Finance
The Order Book: How Buyers and Sellers Set a Price
The Order Book is the live ledger of every resting buy and sell order for an asset, sorted by price — the concrete machinery that turns the abstract idea of "supply meets demand" into an actual traded price, one order at a time. Instead of a Walrasian auctioneer announcing a single clearing price, a modern exchange keeps a continuous, price-ordered queue of bids (would-be buyers) and asks (would-be sellers). A price is not decreed; it is discovered the instant an incoming order crosses a resting one and a trade prints. The order book is where the demand curve and supply curve of finance stop being drawings on a chalkboard and become a stack of executable promises.- Core structurePrice-sorted queue of bids (below) and asks (above)
- Key rulePrice-time priority (best price first, then oldest)
- The spreadBest ask − best bid ≥ 0
- First electronic CLOBToronto's CATS, 1977; NASDAQ SOES 1984; Island ECN 1996
- Matching modelContinuous double auction
- Typical S&P 500 spread≈ 1 tick (~$0.01), a few basis points
Interactive visualization
Press play, or step through manually. The visualization is yours to drive — try it before reading on.
Watch the 60-second explainer
A condensed visual walkthrough — narrated, captioned, under a minute.
The mechanism: a continuous double auction
An order book runs a continuous double auction. "Double" because both sides submit prices; "continuous" because matching happens in real time, not at a single call. Two order types drive it. A limit order specifies a price and quantity — "buy 500 shares at ≤ $99.98" — and if it cannot execute immediately it rests in the book, becoming visible depth. A market order specifies only quantity — "buy 500, now" — and executes against the best available resting orders on the other side.
The book is two sorted queues. Bids (buyers) are ranked high-to-low; the best bid is the highest price anyone will pay. Asks (sellers) are ranked low-to-high; the best ask is the lowest price anyone will accept. The gap between them is the bid-ask spread:
spread = best_ask − best_bid ≥ 0
The midpoint mid = (best_bid + best_ask) ÷ 2 is the market's best single-number estimate of "fair value." A trade prints precisely when an incoming order crosses the book — a buy priced at or above the best ask, or a sell at or below the best bid. At that instant the resting order that gets hit sets the price, and the last-traded price updates. Nobody announced it; it emerged from a queue.
Price-time priority: why the queue is fair (and gameable)
Which resting order gets filled first? Almost every major venue uses price-time priority (also called FIFO):
- Price first. The most aggressive price always executes first — the highest bid, the lowest ask.
- Time second. Among orders at the same price, the one that arrived earliest fills first.
This rule has real economic teeth. It rewards traders for (a) improving the price and (b) committing early, which together incentivize tighter spreads and standing liquidity. It is why high-frequency firms race to be first in the queue at a given price level — being one microsecond earlier can mean the difference between a fill and a miss. Some markets (notably many futures on Eurex and some interest-rate products) instead use pro-rata allocation, splitting an incoming order across all resting orders at the best price in proportion to their size, which rewards posting big rather than posting early. The choice of priority rule is not a technicality — it reshapes who provides liquidity and how.
A worked example: sweeping the book
Suppose the book for a stock looks like this (the classic "staircase"):
- Asks: 200 @ $50.05 · 300 @ $50.04 · 150 @ $50.03 (best ask)
- 400 @ $50.01 (best bid) · 250 @ $50.00 · 500 @ $49.99
The spread is $50.03 − $50.01 = $0.02; the mid is $50.02. Now a trader sends a market buy for 400 shares. The matching engine walks up the ask side:
- Fills 150 @ $50.03 → cost $7,504.50
- Fills next 250 @ $50.04 → cost $12,510.00
Total: 400 shares for $20,014.50 → average price $50.03625. Notice three things. First, the buyer paid more than the $50.03 they saw quoted — this excess over the best-ask is slippage, here about $0.006/share. Second, the best ask has jumped to $50.04 (the remaining 50 there) — the trade moved the price up. Third, the trade consumed depth: the book is now thinner. This is price impact, and it is why a large order cannot be filled at a single price. The demand curve of finance has a slope, and you pay it.
Where the spread comes from: the market-maker's problem
Why does the spread exist at all — why isn't the best bid equal to the best ask? Market microstructure theory decomposes the spread into three costs a liquidity provider must recover:
- Order-processing costs — fees, technology, the basic cost of standing ready.
- Inventory risk — a maker who buys accumulates a position and bears the risk it moves against them (Ho–Stoll, Amihud–Mendelson).
- Adverse selection — the Glosten–Milgrom (1985) insight: some counterparties know something you don't. If you post a firm quote, an informed trader will pick it off exactly when it's wrong. The maker widens the spread to be compensated for trading against possibly-informed flow.
Roughly, the equilibrium half-spread must satisfy half_spread ≈ processing + inventory_premium + adverse_selection_premium. This is why spreads widen dramatically in stressed or news-heavy moments (more adverse selection) and in thin names (more inventory risk), and why deeply liquid instruments like SPY or 10-year Treasuries trade at spreads of a fraction of a basis point while a small-cap can quote 1–2% wide. The spread is not a fee gouged from traders; it is the price of immediacy.
Real markets, real episodes, and the limits of the book
Central limit order books (CLOBs) run essentially all modern electronic equity, futures, options, FX, and crypto trading. NASDAQ pioneered electronic quoting; Island/Instinet ECNs in the late 1990s popularized the fully transparent CLOB; today NYSE, Nasdaq, CME Globex, Eurex, and crypto venues like Binance and Coinbase all publish live books. But the book has real limits:
- Depth is fragile. In the Flash Crash of May 6, 2010, a large sell algorithm sweeping the E-mini S&P futures book met evaporating bids; liquidity providers pulled quotes, and the Dow fell ~1,000 points (~9%) in minutes before rebounding. The book showed how thin "visible" liquidity can be.
- Not all liquidity is lit. Dark pools and hidden/iceberg orders let large traders avoid revealing size, so the public book understates true depth. Hidden orders even in "lit" books mean the staircase you see is incomplete.
- Fragmentation. A single U.S. stock trades across ~16 exchanges and dozens of dark venues; the "National Best Bid and Offer" (NBBO) stitches them together, but there is no one canonical book.
The order book is thus a beautifully concrete price-discovery machine — and a reminder that the elegant crossing of supply and demand depends on someone actually being willing to stand there and quote.
A subtle point people get wrong
The most common misconception is that the last-traded price is "the price" and that you can transact there. You can't. The last price is history — it tells you where the previous trade crossed, not where the next one will. Your executable prices are the best bid (if you want to sell now) and the best ask (if you want to buy now), and for anything larger than the top-of-book size, your real price is the volume-weighted path up or down the staircase. A stock "worth $50" with a last print of $50 might cost you $50.05 to buy meaningfully and only fetch $49.95 to sell — that round-trip cost is the spread plus impact.
A second subtlety: a quoted spread of one penny does not mean a penny of cost. If the top of book is only 100 shares deep and you need 10,000, the effective spread you pay can be many times the quoted one. Depth matters as much as the spread — which is exactly why the animation stacks bars by quantity, not just by price.
| Feature | Limit Order | Market Order |
|---|---|---|
| What you fix | Price (max you'll pay / min you'll accept) | Quantity — you take whatever price is available |
| Effect on book | Rests as new depth (adds liquidity) | Consumes resting depth (removes liquidity) |
| Execution | Only if the market reaches your price; may never fill | Immediate, guaranteed fill (if depth exists) |
| Risk you bear | Non-execution / adverse selection | Slippage — walking up the book, worse average price |
| Role played | Liquidity provider ("maker") | Liquidity taker ("taker") |
Frequently asked questions
What is the difference between a limit order and a market order?
A limit order fixes your price ("buy at ≤ $99.98") and rests in the book until the market reaches it — it may never fill, but it never gets a worse price than you set, and it adds liquidity. A market order fixes your quantity and takes whatever prices are available right now, guaranteeing a fill but exposing you to slippage as it walks up or down the book. Limit orders are 'makers'; market orders are 'takers.'
How does the order book actually 'set' a price?
It doesn't set one price — it discovers a sequence of prices. A trade prints only when an incoming order crosses a resting one (a buy at or above the best ask, or a sell at or below the best bid). The resting order that gets hit determines that trade's price, and the last-traded marker updates. The 'market price' at any moment is really the best bid, the best ask, and their midpoint — three numbers, not one.
Why is the bid-ask spread never zero?
Because liquidity providers must be compensated for three costs: order-processing, inventory risk (holding a position that can move against them), and adverse selection (the Glosten–Milgrom problem — some counterparties are informed and will pick off a stale quote). The spread is the price of immediacy. It narrows in deep, low-information markets (a fraction of a basis point for SPY) and widens in thin or news-driven ones.
What is slippage and how do I estimate it?
Slippage is the gap between the price you expected (usually the best quote or mid) and your actual average execution price when your order eats through multiple book levels. Estimate it by summing quantity×price up the staircase until your order is filled, then dividing by total shares. In the worked example, a 400-share market buy averaged $50.03625 versus a $50.03 best ask — about 0.6¢/share of slippage. Bigger orders and thinner books mean more slippage.
Does the whole order book that I see represent all the liquidity?
No. Hidden and iceberg orders sit in the 'lit' book without displaying full size, and dark pools execute large blocks entirely off the visible book. So the public staircase understates true depth. This is also why price can sometimes absorb a big order better than the visible book suggested — hidden liquidity was there — or, in stress, far worse, when quoted depth vanishes (as in the 2010 Flash Crash).
What is price-time priority and why does it matter?
It's the near-universal rule for who gets filled first: the best price executes first, and among equal prices the earliest-arriving order goes first (FIFO). It rewards improving the price and committing early, which tightens spreads and encourages standing liquidity — and it's why high-frequency firms race to be first in the queue. Some futures markets use pro-rata instead, which rewards posting large size rather than posting early.