DATA · ORDER BOOK

Order-Book WebSocket Reconnects: Rebuild Depth Before Reading Imbalance

After a WebSocket reconnect, your local order book may be missing updates. Reading imbalance from it before rebuilding gives numbers that never existed.

Short answer

A local order book built from WebSocket diff updates is valid only if every update since a snapshot was applied in sequence. After a disconnect, updates are missed; the book must be rebuilt by fetching a fresh REST snapshot, buffering new updates, discarding those older than the snapshot and applying the rest in order (exchanges such as Binance document a sequence-ID procedure for this). Until rebuilt, do not compute imbalance, depth or heatmap values, and mark the gap.

Why the book breaks

Reconnect without rebuildReconnect without rebuild: CONNECTED: Applying updates 1–500; DROP: Updates 501–620 missed; RECONNECT: Updates from 621 applied; RESULT: Book contains stale and missing levels.CONNECTEDApplying updates 1–500DROPUpdates 501–620 missedRECONNECTUpdates from 621 appliedRESULTBook contains stale andmissing levels
Levels removed during the gap stay in your book. Original ChartsPod editorial graphic.

Check Order-Book WebSocket Reconnects against a live market before relying on it.

Try it in ChartsPod

Rebuild procedure

Rebuilding depthRebuilding depth. Steps: 1. Buffer stream — Start collecting updates; 2. Fetch snapshot — REST depth with sequence ID; 3. Drop old updates — Before snapshot ID; 4. Apply in order — Check continuity; 5. Mark gap — Until rebuilt1Buffer streamStart collectingupdates2Fetch snapshotREST depth withsequence ID3Drop old updatesBefore snapshot ID4Apply in orderCheck continuity5Mark gapUntil rebuilt
Follow the exchange's documented sequence rules. Original ChartsPod editorial graphic.
CheckWhy
Sequence continuityDetects missed updates
Snapshot freshnessAvoids stale base
Gap flagPrevents false imbalance readings

Impact on analysis

Illustrative: after a 20-second drop during a fast move, a stale book still shows 300 BTC of bids that were cancelled. Imbalance reads strongly bid-heavy; the real book was ask-heavy.

Illustrative bid/ask imbalanceIllustrative bid/ask imbalance: Stale book 0.72 ; Rebuilt book 0.41 .ILLUSTRATIVE BID/ASK IMBALANCEStale book0.72Rebuilt book0.41
Bid share of depth within 0.5%. The stale book flipped the reading. Original ChartsPod editorial graphic.

Monitoring book health

Track three numbers for any live order-book feed: time since last update, sequence gaps detected, and time since last full rebuild. Display them beside depth-based indicators. When any exceeds a threshold, grey out imbalance and heatmap outputs until the book is rebuilt. It is better to show 'unknown' than a confident wrong number.

Conclusion

Related: Crypto Heatmap Grey Zones: Missing Depth Is Not Zero Liquidity, How to Diagnose Missing Order-Flow Data in ChartsPod.

Rebuild the order book from a fresh snapshot after any reconnect, and don't read imbalance until it is consistent.

Compare Order-Book WebSocket Reconnects across Binance, Bybit, OKX and Hyperliquid markets.

Open markets in ChartsPod

Questions readers ask

Why does my order book look wrong after reconnecting?

Updates were missed during the disconnect.

How do I fix it?

Fetch a new snapshot and apply buffered updates in sequence.

Can I keep reading imbalance during rebuild?

No; mark the period as unreliable.

Sources and methodology

API behaviour comes from DEX Screener's API reference, CoinGecko's onchain API documentation and Binance's USD-M market data documentation as read on 17 October 2026. Code-level details are described conceptually; check current endpoint versions before building. Examples use illustrative values.

  1. Binance: USD-M Futures market data API — trades, depth, funding and open interest.
  2. ChartsPod: product overview, pricing and FAQ — free terminal, venues, modules, no order placement; checked 17 Oct 2026.

This article explains research tools and workflows. It is not financial advice, does not recommend buying or selling any asset and does not predict prices. Crypto derivatives carry a risk of rapid and total loss of margin.

CHARTSPOD EDITORIAL EDITION · RESEARCH AND EDUCATION ONLY · NOT FINANCIAL ADVICE.