Backtrader: Customizing Slippage Models
Your backtest shows a 40% return, but your live account is bleeding capital. Why? Because your backtrader slippage model assumes perfect fills that neve...
Your backtest shows a 40% return, but your live account is bleeding capital. Why? Because your backtrader slippage model assumes perfect fills that never happen in real crypto markets. Most traders run simulations on clean OHLCV data, ignoring the friction of spreads, latency, and order book depth. The result is a strategy that looks profitable on paper but fails the moment it touches a live exchange. In crypto, where volatility spikes can move prices 2% in seconds, a static slippage assumption is often a dangerous lie. This guide explores how to build dynamic execution logic in Backtrader that respects the chaotic nature of crypto tick data. We will move beyond simple percentage adjustments to models that react to market conditions. Slippage is the difference between the expected price of a trade and the price at which the trade is actually executed. In crypto markets, this gap widens significantly during high volatility or low liquidity periods. According to Interactive Brokers, slippage is a fraction of the stock price you must assume as a deviation from the price you are willing to pay.