What does an order book hold?
The diagram below draws an order book with made-up numbers, after the illustration of Gould et al.. Each box is a resting order and the number in it is its size. Buy orders rest below the price axis and sell orders above it, and at each price level the box next to the axis is the order that arrived first. The diagram labels five terms to know:- Best bid is the highest price at which someone is waiting to buy, here 100.
- Best ask is the lowest price at which someone is waiting to sell, here 102.
- Spread is the gap between the two prices: 102 − 100 = 2.
- Mid price is the average of the two: (100 + 102) / 2 = 101.
- Tick size is the smallest price change the exchange allows, here 1.
When a new order arrives, does it wait or trade, and at what price?
There are two basic kinds of order. A market order names no price: it buys or sells at once at the best price available. A limit order buys at no more than the price you set, or sells at no less. The exchange handles the two along two branches: The best resting order is the one with the best price on the opposite side and, at the same price, the one that arrived first. A limit order is marketable when it can trade at once: a buy limit order when its limit is not below the best ask, a sell limit order when its limit is not above the best bid. Send three buy orders into the book of the first diagram, each starting from the original book, and you get three results:
The rule for picking the resting order to trade against is called price-time priority, and most exchanges match orders continuously this way. In an exchange’s fee schedule, an aggressive order is a taker and a passive order is a maker, and each role pays its own fee.
Why does the price move?
The word “price” on a screen covers three different numbers: the best bid, the best ask and the last price, the price of the trade that just happened. The simulation below sends orders at random into an order book. On the left are the best bid and best ask over time, drawn over the size resting at each price. On the right is the order book at the current moment, with a Total column that accumulates size from the best price outward. Take the book of the first diagram again, with a best bid of 100 and a best ask of 102. These two prices change in only three ways:- An aggressive order takes the whole best level. A market order to buy 5 takes the 4 units resting at 102 and 1 unit at 103, so the best ask rises to 103.
- A passive order is placed inside the spread. A limit order to buy 2 at 101 trades with no one, but it bids higher than every resting buy order, so the best bid rises to 101.
- The orders at the best level are cancelled. If both buy orders at 100 are cancelled, the best bid falls to 99.
References
- Statistical theory of the continuous double auction by Smith, Farmer et al.: a model of an order book with random order flow, the idea the simulation on this page rests on.
- Exchange Matching Engine from Coinbase: an exchange’s documentation of price priority, time priority and the trade price.
- What are maker and taker fees? from Binance.US: maker, taker and the fee when an order fills only in part.
Read next
Exchanges and OTC markets
Which markets match orders through an exchange’s order book and which trade through dealers.
Market participants
Who stands behind the resting orders in the book, market by market.

