How a Stock Exchange Matches Your Order

A stock exchange matches your order by stamping it with a number and a time, then checking at once whether an opposite order is already waiting at a price that works. If one is, a trade happens immediately. If not, your order joins a queue ranked by price first and arrival time second.

What happens in the first moment your order arrives?

When your order reaches the exchange, the system attaches a unique number and a timestamp (a record of the exact time of arrival). It then immediately checks whether the order can be matched against orders already there.

The timestamp matters because, as shown below, arrival time decides who goes first when prices are equal.

How does the order book rank waiting orders?

An order that finds no counterpart is parked in the order book, the exchange’s internal list of unmatched buy and sell orders. The book ranks orders by price first, then by arrival time.

Among buy orders, the one bidding the highest price is first in line. Among sell orders, the one asking the lowest price is first in line. This puts the most attractive offers to the other side at the front.

If two orders carry the same price, the one that entered the system earlier is matched first.

Who sets the price when two orders meet?

An order already sitting in the book is called passive. An incoming order that meets it is called active. The trade is struck at the resting order’s price.

So if a seller is waiting at ₹200 and you send a buy order willing to pay up to ₹205, you do not pay ₹205. The trade happens at ₹200, the resting price.

Why can one instruction produce several trades?

A large order can be filled piece by piece against several counter-orders, so one instruction may produce several separate trades. Each piece is struck at the price of the resting order it meets.

Here is a hypothetical example, with all figures invented for illustration. Suppose these sell orders are resting in the book:

  • 100 shares at ₹200, entered first
  • 50 shares at ₹200, entered second
  • 200 shares at ₹201

You then enter a market order (explained in the next section) to buy 300 shares. It trades 100 shares at ₹200 and 50 shares at ₹200, because the earlier order goes first at the same price. It then trades 150 shares at ₹201.

That is three trades from one instruction. The cost is ₹20,000 + ₹10,000 + ₹30,150 = ₹60,150, an average of ₹200.50 per share, which is higher than the ₹200 you saw at the front of the queue. The catch is that a large order can end up above the best displayed price. The remaining 50 shares at ₹201 stay in the book.

How do different order types change the matching?

A market order asks for the best price available when it is entered. It prioritises getting done over the price, as the example above shows.

A limit order sets a maximum buy price or a minimum sell price and waits until the market reaches it. In the example, a limit order to buy 300 shares with a ₹200 ceiling would trade only against the 150 shares at ₹200. It would not buy at ₹201. The catch is that if the market never reaches your limit, the order may not be filled at all.

A buy stop-loss order stays out of the market until the last traded price reaches or exceeds its trigger price, which is the level you set to activate it. It then enters the book as a limit order, with the trigger time as its timestamp. That means it joins the queue at the moment of triggering, not when you first placed it. Being a limit order, it can still go unfilled if the market moves past its limit.

Two further instructions control how long an order lives. An immediate-or-cancel order fills whatever it can at once and cancels the rest. A day order lapses at the end of the trading day if unmatched.

What is different before the market opens?

Before the regular session, a pre-open call auction gathers orders instead of matching them one by one. It computes a single equilibrium price, the price at which eligible orders are executed together.

Within this auction, market orders are matched before limit orders are considered. Orders do not trade at their own prices as they arrive. They trade together at the one computed price.

What happens to orders smaller than a regular lot?

Orders smaller than the regular lot, the standard trading quantity, are handled in a separate odd-lot market. There, buy and sell price and quantity must match exactly. SEBI directives currently route orders of up to 500 shares there.

The exact-match requirement is a real constraint. A buy for 37 shares at ₹200 needs a seller of exactly 37 shares at exactly ₹200, so an order in this market can wait unfilled even when similar orders exist nearby.

Sources and last check

Facts in this article were checked against the sources below on 1 November 2026. Rules and figures can change; check the primary source before acting.

This article is general information, not investment advice. MyFinanceBandhu is not a SEBI-registered investment adviser.


Comments

4 responses to “How a Stock Exchange Matches Your Order”

  1. […] How a Stock Exchange Matches Your Order […]

  2. […] How a Stock Exchange Matches Your Order […]

  3. […] How a Stock Exchange Matches Your Order […]

Leave a Reply