Appearance

Personalize your experience

Mode
Accent Color
Direction

Market Foundations & Exchange Microstructure

0%
Lesson 1/12/Market Foundations/Market Structure/Exchange & Order Book14 min

The Limit Order Book (LOB) & Price-Time Priority

Market Foundations

How exchanges queue passive limit orders by price and timestamp, and how aggressive orders consume resting liquidity.

Key Topics & Tags
limit order bookprice-time priorityfifomakertakermarket depth

Core Architecture & Intuition

Every modern electronic exchange—including NSE, BSE, CME, and NASDAQ—operates a Central Limit Order Book (CLOB). Rather than relying on human floor brokers, the matching engine maintains two sorted queues: the Bid book (buyers sorted highest price first) and the Ask book (sellers sorted lowest price first).

Price never moves simply because 'more people want to buy'; it moves only when aggressive market orders consume 100% of the passive limit orders resting at a given price rung.

Hover over key terms below for instant definitions: Passive Liquidity (Maker), Aggressive Flow (Taker), and Price-Time Priority (FIFO). For the complete mathematical derivation and edge-case analysis, open .

SPREAD: 0.50 ptsCUM QTYBID (BUYERS)ASK (SELLERS)CUM QTY22,450.001,45022,449.503,20022,449.005,85022,448.508,90022,448.0014,20022,450.501,12022,451.002,98022,451.506,40022,452.009,75022,452.5015,600Price-Time Priority (FIFO): Passive Limit Orders Rest on Book · Aggressive Market Orders Cross the Spread
Central Limit Order Book (CLOB) showing cumulative bid/ask depth and top-of-book spread.
★
Pro tip:Never increase the quantity of a resting limit order near the front of the queue—submit a separate second order instead so your original order keeps its early timestamp.

Interactive Concept Breakdown

  • Passive Liquidity (Maker) — Provides market depth and earns queue timestamp priority without crossing the spread.
  • Aggressive Flow (Taker) — Demands immediate execution certainty at the cost of paying the bid-ask spread and sweep slippage.
  • Price-Time Priority (FIFO) — Modifying order price or increasing quantity resets your timestamp to the back of the queue.

Step-by-Step Execution Protocol: Exchange & Order Book

  1. 1
    Gateway Pre-Trade Risk Validation
    The exchange gateway checks tick size, fat-finger execution bands, and broker margin limits in microseconds.
  2. 2
    Crossability Evaluation
    If a Buy order's limit price is >= Best Ask, it is flagged as marketable and enters the matching loop.
  3. 3
    Multi-Rung Sweep Execution
    The engine fills against the oldest resting sell order at Best Ask, sweeping upward until quantity is filled.
  4. 4
    Resting Unfilled Remainder
    Any remaining quantity on a standard DAY Limit order rests on the book, establishing a new Best Bid.

Parameters, Rules & Reference Matrix

Parameter / RuleTypeDefaultDescription
bestBid / bestAsk*price—Highest resting buy price and lowest resting sell price (L1 quote).
bidAskSpreadpoints0.05 - 1.00bestAsk - bestBid; immediate round-trip friction cost.
orderBookImbalanceratio [-1, 1]—(bidQty - askQty) / (bidQty + askQty) across top 5 rungs.

Implementation & Quantitative Model

lob-imbalance.ts
export function calcBookImbalance(bids: { price: number; qty: number }[], asks: { price: number; qty: number }[], depth = 5) {  const bidVol = bids.slice(0, depth).reduce((s, r) => s + r.qty, 0);  const askVol = asks.slice(0, depth).reduce((s, r) => s + r.qty, 0);  const mid = ((bids[0]?.price ?? 0) + (asks[0]?.price ?? 0)) / 2;  return { mid, imbalance: (bidVol - askVol) / Math.max(1, bidVol + askVol) };}

Desk Verification Checklist

Confirm before deploying live capital

  • Inspect top-5 order book depth before firing orders larger than 5 lots.
  • Use Marketable Limit orders instead of bare Market orders.
  • Avoid modifying resting order quantities upward when queue priority matters.

Cross-reference standard risk definitions such as drawdown, slippage, and when auditing your logs.

Full Trade School curriculum →