Methods noteMarket data

Rebuilding an order book from snapshots and diffs

Order book reconstruction applies sequenced diffs to a full snapshot under each venue's own numbering and checks, and one missed update leaves the book wrong until it is resynchronized.

Cover of the full report: Rebuilding an order book from snapshots and diffs
The research behind this article, with every source listed. 20 pages.

Key points

From the Summary of the full report

  1. Order book reconstruction applies diffs to a full snapshot in the order the venue published them. Each of the seven venues studied here sets its own rules for what a diff's size means, how the first diff is matched to the snapshot, how updates are numbered and what a client does after a gap [1, 16, 19, 27, 29].
  2. Coinbase, Binance and Lighter send the new total at a price level, and zero removes it [16, 19, 28]. Kraken removes a level on a quantity of 0 [22]. Nasdaq TotalView-ITCH sends executions and partial cancels as shares to subtract, and CME's market-by-price book addresses levels by position [3, 12].
  3. Gap tests differ by venue and by product. Binance Spot and Futures chain events by different fields, Lighter checks nonce ranges, and NYSE Daily TAQ and CME's per-product files carry numbers that skip by design [10, 15, 16, 17, 27].

Order book reconstruction starts from a full snapshot of the book and applies every later change, or diff, in the order the venue published it [16, 19, 27]. The book at any moment is the last snapshot plus every diff after it. The work sits in three places: reading what a diff's size means, finding the first diff that follows the snapshot, and noticing when a diff goes missing.

One missed diff leaves the book wrong until it is resynchronized. CME Group's rule for its MDP 3.0 feed is direct: after a packet gap, "it should be assumed that all books maintained in the client system may no longer have the correct, latest state" [1]. Each venue sets its own rules for sequencing, batching and recovery.

This note reads the published rules of CME MDP 3.0, Nasdaq TotalView-ITCH, Binance, Coinbase, Kraken, Lighter and Hyperliquid as they stood on 24 October 2026, and turns them into one procedure with tests.

What a diff's size means

Coinbase, Binance and Lighter send the new total at a price level [16, 19, 28]. Coinbase defines its level2 size as "the updated size at the price level", and a size of "0" removes the level [19]. Binance Spot tells clients to "set the new quantity" and to remove a level whose quantity is zero [16]. Lighter's size "is its new total" [28]. Kraken removes a level on a quantity of 0 [22].

Order-level feeds can send amounts to subtract. In Nasdaq TotalView-ITCH, an execution or a partial cancel states the shares removed from an order, and repeated messages are cumulative [12].

CME's market-by-order Update carries the order's new displayed quantity: an order raised from 30 to 50 arrives as 50, with a new, lower priority [4]. Hyperliquid's node records an order update with both the old size, origSz, and the new one, newSz [32]. CME's market-by-price book addresses levels by position: an add shifts lower levels down, and the client deletes any level past the depth set in tag 264 [3]. CME's trade data block and ITCH's Trade Message, sent for non-displayable orders, do not change the book [3, 12].

Order book snapshot and delta alignment

Where the snapshot comes from a separate request, every documented procedure has the same shape: buffer the diffs, take the snapshot, drop the diffs the snapshot already contains, then apply the rest [7, 16, 19].

Binance Spot spells it out. Buffer the stream and note the first event's U. Fetch a snapshot of up to 5,000 levels per side. If its lastUpdateId is below that U, fetch again. Discard every event whose u is at or below lastUpdateId [16]. Coinbase's full channel discards queued messages with sequence numbers "before or equal to the snapshot sequence number" [19]. CME compares tag 369, LastMsgSeqNumProcessed, on each recovery snapshot with the incremental feed's packet numbers and drops cached packets below it [7]. Nasdaq's GLIMPSE, as specified for its BX market, ends each snapshot with a message naming the ITCH sequence number to start from [14].

Sequence gap detection

Each venue numbers updates its own way, and the gap test has to match.

Feed What is numbered Gap test
CME MDP 3.0 Each packet, per channel, reset weekly. Tag 83 RptSeq per instrument A skipped packet number [2, 6]
Nasdaq ITCH over MoldUDP64 The first message in each packet, later ones implied Next expected number not received [13]
Binance Spot First and last update ID per event, U and u U above the local update ID + 1 [16]
Binance USD-M Futures Each event's pu, the previous event's u pu unequal to the previous u [17]
Coinbase full and level3 Each message, per product A jump of more than one [20]
Lighter A nonce range per update, plus a server offset begin_nonce unequal to the previous nonce [27, 28]
Kraken Spot book v2 No sequence field listed None. The checksum shows a wrong book [22, 23]
Hyperliquid l2Book Nothing: every push is a snapshot None needed [29]

