Urgent.News

What's breaking now, across thousands of outlets.

Tech

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.

Read the original at dev.to →

More in Tech

Three things I got wrong measuring my own cache

A team that produces regulatory documents kept getting the same kind of question from other teams: does the current rule allow X?

  • Overlooked issue with negation pairs, labeling error not caught by testing
  • Control group too easy, minimal token differences between accept/reject pairs
  • Misinterpreted embedder failure as semantics issue, not surface form understanding

AWS Shared Responsibility Model Who Takes Care of What in the Cloud

Boa parte dos incidentes de segurança na nuvem não acontece porque a AWS falhou — acontece porque alguém assumiu, incorretamente, que a AWS cuidaria de algo que na verdade era responsabilidade do…

  • AWS Shared Responsibility Model clarifies security responsibilities in cloud services.
  • AWS responsible for infrastructure security, customer responsible for data and application security.

My tests could fail. They still could not tell me I was wrong.

A test proves your code does what you meant. It cannot prove that what you meant was correct. I could have written that sentence a year ago. I still shipped on the wrong side of it this week.

  • Test failed to confirm code correctness
  • Bug related to QIF payee and memo fields
  • Writer discovered importance of testing assumptions

More from Tuesday 25 August →