Sub topic 6
Slippage and Market Depth
Assume you already understand basic order books, bids, asks, and percentages. This chapter focuses on how the available order size changes the price you actually receive.
What slippage measures
Slippage is the difference between the price you expected and the average price at which your order fills. It usually appears when a market order consumes several price levels in an order book.
A market buy takes liquidity from the ask side. A market sell takes liquidity from the bid side. If the quantity is larger than the best available level, the remaining quantity fills at worse prices.
Market depth is the amount available at each price level. A deep book has substantial quantity near the best bid and ask. A thin book can move sharply when a moderate order arrives.
| Order-book feature | What it tells you |
|---|---|
| Best ask | Lowest displayed price for an immediate buy |
| Ask size | Quantity available at that price |
| Deeper ask levels | Prices used after the best ask is exhausted |
| Average fill price | Total cost divided by filled quantity |
The best ask is not necessarily the price for your whole order. It is only the first level your order may reach.
Walking the ask side
Suppose the ask book contains:
- 2 units at 100.00
- 3 units at 100.50
- 5 units at 101.00
A market buy for 4 units consumes 2 units at 100.00 and 2 units at 100.50.
The total cost is:
2 × 100.00 = 200.002 × 100.50 = 201.00- Total:
401.00
The average fill price is 401 / 4 = 100.25. Compared with the best ask of 100.00, the order experienced 25 basis points of price slippage.
asks = [(100.0, 2.0), (100.5, 3.0), (101.0, 5.0)]
def market_buy_avg_price(asks, qty):
remaining, cost = qty, 0.0
for price, size in asks:
take = min(remaining, size)
cost += take * price
remaining -= take
if remaining == 0:
break
if remaining > 0:
raise ValueError("not enough liquidity")
return cost / qty
qty = 4.0
avg = market_buy_avg_price(asks, qty)
best_ask = asks[0][0]
slippage_bps = (avg - best_ask) / best_ask * 10_000
print(avg)
print(round(slippage_bps, 1))For a market sell, use the bid levels instead. The calculation is symmetrical, but the price worsens downward as the order consumes lower bids.
Reducing slippage
You can reduce slippage by:
- Splitting a large order into smaller orders.
- Trading when volume and displayed depth are higher.
- Comparing several venues.
- Using a limit order with a maximum acceptable price.
- Avoiding market orders during sudden price movements.
A limit order controls price but does not guarantee execution. A market order usually prioritizes execution but does not guarantee price. The right choice depends on whether execution certainty or price certainty matters more.
Exercise
The ask book has 1 unit at $50, 4 units at $50.50, and 5 units at $51. What is the average fill price for a market buy of 3 units, and what is the slippage from the best ask in basis points?
Show answer
The cost is $50 + 2 × $50.50 = $151. The average fill price is $50.3333. Slippage is approximately (50.3333 - 50) / 50 × 10,000 = 66.7 basis points.