Backtesting in Python
What a backtest is — and is not
4 min
A backtest simulates how a trading strategy would have performed on historical data. You define entry and exit rules, replay the past candle by candle, and measure the resulting equity curve.
What it gives you
- A way to check whether an idea has any historical edge at all.
- Statistics to compare strategies: total return, drawdown, Sharpe ratio, win rate, number of trades.
- A sense of how the strategy behaves in different market regimes.
What it is NOT
A backtest is not a prediction of the future. It is a hypothesis test on the past. Markets change; an edge that existed for ten years can vanish the moment enough people exploit it.
Every backtest result you will ever see — including the ones in this track — is hypothetical performance. Hypothetical results have well-documented limitations: they are computed with hindsight, they do not involve real money or real emotions, and they often quietly assume fills you would not actually have gotten.
The honest mindset
Treat a backtest as a tool for rejecting bad ideas, not for proving good ones. A strategy that fails a backtest is almost certainly bad. A strategy that passes one might be good — or might be overfit. The next lessons are about telling the difference.
This content is for educational and informational purposes only and is not investment, financial, tax or legal advice. Trading and investing carry risk, including the possible loss of capital. Any performance shown by third-party tools is hypothetical and not a promise of future results. Do your own research and consider professional advice before making any decision.