A resting order to trade a fixed quantity at a specified price or better; it waits in the book. A market order executes immediately at the best available prices, consuming liquidity.
Define depth at a price level.
The total resting order quantity qi available at that price.
Define cumulative depth Qk.
Qk=∑i=1kqi — total volume from the best level through level k.
Formula for the spread and mid price?
s=a1−b1; m=(a1+b1)/2.
How do you find how many ask levels a market buy of size V consumes?
The smallest k with Qk−1<V≤Qk.
Write the VWAP (average) execution price for buying V.
pˉ(V)=V∑i=1k−1qiai+(V−Qk−1)ak.
Define slippage / price impact of a trade.
pˉ(V)−m: the extra average cost above the mid caused by walking the finite-depth book.
Why can a tight-spread stock be expensive to trade in size?
If depth is thin, a large order walks into far worse levels, so slippage dwarfs the small spread.
What is order-book imbalance and what does it hint at?
I=Qbid+QaskQbid−Qask; positive I (more bids) suggests short-term upward price pressure.
When walking the book, why weight the last level by V−Qk−1?
Because the final level is only partially filled — only the remaining shares after exhausting earlier levels come from it.
Recall Feynman: explain to a 12-year-old
Imagine a candy shop where people line up notes saying "I'll SELL you candy for ₹10" or "I'll BUY your candy for ₹9". The sell notes are stacked cheapest-first, the buy notes highest-first. Depth is how many candies each note is good for. If you want to buy 100 candies but the cheapest note only covers 20, you have to grab the next note (a bit pricier), then the next… so buying a lot pushes the price up as you go. A shop with big fat notes (deep book) barely changes price; a shop with tiny notes (thin book) jumps a lot. That's the whole idea!
Socho ek shop mein do lines lagi hain — ek taraf log likh ke rakhte hain "main ₹9 mein KHAREEDunga" (ye hai bid side), aur doosri taraf "main ₹10 mein BECHunga" (ye hai ask side). In sab resting orders ka collection hi limit order book hai. Har price pe kitni quantity padi hai — usko bolte hain depth. Top ki best bid aur best ask ke beech ka gap = spread, aur unka average = mid price.
Ab asli baat: jab tum market buy maarte ho, tum sabse sasti ask se bharna shuru karte ho (price-time priority). Agar tumhara order chhota hai, ek hi level se ban jaata hai — sirf aadha spread ki cost. Lekin agar order bada hai aur upar wala level patla (thin depth) hai, to tumhe agle, mehenge levels tak "walk" karna padta hai. Isse tumhara average fill price (VWAP) mid se upar chala jaata hai — ye extra cost hi slippage / price impact hai. Formula: pˉ(V)=V∑qiai+(V−Qk−1)ak.
Kyun important hai? Kyunki bahut log sochte hain "spread chhota hai to trade sasta hai" — galat! Agar depth kam hai to same order mein bahut zyada slippage lag sakta hai (dekho Example 2 vs Example 3 — same 700 shares, par thin book mein double impact). Isliye bade traders order ko chote tukdon mein todte hain (VWAP/TWAP algos) taaki book "walk" na ho.
Ek aur cheez — imbalance: agar bid side pe depth zyada hai ask se, to short-term mein price upar jaane ka pressure hota hai (I=Qbid+QaskQbid−Qask). To depth sirf cost nahi, direction ka bhi hint deta hai. Yaad rakho: "Spread is the door, depth is the room."