Discuss your hiring requirements. Directly with a Partner.Talk to a Partner

+91 70424 03609

The limit order book explained

How the book works, how it is built in software, and what interviews expect you to know.

TL;DR

A limit order book is the record of all resting buy and sell orders for an instrument, organised by price level and, within each level, by arrival order. The highest buy price is the best bid, the lowest sell price is the best offer, and the gap between them is the spread.

Trades happen when an incoming order crosses the spread, or when a new order matches resting interest. Everything in fast trading, from strategy signals to system design, starts with reading and maintaining this structure accurately.

Key points

  • The book is state: a continuously updated picture of resting supply and demand.
  • Most venues use price-time priority, so arrival order within a level matters.
  • Maintaining a correct book in software is a classic HFT engineering problem.
  • Cancellations dominate message traffic, far outnumbering trades.

Jump to FAQs

The structure

Asks (sellers) 101.031,200 101.02760 101.01440 Spread101.00 to 101.01best bid to best offer 101.00600 100.99920 100.981,280 Bids (buyers) Within each level, orders queue in arrival order: first in, first filled under price-time priority. PriceSize
A simplified book. Real venues publish many levels, and update thousands of times a second in active instruments.

How matching works

Most equity and futures venues use price-time priority: better prices match first, and at the same price, earlier orders match first. Some derivatives markets use pro-rata matching, where fills are allocated in proportion to order size, which changes strategy design substantially because size, not arrival time, wins allocation.

How matching works
Event Effect on the book
New limit order inside the spread Creates a new best level, narrowing the spread
New limit order at an existing level Joins the back of that queue
Market order Consumes resting size from the best level, then deeper levels
Cancellation Removes size, possibly changing the best price
Modification Often treated as cancel and replace, losing queue priority

Building an order book in software

This is one of the most common HFT engineering interview questions, and a real production component. The essentials:

  • Data layout: contiguous arrays for levels near the top of the book for cache efficiency, with a map from order ID to location.
  • No allocation on the hot path: memory pools allocated at startup.
  • Update handling: adds, cancels and executions applied in constant or near-constant time.
  • Correctness: sequence number checks, gap detection, snapshot recovery.
  • Publishing: notifying strategies without locking, typically through a lock-free structure.

See the worked design answer in the HFT C++ and system design interview guide.

What the book tells you

  • Imbalance: more size on one side often precedes short-horizon price moves. See order book imbalance.
  • Depth: how much can trade before the price moves meaningfully.
  • Queue dynamics: how quickly levels are consumed or refreshed, which drives fill probability. See queue position.
  • Spread behaviour: widening often signals uncertainty or reduced market maker appetite.

Common misunderstandings

"The book shows real supply and demand." It shows displayed, cancellable interest. Much of it disappears before execution, and hidden or iceberg orders are not fully visible.

"More depth means better liquidity." Depth that vanishes when you trade is not liquidity. What matters is what survives contact with your order.

"Cancellations are noise." Cancellation behaviour is informative, and most messages on active venues are cancels rather than trades.

Frequently asked questions

What is a limit order book?

It is the ordered record of resting buy and sell limit orders for an instrument, grouped by price and sequenced within each price level.

What is price-time priority?

A matching rule where better prices execute first and, at equal prices, earlier orders execute first. Some markets use pro-rata allocation instead.

Why do HFT interviews ask about order books?

Because building and reading one correctly and quickly is a core engineering and research task, and it reveals whether a candidate understands real market mechanics.

Does modifying an order lose queue priority?

On most venues, increasing size or changing price loses priority, because the modification is treated as a cancel and replace. Exact rules vary by venue.