The Order Book: How Markets Work Mechanically

The limit order book is not a metaphor. It is a data structure --- a sorted list of buy and sell offers --- and every transaction on a modern electronic exchange is a deterministic consequence of how that data structure processes incoming events. Understanding the order book is understanding the mechanism of price formation at the most fundamental level.

Orders and Their Types

Three types of events change the state of the order book:

Limit orders. A limit order specifies a direction (buy or sell), a price, and a quantity. A buy limit order at price p is an offer to purchase up to q units at price p or better (lower). A sell limit order at price p is an offer to sell up to q units at price p or better (higher). If no matching counterparty exists at the specified price, the limit order “rests” in the book, waiting for a counterparty to arrive. Limit orders provide liquidity: they offer future trading opportunities to other participants.

Market orders. A market order specifies a direction and a quantity but no price. It executes immediately against the best available resting limit orders. A buy market order fills against the lowest-priced sell limit orders; a sell market order fills against the highest-priced buy limit orders. If the market order quantity exceeds the quantity available at the best price, it continues to fill at successively worse prices until the order is complete or the book is exhausted. Market orders consume liquidity.

Cancellations. A participant who has placed a limit order may cancel it at any time before it executes. Cancellations remove liquidity from the book. In modern equity markets, cancellation rates exceed 90 percent: the vast majority of limit orders are withdrawn before a counterparty arrives.

The proportions matter. Limit orders dominate by volume --- they constitute the standing inventory of trading opportunities. Market orders are rare events (a small fraction of messages) but each one causes a transaction and potentially moves the price. Cancellations are the most frequent event type, as market makers continuously adjust their quotes.

The Matching Engine

The matching engine is the algorithm that processes incoming orders against the resting book. Modern exchanges use price-time priority:

  1. At each price level, orders are ranked by arrival time. Earlier orders execute first.
  2. An incoming buy market order is matched against the lowest-priced sell limit orders. Within a price level, the oldest sell limit order fills first.
  3. The transaction price is the price of the resting limit order (not the market order).
  4. If the market order is larger than the available quantity at the best price, it continues to the next price level, filling at a (worse) price.

The process is deterministic. Given the current state of the book and an incoming order, the resulting transactions, remaining book state, and transaction prices are uniquely determined. There is no negotiation, no discretion, and no auctioneer.

The best bid is the highest price at which a buy limit order is resting. The best ask is the lowest price at which a sell limit order is resting. The bid-ask spread is the difference: spread = best ask - best bid. The spread is the immediate cost of a round-trip trade: buying at the ask and selling at the bid loses exactly one spread.

The mid-price is (best bid + best ask) / 2 and serves as the market’s best estimate of fair value. Transaction prices oscillate around the mid-price as buy and sell market orders alternately arrive.

The Book as a State Machine

The order book is a stochastic process. Its state at any moment is the complete set of resting limit orders at every price level on both sides (bid and ask). The state space is enormous: a typical equity order book has orders at hundreds of price levels, with quantities at each level changing hundreds of times per second.

Garman (1976) proposed the first formal model: order arrivals as Poisson processes. Buy limit orders arrive at each price level at some rate; sell limit orders arrive at some rate; market orders arrive at some rate. The model is tractable and produces qualitative predictions about spread behavior, but it misses important features of real order flow.

Glosten and Milgrom (1985) introduced the key refinement: adverse selection. Some market orders are submitted by informed traders who know that the current price is wrong. The market maker cannot distinguish informed from uninformed orders ex ante. To compensate for the expected losses to informed traders, the market maker widens the spread. The equilibrium spread is the one that allows the market maker to break even in expectation: profits from uninformed trades exactly offset losses to informed trades.

This adverse selection model explains why the spread widens when the market maker believes the fraction of informed traders has increased (during earnings announcements, for example) and narrows when information asymmetry is low (during quiet periods). The spread is not a transaction cost set by the exchange; it is an endogenous property of the information environment.

Empirical Properties of Real Order Books

Real order book data --- available as Level 2 (best bid/ask with quantities) or Level 3 (full book at every price level) feeds from exchanges --- reveals several regularities:

Average book shape. The quantity of resting limit orders increases with distance from the best quote. More volume is available at prices far from the best bid/ask than at the best prices. The average shape is approximately power-law or concave: rapid increase near the best quotes, slower increase further away. Bouchaud, Mezard, and Potters (2002) documented this shape and proposed a model of limit order placement at random around the best quotes that reproduces it.

Order size distribution. Individual limit order sizes follow a heavy-tailed distribution: most orders are small, but very large orders appear more frequently than a Gaussian distribution would predict. The tail exponent is approximately 1.5 for U.S. equities (Maslov and Mills, 2001).

Order flow autocorrelation. The signs of successive market orders (buy = +1, sell = -1) are positively autocorrelated: a buy market order is more likely to be followed by another buy than by a sell. This autocorrelation persists for hundreds to thousands of trades. Lillo and Farmer (2004) measured a Hurst exponent of approximately 0.7 for the order sign series, indicating long memory. The mechanism: large institutional orders are split into many small orders executed over hours or days, producing a persistent directional signal in the order flow.

Price impact. A market order moves the price. The size of the impact depends on the order size and the book depth. For small orders, the impact is approximately proportional to the square root of order size: a 4x larger order moves the price 2x as much, not 4x. This concave impact function is documented across equities, futures, and foreign exchange (Bouchaud et al., 2018) and reflects the increasing depth of the book at successive price levels.

Cancellation dynamics. Limit orders placed near the best quotes are cancelled quickly (median lifetime of seconds in liquid markets). Orders placed far from the best quotes last longer. The cancellation rate is not constant: it depends on the distance to the best quote, the time since placement, and the recent price movement. When the price moves toward a resting limit order, its cancellation probability increases sharply --- the order holder suspects adverse selection and withdraws.

These empirical regularities are not features of any specific market or time period. They appear in U.S. equities, European equities, U.S. Treasury futures, foreign exchange, and commodity futures. Their universality across markets suggests that they are properties of the order book mechanism itself, not of the specific information environment or trader population.


Further Reading