What a stock exchange actually does

Reading for India · about 10 min

The answer

A stock exchange is a matching machine. It takes everybody's buy orders and sell orders, sorts them by price and then by time, and pairs up the ones that agree. It does not set prices, hold your shares, or have an opinion about any company.

Why this costs you money

There is a cost on every trade you make that does not appear on your contract note, and for many retail traders it is larger than the brokerage.

It is called the spread.

At any moment there are 2 prices for a stock, not 1. The highest price somebody is willing to buy at, and the lowest price somebody is willing to sell at. Those are never the same number. The gap between them is the spread, and when you buy at the seller's price and later sell at the buyer's price, you have paid it.

On a large company the gap might be 5 paise on a ₹1,500 stock. That is nothing.

On a small company it can be ₹2 on a ₹95 stock. That is over 2%. You have lost 2% at the moment of purchase, before the stock has done anything. Round trip, you need a 4% move just to break even.

And it gets worse. If your order is larger than the quantity available at the best price, the rest of it fills at the next price, and the next. This is called slippage, and it is invisible unless you look for it. Traders spend hours choosing a stock and 2 seconds choosing an order type, which is the wrong way round.

How it works

Every exchange runs an order book. Your broker app shows it — it is usually called Market Depth, Depth or Level 2.

It looks like this. The left side is people wanting to buy, the right side people wanting to sell.

Buy qtyBidAskSell qty
400248.50248.60250
1,200248.45248.75900
800248.40248.901,500

The best bid is 248.50 and the best ask is 248.60. The spread is 10 paise. If you place a market order to buy 250 shares, you pay 248.60. If you place one for 1,000 shares, 250 fill at 248.60, 900 at 248.75 — and your average price is worse than the number you saw on the screen.

The exchange matches on price-time priority. Better prices go first. Among orders at the same price, the one that arrived earlier goes first. That is the whole rule, and everything else in market structure is built on it.

The 2 order types that matter.

Market orderLimit order
You controlNothing about the priceThe price exactly
You are guaranteedIt will fillNothing
It takes liquidity from the bookYesNo — it adds to the book
Safe in an illiquid stockNoYes

A market order says "I will pay whatever it takes." In a deep, busy stock, that costs you almost nothing. In a thin one, it is a blank cheque, and the market will cash it.

After the match. The exchange hands the trade to a clearing corporation, which stands between the 2 sides so neither has to trust the other. Your broker holds the relationship; the depository holds the record. The exchange only matched.

What it tells you, and what it does not

The order book tells you what people are willing to do right now, at these prices, in these quantities. That is genuinely useful and it is free.

It does not tell you what will happen next. Large orders sitting in the book can be cancelled in a millisecond and frequently are. Reading intent into visible orders is a trap — some of them are placed precisely so that you will read intent into them.

And the book you see is not the whole book. Exchanges support hidden and iceberg orders that show only a fraction of their size. In the United States, much of the volume never reaches a public order book at all.

The decision rule

Check the depth before you check your conviction.

  1. If the spread is more than about 0.5% of the price, use limit orders only.

Never a market order.

  1. If your intended order is larger than the quantity showing in the top 3

levels, it is too large for this stock today. Split it or skip it.

  1. Never place a market order in the first minute of trading or in the last

minute. The book is thinnest exactly when everybody is trading.

The third one is the cheapest habit in this entire wiki. It costs nothing and it saves a fraction of a percent on every trade you ever make.

Try this now

Two minutes, and you will see a cost you have been paying without knowing.

  1. Open your app. Pick a large company — one in the NIFTY 50 or the S&P 500. Open its Market Depth or Level 2 view.
  2. Note the best bid and the best ask. Subtract. Divide that gap by the price and multiply by 100. That is your spread in percent.
  3. Now do exactly the same for the smallest company you own or watch.
  4. Then, on that small company, add up the total quantity showing across the top 5 sell levels. Compare it to the size of a trade you would actually place.

What you should see. The large company's spread will be a tiny fraction of 1%. The small company's may be 20 or 50 times wider. That difference is a real cost, paid twice — once going in and once coming out.

And on the small company, there is a good chance the entire visible depth is smaller than a single order you have placed before. That is what slippage looks like before it happens to you.

Three real cases

1. The Flash Crash, 6 May 2010 (United States)what happens when the book empties Major US indices fell around 9% and recovered within minutes. During the worst of it, some shares traded at a cent and others at absurdly high prices. The official SEC and CFTC report described how liquidity withdrew and market orders kept executing against whatever was left in the book. The lesson is not that markets are fragile. It is that a market order has no floor — it fills at whatever price exists, and sometimes no sensible price exists.

