TradeLabs AILearn

Order Book Feeds: Snapshots and Incremental Updates

How exchanges publish order book data as snapshots and incremental updates, and how to build and maintain an accurate local order book in code without errors.

Advanced3 min readUpdated 3 Oct 2026
Markdown
Lesson 23 of 27

An order book feed tells your program how the queue of buy and sell orders changes over time. Rather than sending the whole book on every change, which would be enormous, venues send a starting snapshot and then a stream of small updates called deltas. Your program combines them to keep a local copy of the book. Done correctly, the local book matches the exchange's view within milliseconds. Done carelessly, it drifts into a fictional market with prices and sizes that no longer exist.

Feed styles#

StyleContentTypical source
Market by price (MBP)Total size at each price levelMost crypto exchanges, many futures feeds
Market by order (MBO)Every individual order with an IDProfessional exchange feeds
Top of bookBest bid and ask onlyLightweight feeds
Periodic snapshotsFull book every N millisecondsSome retail APIs

See Market Data Levels: Level 1, 2 and 3.

Snapshot plus deltas#

  1. Subscribe to the delta stream and start buffering messages.
  2. Request a snapshot of the book, which includes an update ID or sequence number.
  3. Discard buffered deltas older than the snapshot.
  4. Apply remaining deltas in order.
  5. Check continuity: each delta's ID must follow the previous one; if not, start again from step 2.

A delta in a market by price feed usually says "price level X on the bid side now has size Y". A size of zero means remove the level.

def apply_delta(book_side, price, size):
    if size == 0:
        book_side.pop(price, None)
    else:
        book_side[price] = size

Keeping the book sorted#

The best bid is the highest bid price and the best ask is the lowest ask price. A sorted structure, such as a sorted dictionary or a balanced tree, makes reading the top levels fast. For many retail uses, a plain dictionary plus sorting the top few levels when needed is fast enough.

Sanity checks#

CheckProblem it reveals
Best bid below best askA crossed book usually means missed updates
Sequence continuityLost messages. See Sequence Numbers, Dropped Packets and Out-of-Order Messages
ChecksumsSome exchanges publish a checksum of the top levels to compare against
Book ageStale book when updates stop
Level countUnbounded growth from never removed levels

If any check fails, rebuild from a fresh snapshot rather than trying to patch the book.

Market by order books#

MBO feeds send add, modify, cancel and execute messages for individual orders. Your program tracks each order ID and its price and size, and aggregates them into price levels. This allows queue position estimates, useful for market making and execution research. See Fill Probability and Queue Position.

Performance#

Busy books can produce thousands of updates per second. Keep update handling minimal, avoid recalculating everything on each message and move analytics to a separate process if needed. See Exchange vs Receive Timestamps and Latency Measurement and Message Queues.

Recording books#

Storing every delta allows exact replay later, for backtesting execution strategies and debugging. Store snapshots periodically too, so replay can start from any point without processing the whole day. See Market Data Replay.

Frequently asked questions#

What is an order book snapshot?#

A full picture of the bids and asks at a moment in time, usually with an ID that lets later updates be applied correctly.

Why is my local order book crossed?#

Most often because updates were missed or applied out of order. Rebuild the book from a new snapshot.

What is the difference between market by price and market by order?#

Market by price gives total size at each price level; market by order shows every individual order and its changes.

Next, learn how systems normalise feeds from many venues in Feed Handlers and Normalization.

Check your understanding

3 quick questions on this lesson. Get them all right to finish it.

Turn on JavaScript to take the quiz.

Finished this lesson?Sign in to save your progress across devices.
Next lessonFeed Handlers and NormalizationFeed handlers connect to exchange data feeds and convert each venue's format into one standard internal format. Learn the design, symbol mapping and common pitfalls.

Mentioned in