Three traps recur. Lighter's offset increases on each update, but it is "not guaranteed to be continuous" and can change sharply when a reconnect lands on a different server, so the nonce is the field to check [27, 28]. One Lighter update spans a range of nonces, so a test that expects +1 per message fails [27]. Some numbers skip by design. In NYSE Daily TAQ, Tape A and B sequence numbers equal the CTA block number times 100 plus the message ID, and they "do not increase continuously" [15]. CME's per-product historical files skip packet numbers that "were assigned to another product" [10]. A plain +1 test raises false alarms on both.

Silence needs a test as well. MoldUDP64 heartbeats carry the next expected sequence number, so a receiver can tell a quiet market from lost packets [13].

Batches, depth limits and snapshot-only feeds

A book read in the middle of a batch is not valid. CME requires every book update in the latest incremental message to be processed first, and one event can span several packets [1, 2, 5]. Kraken can send several updates to the same price level in one message, to be applied in order [23]. Coinbase's level2_batch channel and Lighter's order book channel send batches every 50 milliseconds [19, 27].

Depth limits leave parts of the book unknown. Binance warns that levels outside its 5,000-level snapshot stay unknown "unless they change" [16]. Kraken sends no zero-quantity update for a level that falls out of the subscribed depth, so the client truncates its book after each update [22, 24]. An unknown level and an empty level are different facts, and a rebuilt book should record which is which.

Some feeds send snapshots only. Hyperliquid's l2Book pushes 20 levels, or 5 in fast mode, "on each block that is at least 0.5 since last push", with no sequence field [29]. A history built from it has the cadence and depth of those pushes.

Order book checksum and other state checks

Among the feeds read, only Kraken documents a checksum. Each book message carries a CRC32 over the top 10 levels per side, whatever depth is subscribed [22]. The input is the asks and then the bids, with decimal points and leading zeros removed [22]. This note's own computation from the levels in Kraken's worked example gives the documented 3310070434 [22].

Other checks need no venue support. Kraken states that its level 3 book "will never be crossed" [25]. This note treats a rebuilt book whose best bid meets or passes its best ask in continuous trading as a failed check, to be compared against the source.

Building a market-by-order book

CME tells clients to sort orders by price and then by tag 37707, where a lower value means higher priority [4]. An ITCH Order Replace retires the old reference number and issues a new one "for all subsequent updates", and side and symbol carry over from the original Add Order [12]. Coinbase's full channel sends done and change messages for orders that never reached the book, and applying them makes the book incorrect [19].

Recovery and replaying historical order book data

Venues offer three ways back: a fresh snapshot, a replay of the missed messages, or a new subscription. CME recommends processing both of its redundant A and B feeds, then offers a snapshot loop for large recoveries and TCP replay for small ones, capped at 2,000 packets per request and 24 hours of history [1, 7, 8]. Binance says to discard the book and restart, and Lighter's guide resubscribes [16, 28]. In a CME channel reset the client empties the book and RptSeq restarts at 1, which a gap test must read as a reset [9].

Archives carry gaps too, and some list them. CME's packet capture dataset lists its known gaps by date [11]. Hyperliquid uploads its archive "approximately once a month" and states that "data may be missing" [30]. A published research dataset of order data from Hyperliquid's perpetual futures states its coverage by month: 744 hourly book-diff files for December 2025 with no gaps, and trade files missing 2, 10, 0 and 1 hours from October 2025 to January 2026 [33]. The note on datasets that state their limits sets out how scope and refresh can travel with every record.

Order book reconstruction tests

A rebuilt book should pass these tests:

  1. Every update passes the venue's continuity rule, with documented skips and resets handled [9, 10, 15].
  2. The first applied diff meets the venue's boundary rule [7, 14, 16].
  3. No check runs in the middle of a message, event or batch [1, 22].
  4. The checksum matches, where the venue sends one [22].
  5. The best bid stays below the best ask in continuous trading.
  6. The book is cut to its subscribed or published depth [3, 22].
  7. Every gap and resync is recorded with its time range.

Rillor's market data holds on-chain perpetual futures order books rebuilt from snapshots and book diffs. Book sequence numbers are checked on every rebuild, and gaps are written into the coverage notes for each instrument [34].

Read the full report

The full report sets out each venue's rules with exact field names, a cross-venue comparison table, a venue-neutral procedure in pseudocode with ten tests, and the complete source list.

The full report

Rebuilding an order book from snapshots and diffs

The research behind this article, with every source listed. 20 pages.

  1. Summary
  2. Background
  3. Method
  4. Findings
  5. Implications
  6. Limits of this analysis
  7. Sources

