Orderbook update (RPI)
Topic: orderbookupdaterpi@{symbol}
@{depth}
Subscribe to the delta updates of the order book with both non-RPI and RPI orders.
-
With depth level of 50, the incremental changes pushed every 50ms
-
With depth level of 200, the incremental changes pushed every 100ms
-
With depth level of 500, the incremental changes pushed every 200ms
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}
-
Buffer the updates you receive from the stream
-
Get an order book snapshot from https://api.woo.org/v3/public/orderbook?symbol=PERP_BTC_USDT&maxLevel={depth}&rpi=true.
-
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