News · New this week
Order book: how a stock trade finds its seller
When you tap Buy on Zerodha, your order is matched against a stranger through an order book, using price first and then time.
When you tap Buy on Zerodha, the money doesn't reach the company. It goes to another person who was selling at that exact second. The app just found them for you.
That matching is the whole job of an order book, and it's a nice small piece of system design.
One list, two sides
Every buy and every sell waits in one list. Buyers sit on one side, sellers on the other. That list is the order book.
Picture it as a line with a gap in the middle. Sell orders stack above the gap. Buy orders stack below it. The gap between them is the spread.
So the flow runs from you, to the order book, to a stranger. There's no company in that path. On the other end is a human who wanted out of the stock when you wanted in.
How it picks your seller
Plenty of sellers can be waiting at once, so the system needs a rule for which one is yours. The rule has two parts.
Price goes first. The lowest ask trades first, because it's the seller closest to the line. If you're buying, the cheapest seller is the best match.
Then time. If two sellers ask the same price, the one who got there earlier wins.
That's price priority, then time priority. Price decides the order of the queue, and arrival time breaks ties inside each price.
The one caveat
All of this describes normal trades on the exchange, where your order is matched against a stranger who wanted out.
An IPO is different. There you're buying from the company itself, so the money does reach it. Outside an IPO, no money reaches the company.
So here's a quick check on your own intuition. Did you think buying a share sends money to the company? For everyday trades, it doesn't.
What to remember
Next time you place an order, picture the book. Your buy lands below the gap, the lowest ask gets served first, and ties go to whoever was earlier. Price first, then time. If you're designing anything that matches two sides of a market, start from that rule.



