6.3.1Market Microstructure

Understand order book dynamics

2,499 words11 min readdifficulty · medium6 backlinks

WHAT is an order book?

WHY the sort order? The exchange must always trade at the best available price for the incoming party. So the algorithm only ever needs to look at the top of each queue — the highest bid and lowest ask. Sorting guarantees an O(1)O(1) peek at the "best" prices.


HOW an order interacts with the book

There are two fundamental order types, and understanding the difference is 80% of microstructure:

HOW a market buy of size QQ executes (the "walk"): It eats the ask side from the top down. It fills against the best ask first; if that level's depth is exhausted, it moves to the next-higher ask price, and so on until QQ is filled. This is why big orders get worse average prices — they "walk up the book." Note: each partial match only removes the matched quantity from a resting order; any leftover depth at that level stays.

Figure — Understand order book dynamics

WHY the spread and imbalance matter

WHY OBI predicts direction: If VbVaV_b \gg V_a, many buyers are waiting but few sellers — the next small market sell can't push price far, while a market buy easily lifts the ask. Price tends to drift up. OBI +1\to +1 = buy pressure; OBI 1\to -1 = sell pressure. It's a weak, fleeting predictor because the book changes every millisecond.


Worked Examples


Common Mistakes (Steel-man + fix)


Active Recall

Recall Quick self-test (hide answers, forecast first)
  • Q: What sits at the very top of the bid side? → Highest buy price (best bid).
  • Q: Formula for spread and mid? → s=abs=a-b, m=(a+b)/2m=(a+b)/2.
  • Q: Maker vs taker in one word each? → Maker adds liquidity; taker removes it.
  • Q: Why do large market orders get worse average prices? → They walk up/down consuming multiple levels.
  • Q: When two orders match, what exactly is removed? → Only the matched quantity; any remainder stays resting.
  • Q: OBI =+0.8= +0.8 implies? → Strong buy-side pressure, short-term upward drift likely.
Recall Feynman: explain to a 12-year-old

Imagine a lemonade stand market. On one wall, kids write "I'll pay 2foracup!"(thehighestpriceatthetop).Ontheotherwall,sellerswrite"Illsellfor2 for a cup!" (the highest price at the top). On the other wall, sellers write "I'll sell for 2.10!" (lowest at top). The little gap between them ($0.10) is the spread. If a thirsty kid says "give me lemonade NOW at any price," they grab the cheapest seller first, then the next cheapest, paying a bit more each cup — that's walking the book. If a seller had 10 cups but the kid only wanted 4, only 4 cups are sold and the other 6 stay written on the wall. If way more buyers are waiting than sellers, prices will probably creep up soon. The book is just everyone's notes about what they'll do, and it keeps changing as kids add or erase their notes.


Connections

  • Bid-Ask Spread — the core cost embedded in the book's top level.
  • Market Makers and Liquidity Provision — who fills the book and why.
  • Slippage and Market Impact — quantifying the "walk."
  • Order Types (Limit, Market, Stop, Iceberg) — the ingredients of the book.
  • High-Frequency Trading — agents exploiting millisecond book dynamics.
  • Price Discovery — how crossing orders set the "true" price.

What is a limit order book?
A continuously-updated, price-ranked record of all resting limit orders, split into a bid side (highest price at top) and an ask side (lowest price at top).
What is the best bid and best ask?
Best bid = highest price a buyer will pay; best ask = lowest price a seller will accept.
Define the spread and mid price.
Spread s=abs=a-b; mid m=(a+b)/2m=(a+b)/2, where aa=best ask, bb=best bid.
Maker vs taker?
Maker posts a resting limit order (adds liquidity); taker sends a marketable/market order that removes liquidity by crossing the spread.
Why do large market orders suffer slippage?
They exhaust the best level then execute against progressively worse price levels ("walking the book"), raising the average execution price above the best quote.
When two orders match, what quantity is removed from the book?
Only the matched (overlapping) quantity = min of the two sizes; any unfilled remainder of the larger order stays resting.
Formula for average execution price when walking the book?
pˉ=C/Q\bar p = C/Q where C=i=1k1piqi+pkrC=\sum_{i=1}^{k-1}p_iq_i + p_k r, r=Qi=1k1qir=Q-\sum_{i=1}^{k-1}q_i.
Define order-book imbalance and its sign meaning.
OBI=(VbVa)/(Vb+Va)[1,1]\text{OBI}=(V_b-V_a)/(V_b+V_a)\in[-1,1]; positive = buy pressure/upward drift, negative = sell pressure.
Which price do you actually trade at with a market order?
Buyers pay the ask, sellers receive the bid — never the mid.
When does a limit order rest vs execute immediately?
It executes immediately if it crosses (buy price \ge best ask, or sell price \le best bid); otherwise it rests in the book.
Why is the displayed book only an optimistic estimate of cost?
Hidden/iceberg orders exist and other participants cancel/add in reaction, so realized slippage usually exceeds book-implied slippage.

Concept Map

has

has

top is

top is

spread s equals a minus b

spread s equals a minus b

averaged into

averaged into

rests and adds liquidity

makes you a

crosses spread removes liquidity

makes you a

walks up levels

Limit Order Book

Bid Side buy orders

Ask Side sell orders

Best bid b highest

Best ask a lowest

Spread

Mid price m

Limit order

Maker

Market order

Taker

Walk the book worse avg price

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Order book samajhna market microstructure ka dil hai. Socho ek table ke do side hain: ek taraf saare buyers apni highest price likhte hain (bid side, sabse upar sabse zyada price), doosri taraf sellers apni lowest price likhte hain (ask side, sabse upar sabse kam price). In dono ke beech ka gap hi spread hai, aur beech ka point mid price. Jab kisi buyer ki price kisi seller ki price ko chhoo leti hai (cross ho jaati hai), tab trade hota hai — lekin sirf matched (overlapping) quantity hi book se hatti hai. Agar ek order bada hai toh uska bacha hua hissa book me resting reh jaata hai.

Do type ke orders hote hain. Limit order matlab tum price fix karte ho aur agar turant match nahi hua toh woh book me "rest" karta hai — tum maker ban jaate ho (liquidity add karte ho). Market order matlab "abhi kharido/becho jo bhi price ho" — yeh spread cross karke resting orders ko kha jaata hai, tum taker ban jaate ho. Bada market order book ko walk karta hai: pehle best price kha gaya, phir agla thoda mehnga level, phir uske baad — isiliye average price kharaab ho jaati hai, ise slippage kehte hain.

Ek important signal hai order-book imbalance (OBI) = (VbVa)/(Vb+Va)(V_b - V_a)/(V_b + V_a). Agar bid side pe volume bahut zyada hai toh short-term me price upar ja sakti hai, kyunki buyers zyada hain sellers kam. Lekin yaad rakho yeh signal bahut fleeting hai — book har millisecond change hoti hai.

Ek common galti: log sochte hain woh mid price pe trade karenge. Nahi! Market buy me tum ask pay karte ho, market sell me tum bid receive karte ho. Mid sirf ek reference hai. Doosri galti: log sochte hain match hote hi dono orders gayab ho jaate hain — nahi, sirf min(size) trade hoti hai, bacha hua hissa resting rehta hai. Aur jo depth screen pe dikh rahi hai woh bhi poori sachai nahi — hidden/iceberg orders hote hain, isliye asli cost aksar zyada aati hai. Yeh cheezein samajh loge toh trading cost bahut behtar control kar paoge.

Test yourself — Market Microstructure

Connections