2. The NSE outage, 24 February 2021 (India)the exit is not guaranteed India's largest exchange halted trading for several hours because of a connectivity failure. Positions could not be closed. Traders with open derivatives sat through it unable to act. The market later reopened and the session was extended. Nothing about anybody's analysis mattered that afternoon. Being right is worth nothing during the hours you cannot transact.

3. Freak trades in Indian index optionsthin books in liquid-looking places Indian markets have repeatedly seen sudden, momentary price spikes in options contracts, where a large market order hit a nearly empty book and executed at a price far away from fair value. These are called freak trades. They happen in instruments most people assume are deeply liquid, because liquidity is concentrated in a few strikes and vanishes in the others.

The question that resolves it

A novice looks at a stock and asks: what is the price?

An expert asks: at what size?

There is no single price. There is a price for 100 shares and a worse price for 10,000. Every professional knows this and almost no retail platform shows it to you by default.

What would make this wrong

If the spread were not a real cost, then trading a thin stock and a liquid one would cost the same. Anybody who has bought and immediately sold a small-cap knows it does not.

The limits are worth stating.

For a long-term investor buying once and holding 5 years, a 1% spread is a rounding error. This article matters in proportion to how often you trade. If you trade twice a year, read it once and move on. If you trade twice a week, it may be the largest single leak in your account.

And limit orders are not free either. The cost of a limit order is the trade you did not get. A stock that runs away from your limit while you wait has cost you more than the spread ever would. The right choice depends on whether you are more afraid of a bad price or of missing the move.

In India

Two exchanges matter: the NSE and the BSE. Nearly all equity volume is on a visible, central order book at one of them, with price-time priority.

Trading in the cash market runs from 9:15 to 15:30, with a pre-open session before it. Clearing is handled by the exchanges' clearing corporations, and settlement is now on a T+1 cycle — shares and money settle 1 working day after the trade. India was the second market after China to move to T+1, and the first to roll it out across its entire listed universe, completed in January 2023.

Indian cash equities have no designated market makers. There is nobody obliged to quote a two-sided price in an ordinary stock. If nobody wants to buy your small-cap this morning, the book is simply empty, and this is why Indian small-cap spreads can be so brutal.

Individual stocks also have price bands that stop them moving beyond a set percentage in a day. A stock at its band has not finished moving — it has run out of permission, and the order book behind the band is one-sided.

In the United States

There are more than a dozen exchanges and a much larger number of off-exchange venues. Regulation NMS stops trading venues from executing at a price worse than the best displayed quote elsewhere — the National Best Bid and Offer — subject to a list of exceptions. Your own protection comes from a separate obligation: your broker's duty of best execution.

Two structural facts change how the book behaves.

  • Payment for order flow. Many retail brokers do not send your order to an exchange at all. They sell it to a wholesaler who fills it internally, often at a slightly better price than the public quote. You get a good fill; your order never appears in the public book.
  • Dark pools. A large share of US volume executes on venues that do not display quotes before the trade.

The practical effect is that the displayed order book in the US shows a smaller fraction of the real liquidity than it does in India. Designated market makers also exist for listed shares and for ETFs, which is why US spreads are narrow even in medium-sized companies.

Where they differ, and what that tells you

In India, what you see in the depth window is close to the whole story. In the United States, it is a fraction of it.

That changes how much to trust the screen. An Indian investor looking at a thin book in a small-cap is seeing the real situation, and should take it seriously — that is all the liquidity there is. An American investor seeing a thin book in a mid-cap may still get filled easily, because most of the liquidity is not displayed.

The habit that works in both places is the same, and it is the one from the decision rule: size your order against the visible depth, and use a limit order when the spread is wide. In India that habit protects you from a real hole. In the United States it protects you from the days when the hidden liquidity is not there either — which, as 6 May 2010 showed, do happen.

Carry this

  • There is no single price. There is a price at a size.
  • Spread over 0.5%? Limit orders only.
  • Order bigger than the top 3 levels of depth? Too big for this stock today.
  • Never a market order in the first or last minute of the session.

Knowledge check

Q. You want to buy 5,000 shares of a small company. The depth window shows:

AskQuantity
95.00300
96.20500
98.75400
102.001,000

You place a market order for all 5,000 shares. What is the most likely outcome?

Explanation. A market order takes whatever the book offers, one level at a time. You would clear 300 shares at 95.00, then 500 at 96.20, and keep climbing — and the visible book here holds only 2,200 shares in total, so the remaining 2,800 fill at whatever appears above 102.

Two things follow. Your average cost is nowhere near the price you saw. And you have just moved the price up by yourself, which means the "gain" you see on the screen afterwards is your own order, not the market's opinion. When you try to sell, the buy side of that book will be just as thin.

The second option is the reasonable-sounding wrong answer. Exchanges do not reject a market order for lack of quantity — they fill what they can and leave the rest, which is precisely the problem.