How to Backtest a Cryptocurrency Trading Strategy

·

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)

Tick-by-Tick Trade Data

Order Book Snapshot Data

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:

Example: Buying Crypto with Order Book Data

Using Binance’s ENJ-USDT order book as an example:

  1. Buy 1,151.749 ENJ at 0.20559424 USDT = 236.97 USDT + 0.24 USDT fee
  2. Buy 2,559.954 ENJ at 0.20640294 USDT = 528.38 USDT + 0.53 USDT fee
  3. 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:

Strategies like portfolio rebalancing often show consistent outperformance compared to holding (HODL).

Backtest Red Flags

Watch for these warning signs:

  1. Unrealistic continuous growth → Possible calculation errors.
  2. Exponential profit curves → Often indicates flawed simulations.
  3. High-frequency trading without fee impact → Fees may be ignored.
  4. Same results on low/high-liquidity pairs → Suggests aggregated data usage.
  5. Identical performance across exchanges → Likely using incorrect fee structures.

Conclusions

Backtesting is essential for validating trading strategies, but accuracy depends on:

👉 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.