1.4 The continuous limit order book
Motivation
Between auctions, NSE and BSE run a continuous limit order book (CLOB). Every intraday price you see is a trade in this book. Understanding it explains why "the price" is two prices, why a market order costs more than the spread when it is large, and why speed matters.
1.4.1Limit orders and priority#
Definitions
- A limit order specifies side, quantity and a limit price. A buy limit at will trade at or lower; a sell limit at at or higher. If it cannot trade immediately, it rests in the book.
- The bid is the highest resting buy price; the ask (offer) the lowest resting sell price. The spread is ask − bid. The mid is their average. The depth at a level is the total resting quantity at that price.
- A marketable order is one that can trade on arrival: a buy limit at or above the ask, or a sell limit at or below the bid. A market order has no price limit and trades against the best available prices until filled.
- The resting order is the maker (it supplied liquidity); the arriving order is the taker.
- Price-time priority. Better prices trade first. At the same price, the earlier order trades first. The trade price is the maker's price.
- Tick size: the minimum price increment. NSE sets it by price band through circulars; check the current circular before hard-coding it.
1.4.2Retail order types#
Order types available to an Indian retail trader (exchange features and common broker features; the details vary by broker):
- Limit and market orders, as above.
- Stop-loss limit (SL): a buy (sell) order that becomes a limit order only when the last traded price rises to (falls to) a trigger price. It protects a position without being visible as a marketable order beforehand, but it may not fill if price gaps through the limit.
- Stop-loss market (SL-M): becomes a market order on trigger. It always fills if there is liquidity, but at an unknown price. Several brokers do not offer SL-M in F&O.
- Validity: Day (expires at the end of the session) or IOC (immediate-or-cancel: fill what can be filled on arrival, cancel the rest).
- Disclosed quantity / iceberg: only part of the order is displayed; the rest is hidden and refreshes after the visible part fills.
- After-market order (AMO): entered outside market hours and sent at the next open.
- GTT (good-till-triggered): a broker-side, not exchange-side, conditional order that sits on the broker's server, sometimes for up to a year, and sends a limit order to the exchange when the trigger is hit. The exchange never sees it until then, so it has no queue position.
- Product codes (broker margin categories, not exchange order types): CNC (cash and carry, delivery), MIS (intraday; auto-squared off before the close), NRML (carry-forward F&O). Since the peak-margin rules (2021), brokers cannot give intraday leverage beyond exchange margins.
- Algorithmic orders: SEBI's retail algo framework (circular SEBI/HO/MIRSD/MIRSD-PoD/P/CIR/2025/0000013 of 4 Feb 2025; applicable to all brokers from 1 Apr 2026 under circular SEBI/HO/MIRSD/MIRSD-PoD/P/CIR/2025/132 of 30 Sep 2025, para 8) makes the broker the principal and any algo provider its agent. Every algo order sent through a broker API carries an exchange-issued identifier; open APIs are not allowed (access only through a vendor-client-specific API key and a static IP whitelisted by the broker, OAuth and two-factor authentication); an algo you write yourself must be registered with the exchange through your broker once it exceeds the orders-per-second threshold set by the exchanges; and third-party providers must be empanelled with the exchanges. Any live automation you build after this course must comply (M14 · 14.10.2 lists the operational controls).
1.4.3Slippage and market impact#
Market order cost: the walk up the book Suppose asks rest at prices with depths . A market buy of fills at , then continues. Let be the mid before the order. The volume-weighted fill price and slippage in basis points are
Because each additional share fills at a price no better than the previous one, is a convex, piecewise-linear function of , and is non-decreasing. This is the simplest version of market impact studied in M05 · 5.5.
Worked example
A ₹100 stock has bids at 99.95, 99.90, … and asks at 100.05, 100.10, 100.15, …, 100 shares at each level. A market buy of 250 fills 100 at 100.05, 100 at 100.10 and 50 at 100.15. Average price ₹100.09, slippage 9 bp against the mid of ₹100. A market sell of 100 fills at 99.95: 5 bp. These are the fixtures in the tests of Exercise m01_execution (in the app: Exercises → m01_execution).
Code Exercise m01_order_book (in the app: Exercises → m01_order_book) asks you to build the book with price-time priority, cancels and market orders. Its tests include a 3,000-order fuzz test that checks two invariants: quantity is conserved (submitted = filled + cancelled + resting) and the book is never crossed. Exercise m01_execution builds market_impact and round_trip_bps on top of it.
Practitioner notes
- Queue position is an asset. A limit order placed early at the bid trades before later orders at the same price. Market makers invest heavily to be first in the queue. A retail limit order joins the back.
- Displayed depth is not reliable depth. Orders are cancelled and replaced many times a second. SEBI's FY26 F&O study reports that about 99% of prop-trader and FPI gross profit came from algorithmic entities (1.11), which is a measure of who controls the queue.
- A limit order is an option given away for free. A resting buy at ₹99.95 lets anyone sell to you at that price if news arrives. You are paid the spread for the risk of being picked off. M05 · 5.3 models this (Glosten–Milgrom).