{ "topic": "orderbookupdaterpi@SPOT_BTC_USDT@50", "ts": 1618826337580, // when ws sends the data "data": { "s": "SPOT_BTC_USDT", // symbol "prevTs":1618826337380, // orderbook generation system time of the previously sent message "asks": [ // delta updates on the ask side [ "56749.15", "3.92864" ], [ "56749.8", "0" ], ... ], "bids": [ // delta updates on the bid side [ "56745.2", "1.03895025" ], [ "56744.6", "1.0807" ], ... ], "ts": 1618826337570 // orderbook generation time }}
Public Market Data
Orderbook update (RPI)
Copy
{ "topic": "orderbookupdaterpi@SPOT_BTC_USDT@50", "ts": 1618826337580, // when ws sends the data "data": { "s": "SPOT_BTC_USDT", // symbol "prevTs":1618826337380, // orderbook generation system time of the previously sent message "asks": [ // delta updates on the ask side [ "56749.15", "3.92864" ], [ "56749.8", "0" ], ... ], "bids": [ // delta updates on the bid side [ "56745.2", "1.03895025" ], [ "56744.6", "1.0807" ], ... ], "ts": 1618826337570 // orderbook generation time }}
To keep a local copy of the order book, please follow the steps below:
When using both orderbook snapshot and orderbookupdate streams, ensure both include RPI or both exclude it. Mixing them may result in inconsistent or incorrect order book states.
Open a market data stream and subscribe to orderbookupdaterpi@{symbol}@{depth}
Start processing any updates where prevTs = timestamp in the snapshot
Check prevTs of each newly processed update is the same as the ts of the previous update
If you receive a price level with 0 size, delete that price level
If you receive a price level that does not exist, insert that price level and size
If you receive a price level that already exists, update that price level with the new size
Copy
{ "topic": "orderbookupdaterpi@SPOT_BTC_USDT@50", "ts": 1618826337580, // when ws sends the data "data": { "s": "SPOT_BTC_USDT", // symbol "prevTs":1618826337380, // orderbook generation system time of the previously sent message "asks": [ // delta updates on the ask side [ "56749.15", "3.92864" ], [ "56749.8", "0" ], ... ], "bids": [ // delta updates on the bid side [ "56745.2", "1.03895025" ], [ "56744.6", "1.0807" ], ... ], "ts": 1618826337570 // orderbook generation time }}