The system will push the orderbook data.If there is no change in the market, data will not be pushed.For depth: 5 or depth: 50, clients can directly use the received snapshots without maintaining a local order book.For depth: increment, clients must maintain a local order book by combining a REST API snapshot with WebSocket delta updates, following the calibration procedure below.
| Level | SPOT | FUTURES |
|---|
| Best 5 | 100ms | 100ms |
| Best 50 | 100ms | 100ms |
| Increment | Real time | Real time |
Subscribe Message#
{
"id": "1545910660739",
"action": "SUBSCRIBE",
"channel":"obu",
"tradeType": "SPOT",
"symbol": "BTC-USDT",
"depth": "5"
}
Response for Best 5, Best 50 or Snapshot#
Example{
"T": "obu.SPOT",
"dp": "5",
"t": "snapshot",
"P": 1760337567241259000,
"d": {
"E": 22539882000,
"M": 1760337567229000,
"a": [
[
"115132.2",
"0.2149304"
],
[
"115132.3",
"0.02623069"
]
],
"b": [
[
"115132.1",
"0.83498092"
]
],
"s": "BTC-USDT"
}
}
Response for increment#
Example{
"T": "obu.spot",
"dp": "increment",
"t": "delta",
"P": 1760337523292213500,
"d": {
"C": 22539873357,
"M": 1760337523290000,
"O": 22539873357,
"a": [
[
"115177.5",
"0"
]
],
"b": [],
"s": "BTC-USDT"
}
}
To maintain an accurate local order book, follow these steps:1.
Subscribe to the WebSocket Level 2 data feed for the desired trading pair and depth (e.g., obu.spot, dp: increment).
Cache all incoming WebSocket messages (snapshots and deltas) for playback.
2.
Make a REST API request to Get Full Order Book to retrieve a complete snapshot of the order book.
The snapshot provides the initial state with a sequence number, bids, and asks.
3.
Replay cached WebSocket messages (deltas) in sequence order to update the local snapshot.
Ensure continuity by verifying that for each delta:
sequenceStart(new) <= sequenceEnd(old) + 1
sequenceEnd(new) > sequenceEnd(old)
The sequence number in each delta sequenceStart and sequenceEnd represents the range of updates. Only apply deltas with sequence numbers greater than the snapshot's sequence number.
4.
For each delta update in the b (bids) or a (asks) arrays:If size is 0, remove the corresponding price from the order book.
If size is non-zero, update the price with the new size.
Update the local order book's sequence number to the sequenceEnd of the latest applied delta.
The sequence on each record in changes only represents the last modification of the corresponding sequence of the price, not as a basis for judging the continuity of the message; for example, when there are multiple updates at the same price, only the latest data will be pushed
Suppose a REST API request to Get Full Order Book returns the following snapshot with sequence number 100001: "sequence": "100001",
"asks": [
["115669", "0.1"],
["115553.5", "0.05"],
["115442", "0.2"]
],
"bids": [
["115404", "0.5"],
["115403.5", "0.3"],
["115388.9", "0.1"]
]
}
The current data on the local order book is as follows:| Price | Size | Side |
|---|
| 115669 | 0.1 | Sell |
| 115553.5 | 0.05 | Sell |
| 115442 | 0.2 | Sell |
| 115404 | 0.5 | Buy |
| 115403.5 | 0.3 | Buy |
| 115388.9 | 0.1 | Buy |
The order book’s sequence number is 100001.Processing WebSocket Delta UpdatesThe following WebSocket delta updates are received{
"T": "obu.spot",
"t": "delta",
"dp": "increment",
"P": 1760324595709048090,
"d": {
"C": 100002,
"M": 1760324595706000,
"O": 100002,
"a": [["115669", "0.0151843"]],
"b": [],
"s": "BTC-USDT"
}
}
Verify Sequence Continuity:Current order book sequence: 100001.
Delta’s sequenceStart (O): 100002.
Delta’s sequenceEnd (C): 100002.
Check: sequenceStart (100002) <= sequenceEnd(old) + 1 (100001 + 1 = 100002) and
sequenceEnd (100002) > sequenceEnd(old) (100001).
The delta is valid and can be applied.
Set ask size for price 115669 to 0.0151843.
Set the order book’s sequence number to sequenceEnd (C): 100002.
{
"T": "obu.spot",
"t": "delta",
"dp": "increment",
"P": 1760324595709048090,
"d": {
"C": 100003,
"M": 1760324595706000,
"O": 100003,
"a": [],
"b": [["115404", "0"]],
"s": "BTC-USDT"
}
}
Verify Sequence Continuity:Current order book sequence: 100002.
Delta’s sequenceStart (O): 100003.
Delta’s sequenceEnd (C): 100003.
Check: sequenceStart (100003) <= sequenceEnd(old) + 1 (100002 + 1 = 100003) and
sequenceEnd (100003) > sequenceEnd(old) (100002).
The delta is valid and can be applied.
Remove the price 115404 from the order book
Set the order book’s sequence number to sequenceEnd (C): 100003.
| Price | Size | Side |
|---|
| 115669 | 0.0151843 | Sell |
| 115553.5 | 0.05 | Sell |
| 115442 | 0.2 | Sell |
| 115403.5 | 0.3 | Buy |
| 115388.9 | 0.1 | Buy |