Skip to main content

Market Depth Subscription

Info
  • The push delay of this method is about:200ms

Market Depth Subscription

  • Method: depth.subscribe
  • Parameters:
Parameter NameRequiredTypeNotes
market_list[n][0]truestringmarket name.
market_list[n][1]trueintlimit, number of push depth items, one of [5, 10, 20, 50]
market_list[n][2]truestringinterval, merge interval, one of ["0", "0.00000000001", "0.000000000001", "0.0000000001", "0.000000001", "0.00000001", "0.0000001", "0.000001", "0.00001", "0.00 01", "0.001", "0.01", "0.1", "1", "10", "100", "1000"]
market_list[n][3]trueboolif_full, whether it is a full subscription
  • Subscription example
{
"method": "depth.subscribe",
"params": {
"market_list": [
["BTCUSDT", 10, "0", true],
["ETHUSDT", 10, "0", false]
]
},
"id": 1
}

Depth Push

  • Method: depth.update
  • Parameters:
Parameter NameTypeNotes
marketstringMarket name
is_fullboolTrue means full push, and false means incremental push
depthobjectDepth data
depth.asksarraySeller data
asks[n][0]stringSeller price
asks[n][1]stringSeller size. During incremental push, a value of 0 indicates the depth at which the price needs to be deleted.
depth.bidsarrayBuyer data
bids[n][0]stringBuyer price
bids[n][1]stringBuyer size. During incremental push, a value of 0 indicates the depth at which the price needs to be deleted.
depth.laststringLatest price
depth.updated_atintTimestamp (millisecond)
depth.checksumstringData checksum
Reminder

About incremental and full depth push:

  1. Incremental push: Each push delivers the depth data updated from the last push to the present time.In every 200 milliseconds. No push if there is no depth update.
  2. Full push: Each push delivers the complete depth data.In every 200 milliseconds. No push if there is no depth update.
  3. For multiple market subscriptions, use the market params to separate push messages in different markets.
  4. Full market depth push is delivered every 1 minute.

About Depth Checksum:

  1. The checksum is a signed 32-bit integer of the full depth data, used to verify the accuracy of the depth data.
  2. Construct the checksum string: bid1_price:bid1_amount:bid2_price:bid2_amount:ask1_price:ask1_amout:... (if there is no bid, the checksum string will be ask1_price:ask1_amount:ask2_price:ask2_amount:...)
  3. Encode the checksum string using crc32 algorithm

Please check out the Code Examples to see how to use both full and incremental data pushes in the API client to recover complete depth data and verify its accuracy.

  • Push example
{
"method": "depth.update",
"data": {
"market": "BTCUSDT",
"is_full": true,
"depth": {
"asks": [
[
"30740.00",
"0.31763545"
],
[
"30769.00",
"1.45155000"
]
],
"bids": [
[
"30736.00",
"0.04857373"
],
[
"30733.00",
"0.84696320"
],
[
"30725.00",
"0.12563353"
],
[
"30422.00",
"0"
]
],
"last": "30746.28",
"updated_at": 1689152421692,
"checksum": 2578768879
}
},
"id": null
}

Cancel Market Depth Subscription

  • Method: depth.unsubscribe
  • Parameters:
Parameter NameRequiredTypeNotes
market_listtrue[]stringList of market names. Empty list to unsubscribe to all markets.
  • Unsubscribe example:
// unsubscribe to singular market depth
{
"method": "depth.unsubscribe",
"params": {"market_list": ["BTCUSDT"]},
"id": 1
}

// unsubscribe to multiple market depths
{
"method": "depth.unsubscribe",
"params": {"market_list": ["BTCUSDT", "ETHUSDT"]},
"id": 1
}

// unsubscribe to all market depths
{
"method": "depth.unsubscribe",
"params": {"market_list": []},
"id": 1
}