How a Stock Exchange Really Works
Inside the exchange: the order book, how orders are matched, what the clearing corporation and the depository each do, and what none of them promise.
- Phase
- 1 of 5
- Market Foundations
- Reading time
- 20 min
- 12 chapters
- Level
- Beginner
- No experience needed
You tap Buy and, a moment later, the app says Done. What happened in between?
Your order joined a list of waiting orders and was matched by a fixed rule. It was then completed through a clearing corporation and a depository.
Each of those is a separate body with one job. This lesson opens that box with a small example.
By the end you can say what each part does, and what none of them promise.
An exchange does not set prices. It simply provides a fair place for buyers and sellers to discover them.
Before you start
Words you will meet
- Exchange
- A regulated market where buy and sell orders for listed shares meet and are matched by fixed rules.
- Order book
- The live list of waiting buy and sell orders for one share, sorted by price.
- Bid and ask
- The bid is the highest waiting buy price. The ask is the lowest waiting sell price.
- Spread
- The best ask minus the best bid.
- Limit order
- An order to buy or sell at your price or better, or not at all.
- Clearing corporation
- The body that records who owes what after a trade and stands between buyer and seller.
- Depository
- NSDL or CDSL, which keeps the electronic record of who owns which shares.
- T+1
- Settlement on the next trading day after the trade day, which is T.
What an Exchange Does, and What It Does Not
One place, one set of rules
An exchange is a regulated place where buy and sell orders for listed shares meet. A listed share is simply a share of a company that is available for public trading. The exchange matches the orders by fixed rules, and it keeps a public record of the prices and the trades. That is the whole of its job, and it is worth holding on to this plain picture before we add any detail.
Think of the open ring of a vegetable mandi. The mandi operator provides the ring, the rules of the market and a record of the day's rates. The operator does not buy the vegetables, and does not decide the rate either. Buyers and sellers do that between themselves. An exchange stands in the same relation to shares: it provides the place and the rules, and the price comes from the people who trade.
The picture stops working in two ways, and it is honest to say so. First, an exchange is a company too, and SEBI, the market regulator, oversees it. Second, a mandi rate is shouted across the ring and bargained over, while an exchange matches written orders strictly by rule. There is no haggling, no favour and no friend who gets a better rate because he knows the operator.
Sabzi Wala Foods Ltd is an imaginary company used only to explain. Every price, quantity and time in this lesson is illustrative and not real. We will say that it is listed on both NSE and BSE. Each exchange keeps its own order book for the company, which is its own list of waiting buy and sell orders, so the two lists are separate.
Because the lists are separate, the best prices on the two exchanges can differ a little at one moment. Neither exchange is wrong. Each book simply holds different waiting orders. It also helps to remember what an exchange does not do. It is not your broker, it does not hold your shares, and it cannot tell you whether a price is fair or whether a company is sound.
The Order Book: Bids, Asks and the Spread
The live list of waiting orders
An order is your instruction to buy or sell a certain number of shares. The order book is the live list of all such orders for one share that are still waiting to be matched, sorted by price. Every share has its own book, and a new order either joins the list or meets an order already waiting. Understanding this one list explains most of how prices move on the screen.
Think of two notice boards in a mandi, one for buyers and one for sellers, with the best offer on top of each. A buyer writes the rate he will pay, and a seller writes the rate he will accept. The picture differs from the market in one way. On an exchange the boards update live, and the matching of orders happens by itself, without anybody walking across the ring.
The highest waiting buy price is called the best bid, and the lowest waiting sell price is called the best ask. The gap between them is the spread. In our imaginary book we label the sellers S1 to S4 and the buyers B1 to B4, with the best price first on each side. The table below shows the book at 10:00:30, when the previous close was ₹200.00.
Here the best bid is ₹199.95 and the best ask is ₹200.00. The spread is 200.00 − 199.95, which is ₹0.05. Written as a share of the price, it is 0.05 ÷ 200.00, or 0.025%. The spread is the small gap that sits between buyers and sellers, and it is the first thing to look at when you open a quote.
The waiting orders total 200 shares on the bid side and 150 shares on the ask side. Notice that nothing trades while the best bid stays below the best ask, because no buyer and seller agree yet. A trade happens only when a new order meets the best price on the other side. Apps usually show only a few levels of the book, not all of it.
S1
Side
Ask
Price
₹200.00
Shares
10
Order sent
10:00:08
S2
Side
Ask
Price
₹200.05
Shares
20
Order sent
10:00:06
S3
Side
Ask
Price
₹200.10
Shares
40
Order sent
10:00:03
S4
Side
Ask
Price
₹200.20
Shares
80
Order sent
10:00:00
B1
Side
Bid
Price
₹199.95
Shares
30
Order sent
10:00:02
B2
Side
Bid
Price
₹199.95
Shares
20
Order sent
10:00:05
B3
Side
Bid
Price
₹199.90
Shares
100
Order sent
10:00:01
B4
Side
Bid
Price
₹199.85
Shares
50
Order sent
10:00:07
Imaginary company. Book at 10:00:30, previous close ₹200.00. Best price first on each side.
| Order | Side | Price | Shares | Order sent |
|---|---|---|---|---|
| S1 | Ask | ₹200.00 | 10 | 10:00:08 |
| S2 | Ask | ₹200.05 | 20 | 10:00:06 |
| S3 | Ask | ₹200.10 | 40 | 10:00:03 |
| S4 | Ask | ₹200.20 | 80 | 10:00:00 |
| B1 | Bid | ₹199.95 | 30 | 10:00:02 |
| B2 | Bid | ₹199.95 | 20 | 10:00:05 |
| B3 | Bid | ₹199.90 | 100 | 10:00:01 |
| B4 | Bid | ₹199.85 | 50 | 10:00:07 |
How Orders Are Matched: Price First, Then Time
Who gets the shares first
When a new order arrives, the exchange fills the best price first. Among orders waiting at the same price, the one that arrived earlier goes first. This rule is called price-time priority. It is the single rule that decides who gets the shares, and it looks only at the price and the arrival time of an order, never at who sent it.
Think of a ration shop where the customer who pays the better rate is served first. Among customers who pay the same rate, whoever came first is served first. Nobody can push ahead by being important or by being a known face. The rule is the same for everyone in the line, and that is exactly what makes an exchange fair to a small buyer.
The picture stops in two places. A better price is a real extra payment offered by one side to the other, so it is not just politeness. Also, the exchange uses the arrival time that it records, so a slow internet connection can put your order later than you intended. Arriving first on your own screen does not always mean arriving first at the exchange.
Take the buy orders B1, B2 and B3 from the book. B1 wants 30 shares at ₹199.95 and was sent at 10:00:02. B2 wants 20 shares at ₹199.95 and was sent at 10:00:05. B3 wants 100 shares at ₹199.90 and was sent at 10:00:01. B3 was sent first of the three, but at a lower price.
Now a seller sells 40 shares at ₹199.95. B3 waits because its price is lower, even though its time is earliest. B1 and B2 share the best price, so B1 goes first and is filled fully with 30 shares, worth 30 × 199.95 = ₹5,998.50. B2 gets the remaining 10 shares, worth ₹1,999.50, and keeps waiting for the other 10. The total is ₹7,998.00, which is 40 × 199.95.
This is why a limit order, an order at your own chosen price, may not fill even when the price touches your level. Whether it fills depends on how many shares are ahead of you at that price. Small orders and large orders follow the same rule, so the first order sent does not always fill first.
Order Types Seen From Inside the Book
What each order does to the book
There are three basic kinds of order, and each one behaves differently once it reaches the book. A market order trades now at the best prices waiting, whatever they are. A limit order trades at your price or better, or it does not trade at all. A stop-loss order stays out of the book completely until its trigger price is touched.
Think of buying at a mandi. Paying the first seller's rate right now is a market order. Saying, "I will pay at most this much," and then waiting is a limit order. Telling a friend, "sell my stock if the rate falls to X," is a stop-loss, because it does nothing until that rate arrives. The mandi seller can bargain, but the exchange only matches fixed orders.
Take the imaginary book again. A market buy for 50 shares fills 10 shares at ₹200.00, then 20 at ₹200.05 and then 20 at ₹200.10, because it walks up through the waiting sellers. The total is 2,000.00 + 4,001.00 + 4,002.00, which is ₹10,003.00. The average price is ₹200.06, so the quick trade cost ₹3.00 more than 50 shares at ₹200.00.
A limit buy for 50 shares at ₹200.05 behaves differently. It fills 10 shares at ₹200.00 and 20 shares at ₹200.05, for ₹6,001.00 in all. The other 20 shares cannot be filled without paying more than ₹200.05, so they wait in the book as the new best bid. This order never pays more than the limit you set, but a fill is not certain.
A stop-loss comes in two forms. An ordinary stop-loss, once triggered, becomes a limit order, so you get a planned exit price but not a guaranteed fill. A stop-loss market order, once triggered, becomes a market order, so you get a trade but lose control of the price. Availability of the second form varies, so check what your app offers.
Consider Asha's 10 shares with a stop-loss sell, trigger ₹190.00 and limit ₹189.50. Nothing sits in the book until ₹190.00 is touched. If the price then falls fast past ₹189.50 and no buyer is waiting at ₹189.50 or higher, the order stays unfilled. A stop-loss waits for its trigger; it is not a guarantee.
From Order to Demat: Three Records
Who keeps which fact
After you tap Buy, three separate bodies each keep one record of your trade. The exchange keeps the trade itself. The clearing corporation keeps the record of who owes what. The depository keeps the record of who owns what. Each record answers a different question, and no single body holds all three answers.
Think of buying a flat. The registrar records the sale, the bank records the payment, and the society records the new owner. Three registers sit in three offices, and each office knows only its own part of the story. A share trade works in a similar way, with the important difference that here the three bodies are linked electronically and finish in about a day.
The earlier lesson, What Is the Stock Market, named these hops one by one. Here we look only at the three records that they leave behind. None of these bodies judges whether your purchase was wise. Each one only writes down a fact about the trade, and then passes the work to the next body in the chain.
Take Asha's trade with Ravi, which is 10 shares at ₹200.00, so ₹2,000 in all. On Monday, which is T, the trade day, the exchange and the clearing corporation write their records. On Tuesday, which is T+1, the depository writes its own. Charges are ignored here to keep the sums simple.
So the exchange record says that 10 shares traded at ₹200.00. The clearing record says that Asha owes ₹2,000 and Ravi owes 10 shares. The depository record says that 10 shares sit in Asha's demat account on T+1. Your broker does not hold your shares; a depository does. Keep this in mind whenever an app shows a trade as done, because the depository record is the one that says who owns the shares.
1. Your broker
Your broker is the first stop. It checks your order and then sends it on to the exchange. It does not match orders itself, and it does not decide the price. If the broker stops an order before it reaches the exchange, the order is shown as rejected. Think of the broker as the runner who carries your slip into the ring and nothing more.
2. The exchange
The exchange takes the order and matches it against a waiting order on the other side, by price first and then time. Once matched, it records a trade. In our example the record reads 10 shares at ₹200.00. Until a match is found, your order is shown as pending, because it is simply waiting in the exchange's book for a counterparty.
3. The clearing corporation
The clearing corporation takes the exchange's trade and records who owes what. Here it records that Asha owes ₹2,000 and that Ravi owes 10 shares. It then stands in the middle of the two until settlement is complete. A trade can be done while the shares have not yet reached the demat account, because this step is still running.
4. The depository
On settlement day the depository finishes the job. It credits 10 shares to Asha's demat account, and Ravi receives the ₹2,000. The depository does not match trades or clear them. It only keeps the electronic record of who owns which shares, and it sends holding statements that show what your account contains.
The Opening Auction: How the Day's First Price Is Found
Why the day may not start at yesterday's close
Before continuous trading starts at 9:15 am, the exchange runs a short auction, called a call auction. It collects orders and finds one opening price for the share. Nothing trades until that price is found. Only then does ordinary trading begin, with orders matching one by one as they arrive.
Think of a sealed-bid auction for the first rate of the day. Everyone writes down a price and a quantity. One rate is then chosen so that the largest quantity of goods changes hands. The picture differs in one way. A mandi rate is shouted, but here the exchange works out the single price by rule, as a fixed daily routine for listed shares.
Sabzi Wala closed at ₹200.00 yesterday. The table shows how many shares buyers would take at each price or higher, and how many sellers would give at each price or lower. At each price the number that can trade is the smaller of the two. At ₹201, buyers of 700 shares meet sellers of 600, so 600 shares can trade.
That is the most of any price in the table, since the other prices allow 200, 400, 400 and 200. So ₹201 becomes the opening price. Every matched order trades at ₹201, even a buyer who offered ₹203 or a seller who asked ₹199. The 100 extra buy shares stay unmatched.
The open is therefore 201 − 200, which is ₹1 above yesterday's close, or 0.5%. This is why a day may not start at yesterday's close. The opening price is not the close, and it is not the last trade before the bell. A market order sent before the open trades at whatever price the auction finds, and you cannot know that price for sure in advance.
₹203
Buy up to here
200
Sell up to here
1,000
Can trade
200
₹202
Buy up to here
400
Sell up to here
800
Can trade
400
₹201
Buy up to here
700
Sell up to here
600
Can trade
600 (most)
₹200
Buy up to here
900
Sell up to here
400
Can trade
400
₹199
Buy up to here
1,000
Sell up to here
200
Can trade
200
Imaginary company. Buy column: buyers at this price or higher. Sell column: sellers at this price or lower. Can trade: the smaller of the two.
| Price | Buy up to here | Sell up to here | Can trade |
|---|---|---|---|
| ₹203 | 200 | 1,000 | 200 |
| ₹202 | 400 | 800 | 400 |
| ₹201 | 700 | 600 | 600 (most) |
| ₹200 | 900 | 400 | 400 |
| ₹199 | 1,000 | 200 | 200 |
Depth and Spread: Why Some Shares Are Easier to Trade
The cost of a wide spread
Liquidity means how easily a share can be bought or sold at about the same price. It is high when the spread is small and orders wait at several prices close together. Depth means how many shares wait at each price. A deep book can absorb a large order without the price jumping around.
Think of a busy vegetable stall and a lane shop that sells one rare item. At the busy stall you can buy and sell at about the same rate, all day long. At the lane shop the buying rate and the selling rate are far apart. A busy share can still fall fast, so easy to trade does not mean safe.
Test Sabzi Wala with a round trip. Buy 10 shares at ₹200.00, which costs ₹2,000, and then sell at once at ₹199.95. The cost of the round trip is 10 × (200.00 − 199.95), which is ₹0.50. As a share of the money used, that is 0.50 ÷ 2,000, or 0.025%.
Tiny Trading Co is also an imaginary company. Its best bid is ₹8.55 and its best ask is ₹9.00, with only 100 shares waiting on each side. The spread is 9.00 − 8.55, which is ₹0.45. Compared with the ask, that is 0.45 ÷ 9.00, or 5%, which is far wider than the 0.025% of Sabzi Wala.
Buying 100 shares at ₹9.00 costs ₹900. Selling them at once at ₹8.55 brings back ₹855, so the difference is ₹45, or 5% of ₹900. The spread is lost once on a round trip, not twice. A wide spread is therefore a cost paid before the price moves at all.
Finally, remember that a price on the screen does not mean you can sell at that price. If your order is larger than the shares waiting near the best price, it walks through the book, as in the section on order types. To read a quote on your own screen, see the lesson on reading a stock quote.
Clearing and Settlement: Who Owes What, Then the Handover
Netting, then T+1
Clearing works out who owes what after the trades are done. Settlement then moves the shares and the money. Settlement happens on the next trading day, which is called T+1, where T is the trade day. A matched trade is therefore not yet a completed one, and the shares are not yet yours.
Think of the members of a housing society who owe each other small amounts. Instead of everyone paying everyone, the treasurer nets the dues, so only the difference is paid. This is called netting. The picture stops at one point. A clearing corporation also keeps margin, which is money set aside to cover losses, and a treasurer does not.
Suppose the clients of Broker Z buy 1,000 Sabzi Wala shares today and also sell 600. Together that is 1,000 + 600, or 1,600 shares of trading. The net to settle is only 1,000 − 600, which is 400 shares. This is simplified, because real netting is done per member per share, but the idea is the same.
Money nets in the same way, so only the net amount moves, and fewer transfers are needed. SEBI requires that shares are credited straight to your own demat account. A trade on Monday settles on Tuesday, and a trade on Friday settles on Monday. If Friday is a trading holiday, a Thursday trade also settles on Monday.
Your broker can tell you when the shares show in your app. Until then, treat the trade as matched but not yet settled, even though the screen may already say that the order is done. The settlement calendar, holidays and market timings come in the lesson on settlement and market timings, where the days are worked out one by one.
What the Clearing Corporation Does for You
One trade becomes two
After a trade, the clearing corporation steps into the middle. From then on you deal with it, and not with the other side of your trade. The other side is simply whoever took the opposite position, and you never need to know that person or worry about their promise. Your risk of a missed handover moves to a body built to carry it.
Think of a trusted cashier at a mandi. The cashier takes the buyer's money and the seller's goods, and hands each their share. The cashier is not owned by either party. The picture stops here in an important way. The clearing corporation is a separate regulated body with its own rules, and its fund has a limited size. NSE trades use NSE Clearing, and BSE trades use Indian Clearing Corporation.
Asha buys 10 shares at ₹200.00 from Ravi. Before the step, Asha and Ravi are the two sides of one trade. After it, there are two trades: Asha with the clearing corporation, and the clearing corporation with Ravi. Each trade is for ₹2,000. This replacement of one trade by two is called novation.
Three things back this arrangement. Members, which are the brokers who trade through it, post margin up front. Losses on open trades are collected each day. A settlement fund is there to absorb a default, up to its limited size. These steps make completion of the trade much more dependable.
It is equally important to see what this does not cover. The clearing corporation completes the trade. It does not protect the price you paid, which stays at market risk, and it does not protect you if the company does badly. A broker misusing your money is a different matter and has a different protection. If a seller fails, the steps in the next section apply.
If a Seller Fails to Deliver
The auction, in outline
Sometimes a seller does not deliver the shares on settlement day. In that case the clearing corporation holds an auction to buy the shares. The auction is on T+1, and the shares settle on T+2, which is one day later than normal. The buyer is not charged for the failure.
Think of a caterer who fails to supply 10 plates at a wedding. The organiser buys the plates elsewhere at the going rate and sends the bill to the caterer. The picture differs in one respect. Here the formula and the auction day are fixed by rule, and nothing is negotiated between the parties.
Ravi sold 10 shares at ₹200.00, which is ₹2,000, but the shares are missing on settlement day. Say the auction fills at ₹230.00. Buying the 10 shares then costs 10 × 230, which is ₹2,300. Ravi bears 2,300 − 2,000, which is ₹300, plus charges. Asha, the buyer, is not charged.
If no seller is found even in the auction, the trade is closed out in cash. The rate used is the higher of two numbers. One is the highest price from the trade day to the auction day. The other is 20% above the auction-day close. The higher of the two is used. This fixed formula is meant to leave no room for argument about the rate.
Say the highest price was ₹210.00 and the auction-day close was ₹195.00. Then 195 × 1.20 is ₹234.00, and the higher number is ₹234.00. Ravi bears 10 × (234 − 200), which is ₹340, plus charges. Asha is again not charged. A failed delivery does not simply cancel the trade, and only shares free to deliver in the demat account can be delivered. Full detail comes in a later lesson.
How the Exchange Keeps Trading Orderly
Price bands and watch lists, in outline
The exchange limits how far a price can move in a single day, and it watches for unusual trading. The limit is a daily price band for each share. Touching the band is called a circuit. A band slows a move, but it does not decide where the price should be.
Think of speed breakers and traffic police on a busy road. They slow the vehicles and watch for rash driving, but they give nobody a destination. The picture differs in one way. Speed breakers cover the whole road, but the exchange sets bands share by share, and publishes each share's current band.
Take Sabzi Wala's previous close of ₹200.00. Say a 10% band applies, which is only an illustration. Then 200 × 0.10 is ₹20, so the permitted range for the day is ₹180.00 to ₹220.00. A 5% band would give a narrower range of ₹190.00 to ₹210.00. No order outside the band is accepted that day.
There is also a market-wide halt. A move of 10%, 15% or 20% in Nifty 50 or Sensex, whichever is breached first, halts trading across the whole market. Nifty 50 and Sensex are the two main index numbers that summarise the market. This is different from a share's own band, because it applies to every share together.
Exchanges also keep surveillance lists, under SEBI's framework, for shares with unusual price or volume patterns. These lists are a form of watching and are not predictions. A circuit also does not mean a share is safe or doomed. A lower circuit can mean that no buyer exists at the permitted price, since a band slows a move but does not create buyers.
Band lists, pause durations and surveillance stages come in the lesson on circuit limits and surveillance. For now it is enough to remember the idea. A band is a daily limit on one share's move, a halt is a pause for the whole market, and a surveillance list is a way of watching. None of them is advice about what to buy or sell.
Putting It Together: Who Does What
One job each
Each body in the chain does one job, and none of them judges whether your trade was a good idea. The exchange matches orders by one rule and does not set the price or hold shares. The broker takes your order and sends it, and does not match orders or set the price. Keeping the jobs separate is what makes the system dependable.
Think of the mandi again. The ring is the exchange, the cashier is the clearing corporation, and the record book is the depository. The inspector is SEBI, and the runner who carries your order in is the broker. The picture stops here. In the market these are separate regulated firms, with separate duties and separate fees.
The clearing corporation completes the trade and stands in the middle, but it does not protect the price you paid. The depository records who owns the shares, and it does not match or clear trades. SEBI makes and enforces the rules for all of them, but it does not place trades or promise gains.
Follow Asha's trade through the whole chain. The broker sends her order, and the exchange matches 10 shares at ₹200.00. The clearing corporation records ₹2,000 and 10 shares. The depository credits the 10 shares on Tuesday, which is T+1. Depositories send holding statements and alerts, which show what is in your demat account.
The chain protects the process, which is the trade completing correctly. It does not protect the price, and the price is still a risk. Your shares sit in your demat account and not with your broker. Markets carry the risk of loss of capital. This lesson is education, not investment advice.
Common questions
Does the stock exchange decide the price of a share?
No. The exchange matches orders by a fixed rule. The price is where a buyer and a seller agree. NSE and BSE each keep their own order book, so the same share can show slightly different best prices at one moment.
What are the bid, the ask and the spread?
The bid is the highest price a buyer is waiting to pay, and the ask is the lowest price a seller is waiting to accept. The spread is the gap between them. For an imaginary share, a bid of ₹199.95 and an ask of ₹200.00 give a spread of ₹0.05, or 0.025%.
Why did my limit order not fill even though the price touched it?
Orders at the same price are filled in the order they arrived. If others were ahead of you and used up the shares available at that price, the price may move away before your turn. For example, if 30 shares wait ahead of you at ₹199.95 and a seller sells 40, those 30 fill first and your order of 20 gets only 10.
Why can the first price of the day differ from yesterday's close?
News can arrive overnight. Before continuous trading starts at 9:15 am, the exchange collects orders in an auction and picks the one price at which the most shares can trade. That price becomes the opening price.
What is the difference between a clearing corporation and a depository?
The clearing corporation keeps track of who owes what after a trade and stands in the middle of it. The depository (NSDL or CDSL) keeps the record of who owns which shares in electronic form. One handles the completion of the trade, the other handles ownership.
What happens if the person who sold me shares does not deliver?
The clearing corporation holds an auction to buy the shares, and you receive them one day later than normal. The seller who failed bears the extra cost. If no seller is found, the trade is closed out in cash by a fixed formula.
What is an upper or lower circuit?
A circuit is the limit of the daily price band set for a share. Once the price touches it, no order beyond it is accepted that day. It slows the move but does not bring buyers, so a lower circuit can mean nobody is buying at the permitted price.
Is the exchange the same as my broker, and does it hold my shares?
No. Your broker takes your order and sends it to the exchange. The exchange matches orders and publishes prices; it does not hold your shares. Your shares are held in your demat account at a depository.
Check what you learned
5 questions. Pick an answer to see why.
