What is slippage in trading bots? (causes, cost and how to cut it)
Slippage is the gap between the price your bot expected and the price it actually got — and it's the silent killer of strategies that looked great in a backtest. A signal says buy at $100; by the time your market order fills, you paid $100.15. That 0.15% sounds tiny, but on a bot that trades hundreds of times it can erase the entire edge. This guide explains where slippage comes from, why it punishes fast strategies hardest, how to model it honestly in a backtest, and how to reduce it.
What slippage is
Slippage is the difference between the expected execution price and the actual filled price. It can be negative (you got a worse price) or, occasionally, positive (better). For a bot it matters because it's a real, recurring cost on top of fees — and unlike fees, it's variable and easy to forget when you're admiring a backtest that assumed perfect fills.
Where slippage comes from
- Thin liquidity — if your order is larger than the size available at the best price, it eats into worse levels.
- Volatility & latency — price moves in the milliseconds between your bot deciding and the order arriving.
- Wide spreads — illiquid altcoins and off-hours markets have big bid-ask gaps you cross.
Market vs limit orders
A market order guarantees a fill but not a price — it accepts whatever slippage the book imposes. A limit order guarantees a price but not a fill — it may never execute if price runs away. Bots that need certainty of execution (stop-outs, momentum entries) lean market; bots that can be patient (mean reversion, market making) lean limit and can even earn the spread instead of paying it.
Modelling slippage honestly in a backtest
A backtest that fills every order at the exact signal price is lying to you, and the lie is largest for high-frequency strategies. The fix is to subtract a slippage estimate from every fill — a fixed number of basis points, or better, a model scaled by your order size relative to recent volume. A strategy that's profitable at 0 bps and dead at 10 bps was never real. This is exactly why honest backtesting insists on modelling costs.
python · slippage.pydef apply_slippage(price, side, bps=5):
slip = price * bps/10000 # 5 bps = 0.05%
return price + slip if side == 'buy' else price - slip
fill = apply_slippage(signal_price, 'buy', bps=8) # pay up to buy
How to reduce slippage
- Use limit orders where the strategy can tolerate occasional misses.
- Trade liquid markets — major pairs and large-cap stocks, not thin altcoins.
- Split large orders so you don't walk the whole book at once.
- Avoid the worst hours — illiquid sessions have wider spreads.
- Don't over-trade — fewer, higher-conviction trades pay less total slippage.
The bottom line
Slippage is why scalping and HFT-style retail strategies usually fail: their tiny edge per trade can't survive the cost of crossing the spread hundreds of times. Slower strategies pay it far less. Always model slippage in the backtester (it includes a fee/slippage input), confirm the strategy still works after costs, and prove it in paper trading where real fills reveal the true number.
Frequently asked questions
What is slippage in trading bots?
Slippage is the difference between the price a bot expected and the price it actually filled at. A buy signalled at $100 might fill at $100.15 because the market moved or the order was larger than the best available price. It is a real, recurring cost on top of fees.
What causes slippage?
Slippage comes from thin liquidity (an order larger than the size at the best price walks into worse levels), volatility and latency (price moves between decision and fill), and wide bid-ask spreads in illiquid markets or off-hours sessions.
How do market and limit orders affect slippage?
A market order guarantees a fill but accepts whatever slippage the order book imposes; a limit order guarantees a price but may never fill if price runs away. Patient strategies use limit orders to avoid or even earn the spread, while strategies needing certain execution use market orders.
How do you model slippage in a backtest?
Subtract a slippage estimate from every fill — a fixed number of basis points, or a model scaled by order size relative to recent volume. A backtest that fills at the exact signal price overstates returns, especially for high-frequency strategies, so always test whether the edge survives realistic costs.