Sources

  1. MDP 3.0 - Recovery Services. CME Group Client Systems Wiki, page version 2, 26 December 2024. https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457325847/MDP+3.0+-+Recovery+Services
  2. MDP 3.0 - Packet Structure with Event Based Messaging. CME Group Client Systems Wiki, page version 4, 13 May 2026. https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457326496
  3. MDP 3.0 - Market by Price - Multiple Depth Book. CME Group Client Systems Wiki, page version 2, 26 December 2024. https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457574047
  4. MDP 3.0 - Market by Order - Book Management. CME Group Client Systems Wiki, page version 2, 23 December 2024. https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457605721/MDP+3.0+-+Market+by+Order+-+Book+Management
  5. MDP 3.0 - Implied Book. CME Group Client Systems Wiki, page version 3, 10 January 2025. https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457422235
  6. MDP 3.0 - Market by Price - Book Recovery Methods for Concurrent Processing. CME Group Client Systems Wiki, page version 3, 10 January 2025. https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457705188
  7. MDP 3.0 - MBP and MBOFD Market Recovery. CME Group Client Systems Wiki, page version 4, 1 October 2025. https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457672425
  8. MDP 3.0 - TCP Recovery. CME Group Client Systems Wiki, page version 4, 10 January 2025. https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457574209
  9. MDP 3.0 - Channel Reset. CME Group Client Systems Wiki, page version 5, 9 June 2026. https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457326922
  10. MBO FIX (CME DataMine dataset). CME Group Client Systems Wiki, page version 7, 20 October 2026. https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457223111/MBO+FIX
  11. Packet Capture Dataset (CME DataMine). CME Group Client Systems Wiki, page version 8, 20 October 2026. https://cmegroupclientsite.atlassian.net/wiki/spaces/EPICSANDBOX/pages/457323061/Packet+Capture+Dataset
  12. Nasdaq TotalView-ITCH 5.0 Specification. Nasdaq, latest revision 28 April 2023. https://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/NQTVITCHSpecification.pdf
  13. MoldUDP64 Protocol Specification, Version 1.00. Nasdaq, last revised 2 August 2024. https://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/moldudp64.pdf
  14. BX GLIMPSE 5.0 Interface Specification, Version 5.00. Nasdaq, 1 October 2013. https://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/BXGLIMPSESpecification_5.0.pdf
  15. Daily TAQ Client Specifications, Version 4.0. NYSE, 2 November 2022. https://www.nyse.com/publicdocs/nyse/data/Daily_TAQ_Client_Spec_v4.0.pdf
  16. WebSocket Streams for Binance (web-socket-streams.md). Binance, binance-spot-api-docs repository on GitHub, last changed 15 October 2026. https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-streams.md
  17. How to manage a local order book correctly (USDⓈ-M Futures). Binance Developer Docs, viewed 24 October 2026. https://developers.binance.com/docs/derivatives/usds-margined-futures/websocket-market-streams/How-to-manage-a-local-order-book-correctly
  18. Exchange WebSocket Channels. Coinbase Developer Documentation, viewed 24 October 2026. https://docs.cdp.coinbase.com/exchange/websocket-feed/channels
  19. Exchange WebSocket Overview. Coinbase Developer Documentation, viewed 24 October 2026. https://docs.cdp.coinbase.com/exchange/websocket-feed/overview
  20. Book checksum (WebSocket v2). Kraken Developers, viewed 24 October 2026. https://docs.kraken.com/api/docs/guides/spot-ws-book-v2
  21. Book (Level 2), WebSocket v2. Kraken Developers, viewed 24 October 2026. https://docs.kraken.com/api/docs/websocket-v2/book
  22. Orders (Level 3), WebSocket v2. Kraken Developers, viewed 24 October 2026. https://docs.kraken.com/api/docs/websocket-v2/level3
  23. Spot Level 3 Market Data. Kraken Developers, viewed 24 October 2026. https://docs.kraken.com/api/docs/guides/spot-l3-data
  24. WebSocket. Lighter API documentation, updated 18 October 2026. https://apidocs.lighter.xyz/docs/websocket-reference
  25. Market data. Lighter API documentation, updated 18 October 2026. https://apidocs.lighter.xyz/docs/market-data
  26. WebSocket: Subscriptions. Hyperliquid Docs, viewed 24 October 2026. https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/websocket/subscriptions
  27. Historical data. Hyperliquid Docs, viewed 24 October 2026. https://hyperliquid.gitbook.io/hyperliquid-docs/historical-data
  28. L1 data schemas. Hyperliquid Docs, viewed 24 October 2026. https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/nodes/l1-data-schemas
  29. An Open Book: Level 4 Order Book Data from the Hyperliquid Exchange, version 1.0 (dataset), by Jakob Albers, Mihai Cucuringu, Sam Howison and Alexander Y. Shestopaloff. Zenodo, 25 March 2026. https://zenodo.org/records/18184441
  30. Market data. Rillor, viewed 7 November 2026. https://rillor.com/markets/market-data

Notices

Rillor is not a registered investment adviser or commodity trading advisor and does not provide investment or trading advice. Research, forecasts, data and software described on this site are for research and engineering use. Nothing here is an offer or recommendation to buy or sell any security, commodity interest or digital asset. Past or simulated results do not indicate future results.

Tell us the instruments and history you need.

Send the instruments, the history window, the delivery format and the intended use.

Request market data