Skip to main content

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

wss://ws.futurescw.com/perpum

Frequency Limit

The frequency limit for this subscription is 3 requests/s per IP.

Subscription Parameters

ParameterMandatoryTypeDescription
eventtrueStringSubscribe or unsubscribe. sub: subscribe; unsub: unsubscribe.
Note: This parameter is case-sensitive.
paramstrueJsonRequested parameter objects including:
-biztrueStringSpecifies the channel, e.g., "futures".
Note: Lowercase is recommended.
-typetrueStringDefines the function type, e.g., "ticker_swap".
Note: Lowercase is recommended.
-pairCodetrueStringThe 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

ParameterTypeDescription
bizStringSpecifies the channel, e.g., "futures".
typeStringDefines the function type, e.g., "ticker_swap".
resultbooleanIndicates whether the subscription or unsubscription was successful: true, false.
channelStringSpecifies the action performed: subscribe or unsubscribe.
pairCodeStringBase currency of the instrument, e.g., BTC.
dataJsonData object, containing the following fields:
-highStringHighest price in the last 24 hours.
-volStringTrading volume denominated in the base currency in the last 24 hours.
-volUsdtStringTrading volume denominated in USDT in the last 24 hours.
-lastStringThe latest trading price in the last 24 hours.
-lowStringThe lowest price in the last 24 hours.
-changeRateStringPrice change in the last 24 hours.
-currencyCodeStringCurrency code i.e., btc.
-openStringOpening 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'}..............