How Buyers and Sellers Get Matched
The order book and the price-time priority rule that decides who trades with whom.
At the heart of the exchangeA regulated marketplace where shares are bought and sold. is one fast, fair, dumb machine: the matching engine. It keeps a live list of every buy and sell order — the order bookThe live list of buy and sell orders for a stock. — and pairs them by two simple rules.
Price-time priority
- Price first: the highest bid and the lowest ask get matched first — best prices win.
- Time second: among equal prices, whoever placed the order earlier gets filled first.
A trade happens only when a buyer’s bid meets a seller’s ask at the same price. If the best buyer offers ₹100 and the best seller wants ₹101, nothing trades — until someone moves. That gapA jump between one bar’s close and the next bar’s open. is the spreadThe gap between the highest buy price and lowest sell price. (next lesson).
What is the order book?
A live, ranked list of all outstanding buy orders (bids) and sell orders (asks) for a stock, with their prices and quantities. The “market depth” view in your trading app shows the top few levels of it.