Backtesting overfitting: why your backtest lies and how to make it honest
Cross-post. Original: stellarbytecapital.com/blog/backtesting-overfitting A profitable backtest is the easiest thing to produce in all of quant trading, and the most worthless. Give a motivated person historical data and enough parameters, and they'll hand you a strategy that turned $10k into $10M — on paper, on data that already happened. The hard part was never getting a good backtest. It's…
Backtesting overfitting is a common problem in quantitative trading. A profitable backtest on historical data is easy to produce, but it often fails to predict future market behavior. Overfitting occurs when a strategy learns the noise in the historical data instead of a genuine, repeatable pattern. Markets are mostly noise with a small signal, and a model with too many parameters can memorize this noise, maximizing backtest performance but providing no predictive power for the future.
There are several mechanisms that make backtests lie. Multiple testing is a major issue, as trying thousands of variations and keeping the best one almost certainly leads to finding a great-looking strategy by chance. Random noise can create impressive Sharpe ratios, making the strategy seem much better than it actually is. Tuning parameters also burns statistical power, and lookahead bias, where information known at decision time is used before the trade is executed, can vanish once the backtest moves to live trading.
Survivorship bias, which involves only using assets that exist today, deletes companies and tokens that went bankrupt or to zero. Ignoring costs and fills, such as high turnover strategies with zero fees and perfect fills, can also create a false sense of a profitable edge.
To make a backtest honest, several steps should be taken. Out-of-sample and walk-forward testing are essential, never judging a strategy on data used to build it. Develop in-sample, test once out-of-sample, or better yet, perform walk-forward optimization, where a strategy is optimized on a rolling window and tested on the next unseen window, repeating the process.
Keep a locked holdout, which is never touched during research, and reserve recent history that neither you nor your optimizer look at. Prefer a few parameters and robust plateaus, as every degree of freedom increases the opportunity for overfitting. Account for the search performed during optimization by deflating the Sharpe ratio accordingly.
Avoid optimizing on all your data, re-running until you like the holdout, chasing the highest backtest return, using zero-cost, perfect-fill assumptions, and having too many parameters with a single magic setting. Finally, be adversarial toward your own results and assume every great backtest is overfit until it survives unseen data, realistic costs, and an honest accounting of the search performed.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.