Backtesting is the practice of running a strategy's rules against historical market data to see how it would have traded in the past. It does not predict the future, but it is the fastest way to filter bad ideas before you risk capital.
What you need
- A clear strategy - when to buy, sell, size positions, and rebalance.
- Historical prices - daily (or finer) data for every symbol you trade.
- Realistic assumptions - fees, slippage, and tradable universes (no peeking at delisted stocks without handling survivorship).
The basic loop
- Define rules (for example, "hold top 3 momentum names each month").
- Walk forward through history bar by bar.
- Apply rules as if you were trading live on each date with only information available then.
- Record positions, cash, and equity over time.
- Summarize performance: return, volatility, Sharpe, max drawdown, hit rate.
Common mistakes
| Mistake | Why it hurts |
|---|---|
| Look-ahead bias | Using future data in today's decision inflates results. |
| Overfitting | Tweaking until one date range looks perfect; fails live. |
| Ignoring costs | Small edges disappear after commissions and slippage. |
| Too little data | One bull market is not a full stress test. |
Backtest vs paper trading
A backtest is historical simulation. Paper trading runs the same logic forward in real time with simulated fills. The best workflow: backtest for research, paper trade for execution bugs and operational confidence, then consider live sizing.
No-code backtesting
Visual builders let you express conditions (indicators, filters, weights) without Python. The discipline is the same: state hypotheses, test out-of-sample periods, and change one variable at a time.
Quantly supports long-history backtests on many tickers, benchmark comparison, and Monte Carlo stress tests. Try the demo to walk through a full loop.
