[Systematic Trading] What is backtesting (回測)? How to avoid overfitting (過度擬合) and historical traps
30-second key takeaways (Key Takeaways)
- Backtesting is the quantitative core method of applying a trading strategy to historical data to assess its past performance and feasibility.
- Overfitting is the biggest killer in backtests: tuning a strategy to perfectly fit historical noise, which often leads to disaster in live trading.
- Out‑of‑sample testing and walk‑forward analysis can substantially improve a strategy’s robustness.
- Position cash management and risk assessment — see the on‑site resources. Kelly risk budget tool。
1. Basic concepts and importance of backtesting (回測)
When entering systematic and quantitative trading, backtesting is the first step to validate an idea. In short, backtesting simulates a strategy over a historical period using historical prices, volumes and financial data via code or professional software to reproduce hypothetical executions.
The core value of backtesting is to quickly eliminate ineffective trading ideas without risking real capital and to evaluate a strategy's max drawdown (MDD), win rate, profit factor and Sharpe ratio. Good backtest results, however, are no guarantee of future live performance.
2. The biggest fatal backtest trap: overfitting
Many beginners fall into traps when backtestingOverfitting (also called curve fitting)...to the abyss. When you repeatedly add parameters in backtest software (for example, fine‑tuning a moving‑average from 20 days to 23, then adding complex conditions like RSI > 58 and MACD histogram > a specific value) until the backtest curve forms a perfect 45‑degree upward line, your strategy is very likely severely overfitted.
The essence of overfitting is treating random noise in historical data as general rules. When such a strategy — tuned countless times — is deployed in future real markets, changes in the environment typically cause it to fail rapidly and incur large losses.
| Backtest characteristics | Sound trading strategy | An overfitted (curve‑fitted) strategy |
|---|---|---|
| Number of parameters | Streamlined (typically 1–2 core parameters) | complex (several to a dozen+ tuning parameters) |
| Logical foundation | Based on macroeconomics or market microstructure | Blindly chasing historically maximized performance |
| Out‑of‑sample performance | stable performance, small backtest gap | Catastrophic live failure — results completely non‑replicable. |
3. How to prevent overfitting: out‑of‑sample testing and walk‑forward
To ensure backtest results have real‑world value, quantitative traders use a scientific validation process:
1. In-sample vs out-of-sample split (In-sample / Out-of-sample):Split historical data into two parts. For example, use 2010–2020 for strategy development and parameter tuning (in‑sample), then test independently on unseen 2021–2025 data (out‑of‑sample). Only strategies that still perform well out‑of‑sample qualify for live deployment.
2. Walk-forward Analysis (步進式向前分析):Dynamic rolling optimization and validation windows simulate the real‑world process of periodically reviewing and adjusting a strategy.
After building a robust quantitative system, precise money management is key to surviving the market. We recommend pairing with the on‑site Kelly risk budget tool,scientifically manage the capital allocation for each trade entry.
Frequently Asked Questions (FAQ)
Advantages and target audience
Backtesting replaces subjective emotion with scientific data, helping traders build objective discipline; it is especially suitable for investors pursuing systematic and algorithmic trading.
Challenges and cautions
History won't repeat exactly but it often rhymes. Backtests cannot predict future black‑swan events or liquidity crises; strict stop‑losses are still required in live trading.
Do you like this article?
Your support is my greatest motivation to keep creating high‑quality investment education.
Buy me a coffee