Skip to main content

Overview

The Market Depth channel provides real-time order book data with support for both one-time queries and subscription-based updates.

Update Behavior

After successful subscription, the server sends a full snapshot of the order book as the first depth_update message. All subsequent messages are incremental updates containing only the changes since the last update.
Public depth updates exclude Retail Price Improvement (RPI) orders. The depth_update stream includes only regular order book liquidity.Private active order endpoints and private WebSocket streams return RPI orders. The exchange UI order book (web and mobile) displays RPI orders.

Understanding Updates

  • First message (past_update_id is absent): Full order book snapshot with all price levels
  • Subsequent messages (past_update_id is present): Only changed price levels
  • Removed levels: Shown as [price, "0"] - when amount is “0”, remove the price level from the local order book
If 10 seconds elapse without any order book changes, the server pushes a full snapshot again as a keepalive mechanism.

Maintaining a Local Order Book

To maintain an accurate local order book, follow the algorithm below:
  1. Subscribe to depth updates
  2. Receive the first message (full snapshot) - initialize the order book
  3. For each incremental update:
    • If amount is “0” → remove the price level
    • If amount is not “0” → update existing level or insert new level at the correct sorted position
  4. Keep order book sorted: asks ascending, bids descending
  5. Truncate to the desired limit after each update

Code Examples