How Trades Work

Chapter 2 of 10

The order book

Every price you see is the edge of a queue of buyers and sellers. Place orders into a live one.

Open any stock app and you see one number: the price. That number is less solid than it looks. It is usually the last price, the price at which the most recent trade happened. It tells you what two other people agreed on a moment ago. It does not tell you what you will pay.

What you will pay is decided by the order book: a list, kept by each exchange for each stock, of everyone who has said "I will buy at this price" or "I will sell at this price" and is still waiting. Buyers waiting are called bids. Sellers waiting are called asks (or offers). The book is the market. Everything else, including the price on your screen, is a summary of it.

Reading the book

The book is drawn as a ladder of prices. Sellers sit above, sorted so the cheapest is closest to the middle. Buyers sit below, sorted so the most generous is closest to the middle. Each row is a price level: every share offered at that exact price, added up, no matter how many separate orders it came from.

Together, the best bid and best ask are called the quote, or the top of the book. When a broker shows you "Bid 100.38, Ask 100.42", it is showing you the inside edge of this ladder.

A live order book

Simulated traders are sending orders into this book right now. Yours go into the same book.

Gold dots mark your resting orders. Tap a row in the book to copy its price into a limit order. Pause the market if it moves too fast to follow.

Two ways to ask for a trade

Every order you send is one of two basic kinds, and the difference is the most useful thing on this page.

A market order says "trade now, at whatever price it takes." It never waits. A market buy goes straight to the cheapest ask and takes those shares; if that level runs out, it moves to the next one up, and the next, until the order is filled. You are certain to trade and uncertain about the price.

A limit order says "trade only at this price or better." A limit buy at $100.30 will happily take any shares offered at $100.30 or less. If none are offered, the order does not disappear: it joins the book as a new bid and waits for a seller to come to it. You are certain about the price and uncertain whether you will trade at all.

Try both in the book above. Send a market buy and watch it eat the bottom red row. Then place a limit buy a few cents under the best bid and watch it sit there with a gold dot, waiting, while the price wanders around it. If the market falls to your price, someone's sell order will hit yours and you will see it fill.

Takers and makers

An order that trades immediately against something already in the book takes liquidity. An order that rests in the book and waits makes liquidity, because it gives the next person something to trade against. Every trade has exactly one of each: a resting order that was there first, and an incoming order that crossed the spread to reach it. The trade happens at the resting order's price. The person in a hurry pays the spread; the person who waited earns it. This is why exchanges often pay a small rebate to makers and charge a small fee to takers, a detail chapter 3 returns to.

The spread is a price you pay

Suppose the best bid is $100.38 and the best ask is $100.42. If you buy 100 shares with a market order you pay $100.42 each. If you changed your mind a second later and sold them with a market order, you would get $100.38. Nothing about the company changed, and you lost $4. That round trip cost is the spread, and it is charged on every immediate trade, whether or not your broker charges a commission.

Measured against the midpoint ($100.40), each half of the round trip costs two cents a share, or about 0.02% of the price. For a single purchase you plan to hold for years, that is nothing. For someone trading the same stock many times a day it is the whole game, and a large part of why frequent traders find it hard to make money.

The price in your app is the last trade, not the price you can get. In a busy stock they are a cent or two apart. In a quiet stock, before the market opens, or during a sharp move, they can be far apart, and a market order will fill wherever the book happens to be.

Walking the book

The best ask only holds a limited number of shares. If your market order is bigger than that level, it keeps going: it takes everything at the best price, then everything at the next price up, and so on. Traders call this walking the book, and the difference between the best price you saw and the average price you actually paid is called slippage.

The book below is frozen so you can see this clearly. Drag the size and watch which levels your order empties. Then switch to the thinly traded stock and try the same size.

Walk the book with one market buy

A snapshot of two order books. Your order takes the cheapest shares first, then moves up.

In the busy stock, a buy of a few hundred shares barely moves past the best ask. A buy of tens of thousands digs several levels deep, and the average price drifts up a few cents. In the thin stock, the same order runs through the book in a few levels and pays many times as much in slippage, because each level holds fewer shares and the levels are further apart.

Big investors handle this by not sending one big market order. They split the order into many small pieces over minutes, hours or days (often with software called an execution algorithm), they use limit orders, or they trade in auctions and private venues covered in chapter 5. Their goal is the same as yours on a smaller scale: to buy without announcing to the whole book that a large buyer has arrived.

Why some stocks have wide spreads

The spread is not set by anyone. It is the gap that remains after everyone willing to quote has put in their best price. A few forces decide how wide it ends up.

What the book does not show you

The ladder on this page is a simplification of a real one in a few honest ways.

There is more than one book. A US stock trades on more than a dozen exchanges at once, including NYSE, Nasdaq, Cboe's exchanges and IEX, plus private venues called dark pools. Each keeps its own book. The national best bid and offer, the NBBO, is the best price across all of them, and rules require that it is respected. Chapter 5 follows an order through that maze.

Some orders are hidden. Many venues let traders post hidden orders, or "iceberg" orders that show only a small piece of a much larger size. Your market order can fill against shares you never saw on the screen.

Small orders may be missing. Orders for fewer than 100 shares are called odd lots. They have historically been left out of the official best quote, so the full book can contain better prices than the quote in your app. Rule changes are adding more odd-lot information to public data, but the gap has been a real quirk for years.

It moves much faster. The simulation here updates a few times a second so you can follow it. A real book for a popular stock can change thousands of times a second, mostly from automated market makers adjusting and cancelling quotes. Most orders placed in a real book are cancelled rather than filled.

What to take from this

When you buy a share you are not buying "at the price." You are trading with a specific person (or program) who posted a specific order in a queue. For most long-term investors in large, busy stocks, the cost of crossing the spread is tiny. It grows quickly with order size, with how thin the stock is, and with how often you trade. A limit order is the simplest protection: it caps the worst price you can get, at the cost of maybe not trading. Next, the rules that decide exactly which orders meet, and in what order.