Introduction to Backtesting
Backtesting is a powerful mathematical simulation that allows traders to evaluate the performance of a trading strategy using historical market data. By simulating how a strategy would have performed in the past, traders gain insights into its potential profitability before risking real capital.
While past performance doesn’t guarantee future success, backtesting remains the most reliable method for identifying robust trading strategies. It helps eliminate underperforming approaches, ensuring traders focus only on those with a high probability of success.
With the rise of cryptocurrency trading, backtesting has become essential. Thoroughly testing strategies before deployment increases confidence in their effectiveness in volatile crypto markets.
Backtesting Data Requirements
Accurate backtesting relies on high-quality market data. Below are the three main types of data used in backtesting tools:
Candlestick Data (OHLCV)
- Pros: Easily accessible.
- Cons: Unreliable for precise simulations due to aggregation and lack of granularity.
- Recommendation: Avoid using OHLCV data for backtesting—it leads to inaccurate results.
Tick-by-Tick Trade Data
- Pros: Represents real executed trades.
- Cons: Doesn’t reflect order book depth or liquidity conditions.
- Recommendation: Not ideal for backtesting—still lacks precision.
Order Book Snapshot Data
- Pros: Provides exact market conditions, including bid-ask spread, slippage, and liquidity.
- Cons: Harder to obtain and process.
- Recommendation: The best option for accurate backtesting.
Data Sources
High-quality order book data is essential for reliable backtesting. Exchanges stream this data in real-time but rarely store it long-term. Third-party providers like Kaiko (partnered with Shrimpy) offer historical order book snapshots dating back to 2014.
👉 Access premium crypto data for accurate backtesting
Simulating a Backtest
To calculate strategy performance accurately, backtests must account for:
- Trading fees
- Bid-ask spread
- Slippage
- Trade timing
Example: Buying Crypto with Order Book Data
Using Binance’s ENJ-USDT order book as an example:
- Buy 1,151.749 ENJ at 0.20559424 USDT = 236.97 USDT + 0.24 USDT fee
- Buy 2,559.954 ENJ at 0.20640294 USDT = 528.38 USDT + 0.53 USDT fee
- Continue until the full 1,500 USDT is spent
Total acquired: 7,260.084 ENJ (vs. 7,319.761 ENJ estimated with candlestick data—a 1% discrepancy). Small inaccuracies compound over multiple trades, making precise data crucial.
Performance Results
Calculate strategy performance using:
Performance (%) = [(Final Portfolio Value - Initial Portfolio Value) / Initial Portfolio Value] × 100
Key Metrics:
- Consistency: Similar results across different time periods.
- Robustness: Minimal performance swings with small parameter changes.
Strategies like portfolio rebalancing often show consistent outperformance compared to holding (HODL).
Backtest Red Flags
Watch for these warning signs:
- Unrealistic continuous growth → Possible calculation errors.
- Exponential profit curves → Often indicates flawed simulations.
- High-frequency trading without fee impact → Fees may be ignored.
- Same results on low/high-liquidity pairs → Suggests aggregated data usage.
- Identical performance across exchanges → Likely using incorrect fee structures.
Conclusions
Backtesting is essential for validating trading strategies, but accuracy depends on:
- High-quality order book data
- Proper fee & slippage simulation
- Extensive testing across market conditions
👉 Optimize your trading strategy with reliable backtesting
FAQ Section
Q: Why is candlestick data unreliable for backtesting?
A: It lacks granularity and doesn’t account for liquidity or slippage, leading to inaccurate trade simulations.
Q: How often should I backtest my strategy?
A: Test across multiple historical periods and market conditions to ensure consistency.
Q: What’s the biggest mistake in backtesting?
A: Overfitting—optimizing a strategy too closely to past data, reducing future effectiveness.
Q: Can backtesting guarantee profits?
A: No, but it helps identify statistically favorable strategies.
Q: Where can I get reliable historical order book data?
A: Providers like Kaiko (via Shrimpy APIs) offer the most precise datasets.