Subscribe 24H Trade Summary
API Description
This Websocket provides real-time 24 hour trading summary for the specified trading instrument. It includes key market metric such as the latest transaction price, highest bid, lowest ask, 24-hour trading volume, etc..
Note: 24H Trade Summary is only available via Websocket API.
Precautions
- Currently, two methods are availabe for 24H trade summary subscription. User should exercise caution while creating connection.
Method 1
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 > Spot > Websocket Public Interface > Method 1
Websocket URL
wss://ws.futurescw.info?token={your_token}
Frequency Limit
None
Subscription Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| event | true | String | subscribe |
| args | true | String | "spot/market-api-ticker:symbol", where symbol is the trading instrument to be subscribed Example: "spot/market-api-ticker:BTC-USDT" |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| channel | String | Subscribed channel, i.e., 'spot/market-api-ticker:BTC-USDT' |
| subject | string | subject: 'spot/market-api-ticker' |
| buy | string | Bid |
| changePrice | string | Price change |
| changeRate | String | Price change percentage |
| high | String | Highest price in the past 24 hours |
| last | String | Latest price |
| low | String | Lowest price in the past 24 hours |
| open | String | Opening Price |
| sell | String | Ask |
| symbol | String | Currency pair ID, i.e., 78 : BTC_USDT Note: The mapping between currency pair ID and Trading instrument can be obtained through Get 24H Trade Summary for All Instruments |
| vol | string | Trading volume in base currency |
| volValue | String | Amount in USDT |
Subscription Example
The following Python code shows how to subscribe to 24 Hour Trading Summary for BTC.
Note: For complete code, please refer to Introduction > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 1
symbol = "BTC-USDT"
args = f'spot/market-api-ticker:{symbol}'
SpotWebsocketPublic(args) # the function SpotWebsocketPublic() is defined in section (Introduction > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 1)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 1.
Response Example
The following is an example response returned by the above Python subscription. The Websocket subscription will keep updating the 24-hour trade summary in real-time. For brevity, only the initial response is provided below:
{'channel': 'spot/market-api-ticker:BTC-USDT',
'subject': 'spot/market-api-ticker',
'data': '{
"buy":"82821.35",
"changePrice":"-610.48",
"changeRate":"-0.007317",
"high":"83799.09",
"last":"82821.45",
"low":"79998.45",
"open":"83431.93",
"sell":"82821.40",
"symbol":"78",
"vol":"10329.2388",
"volValue":"843619014.31"
}'
},.....
Method 2
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 > Spot > Websocket Public Interface > Method 2
Websocket URL
Frequency Limit
None
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., "exchange". Note: Lowercase is recommended. |
| -type | true | String | Defines the function type, e.g., "ticker". Note: Lowercase is recommended. |
| -pairCode | true | String | Currency pair ID, i.e., 78 : BTC_USDT Note: The mapping between currency pair ID and trading instrument can be obtained through Get 24H Trade Summary for All Instruments interface. |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| biz | String | Channel name, e.g., "exchange". |
| pairCode | String | Currency pair ID, i.e., 78 : BTC_USDT Note: The mapping between currency pair ID and trading instrument can be obtained through Get 24H Trade Summary for All Instruments interface. |
| channel | String | Subscription type, e.g., "subscribe". |
| type | String | Message type, e.g., "ticker". |
| -result | Boolean | Result of the subscription request: true or false. |
| data | Json | Data object, containing the following fields: |
| changePrice | bigdecimal | Price change |
| changeRate | bigdecimal | Price change rates |
| high | bigdecimal | Highest price in the past 24 hours ( in quote currency) |
| last | bigdecimal | Latest price in the past 24 hours ( in quote currency) |
| low | bigdecimal | Lowest price in the past 24 hours ( in quote currency) |
| open | bigdecimal | Opening Price ( in quote currency) |
| symbol | string | Currency pair ID, i.e., 78 : BTC_USDT Note: The mapping between currency pair ID and Trading instrument can be obtained through Get 24H Trade Summary for All Instruments |
| vol | bigdecimal | Trading volume in base currency |
| volValue | bigdecimal | Amount in USDT |
Subscription Example
The following Python code shows how to subscribe to 24H trading summary for BTC-USDT.
Note: For complete code, please refer to Introduction > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 2.
url = "wss://ws.futurescw.com"
subscription_params = {"event":"sub",
"params":{"biz":"exchange",
"type":"ticker",
"pairCode":"78"}} # "78" : BTC-USDT
SpotWebsocketPublic(url, subscription_params) # the function SpotWebsocketPublic() is defined in section (Introduction > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 2)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Spot > Websocket Public Interface > Method 2.
Response Example
The following is an example response returned by the above Python subscription. The Websocket subscription will keep updating the 24H trade summary in real-time. For brevity, only the initial response is provided below:
{"biz":"exchange","pairCode":"78","data":{"result":true},"channel":"subscribe","type":"ticker"}
{"biz":"exchange","pairCode":"78","data":
"{\"changePrice\":\"535.14\",
\"changeRate\":\"0.005678\",
\"high\":\"94827.32\",
\"last\":\"94788.99\",
\"low\":\"92788.41\",
\"open\":\"94253.85\",
\"symbol\":\"78\",
\"vol\":\"6209.9048\",
\"volValue\":\"583370376.71\"
}","type":"ticker"},.....