Subscribe 24H Trade Summary
API Description
This websocket allows querying the real-time 24-hour trade summary for a specified instrument including the highest price, lowest price, maximum leverage, total trading volume, latest price and contract size.
Note: 24H Trade Summary data is only available via Websocket API.
Precautions
None
Authentication
This is a public websocket and does not require authentication. For details on using the Websocket API, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Public Interface.
Websocket URL
Frequency Limit
The frequency limit for this subscription is 3 requests/s per IP.
Subscription Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| event | true | String | Subscribe or unsubscribe. sub: subscribe; unsub: unsubscribe. Note: This parameter is case-sensitive. |
| params | true | Json | Requested parameter objects including: |
| -biz | true | String | Specifies the channel, e.g., "futures". Note: Lowercase is recommended. |
| -type | true | String | Defines the function type, e.g., "ticker_swap". Note: Lowercase is recommended. |
| -pairCode | true | String | The base currency of the instrument. (e.g., BTC or btc). This parameter is case-insensitive. Note: For instruments that start with numbers (e.g., 1000PEPE), both uppercase and lowercase formats are valid. |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| biz | String | Specifies the channel, e.g., "futures". |
| type | String | Defines the function type, e.g., "ticker_swap". |
| result | boolean | Indicates whether the subscription or unsubscription was successful: true, false. |
| channel | String | Specifies the action performed: subscribe or unsubscribe. |
| pairCode | String | Base currency of the instrument, e.g., BTC. |
| data | Json | Data object, containing the following fields: |
| -high | String | Highest price in the last 24 hours. |
| -vol | String | Trading volume denominated in the base currency in the last 24 hours. |
| -volUsdt | String | Trading volume denominated in USDT in the last 24 hours. |
| -last | String | The latest trading price in the last 24 hours. |
| -low | String | The lowest price in the last 24 hours. |
| -changeRate | String | Price change in the last 24 hours. |
| -currencyCode | String | Currency code i.e., btc. |
| -open | String | Opening price in the last 24 hours. |
Subscription Example
The following Python code shows how to subscribe to 24-hour trade summary for BTC.
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Public Interface.
subscription_params = { "event": "sub",
"params": {
"biz": "futures",
"pairCode": "BTC",
"type": "ticker_swap"}}
url = "wss://ws.futurescw.com/perpum"
FuturesWebsocketPublic(url, subscription_params) #function FuturesWebsocketPublic() is defined in section (Introduction > Authentication & Code Snippet > Futures > Websocket Public Interface)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Public Interface.
Response Example
The Websocket subscription will keep updating the 24-hour trade summary in real-time. For brevity, only the initial response for python subscrption is provided below:
{'biz': 'futures',
'pairCode': 'BTC',
'data': {'result': True},
'channel': 'subscribe',
'type': 'ticker_swap'}
{'biz': 'futures',
'pairCode': 'BTC',
'data': {'high': '96721.6',
'vol': '184464.598',
'volUsdt': '17546484639.42',
'last': '96192.6',
'low': '93321.4',
'changeRate': '-0.000020',
'currencyCode': 'btc',
'open': '96194.5'},
'type': 'ticker_swap'}..............