A share price on a screen looks like a single fact, but it is the output of a process. Somewhere, an exchange is holding a list of instructions from people who want to buy and people who want to sell, and the price shown is the level at which the most recent pair of those instructions met. This article describes that process step by step, using an invented Company A and invented orders.
The order book: two queues facing each other
In one line: buy orders sit on one side, sell orders on the other, each sorted by price.
For each listed security, the exchange keeps an order book. Buy orders, called bids, are sorted with the highest price at the top. Sell orders, called asks or offers, are sorted with the lowest price at the top. The two best prices face each other in the middle of the book.
| Bids: quantity | Bid price | Ask price | Asks: quantity |
|---|---|---|---|
| 300 | $19.98 | $20.02 | 200 |
| 500 | $19.97 | $20.03 | 400 |
| 800 | $19.95 | $20.05 | 600 |
Each line shows how many shares are waiting at each price. In this illustration, buyers are waiting to buy 300 shares at $19.98 and sellers are waiting to sell 200 shares at $20.02. Nobody has agreed yet, so no exchange has taken place at these levels.
Bid, ask and the spread
In one line: the spread is the gap between the best bid and the best ask.
The best bid ($19.98) and the best ask ($20.02) together form the quote. The difference between them, four cents here, is the spread. It is a real cost for anyone who buys and then sells straight away: they would buy at the ask and sell at the bid, losing the spread in the process. The midpoint, $20.00, is often used as a reference price, but no order necessarily exists there.
Limit orders and market orders
In one line: a limit order names a price; a market order accepts the best available one.
A limit order says: buy or sell this many shares, at this price or better. If it cannot be filled at once, it joins the book and waits. The orders in the table are all limit orders. A market order says: buy or sell this many shares now, at the best prices available. It does not wait; it takes liquidity from the book.
If a market order to buy 500 shares arrived in our example, it would take the 200 shares offered at $20.02, then 300 of the 400 offered at $20.03. The buyer would pay two different prices. This is why market orders can be filled at less favourable prices than the quote suggests, especially when the book is thin.
Price-time priority: who meets first
In one line: the best price is served first; at equal prices, the earliest order is served first.
Most exchanges match continuously during the session using price-time priority. When a new order arrives, the matching engine follows a fixed sequence:
- Check whether the new order's price reaches the best price on the opposite side.
- If it does, match it against the best-priced resting order.
- Among resting orders at the same price, match the one that arrived first.
- Repeat until the new order is filled or no opposite order reaches its price.
- Place any remaining quantity of a limit order in the book at its own price, behind earlier orders at that price.
Each match produces a transaction, and its price becomes the latest reported price. Because the rules are published and applied mechanically, two identical orders arriving in the same sequence will always be treated the same way.
Opening and closing auctions
In one line: at the start and end of the session, orders are collected and matched at one price.
Continuous matching is not used all day everywhere. Many exchanges open and close the session with an auction. For a set period, orders are collected without being matched. At the end of that period, the exchange calculates the single price at which the largest quantity of shares can change hands, and all eligible orders are matched at that price. Closing prices, which many funds and indexes use for daily valuations, often come from these auctions.
Why spreads differ between securities
In one line: more waiting orders on both sides usually means a narrower gap.
Securities with many active buyers and sellers tend to have deep books and narrow spreads. Smaller companies, or any security during a period of uncertainty, may have fewer orders waiting and wider spreads. Some participants, often called market makers, continuously post both bids and asks and earn the spread in return for taking the risk of holding inventory. Their presence can narrow spreads, but it does not remove the risk that prices move.
Seen as a machine, an exchange is a sorting and pairing engine. It does not decide what anything is worth. It applies the same published rules to every order and reports the prices at which orders met.
Educational content, not advice
This article explains a general mechanism. It is not a recommendation to buy, sell or hold any security, and it does not take your personal circumstances into account. All investments carry risk, including the possible loss of capital.