Skip to content
← Back to all concepts

Concepts / Overfitting

Overfitting

3 min read · Concept

In everyday words

Imagine learning last year's exam answers by heart. You would ace last year's paper and fail this year's.

An example in pounds

Say a rule is tuned until it turns £1,000 into £2,000 on five years of past prices. On five other years, which it was never tuned on, the same rule turns £1,000 into £900. The £2,000 was the tuning, not the rule.

The short version

When a rule fits the past so closely that it has learned the luck, not the pattern.

DrawingA drawing of the idea, not a real result.
Each column is the score of one setting. The tall lone column is luck at one exact setting. A rule that scores about the same at nearby settings is on firmer ground.

What it is

Give a rule enough dials and it can be tuned to fit any stretch of past prices. The trouble is that past prices are part pattern and part luck. A rule tuned too closely learns both. On new prices the luck is different, and the rule does worse. That is overfitting.

There is a quieter version. Nobody tunes one rule too hard. A hundred rules are tried and the highest scorer is kept. The top one of a hundred looks good even if none of them is any use. Picking it is overfitting too.

A worked example

A rule buys when the price is above its average of the last 60 days. On a test it scores 1.0. The score here is the Sharpe ratio: return above cash, set against how bumpy the ride was.

Now every length from 5 days to 250 days is tried. The highest score is 1.5, at 63 days. At 65 days the score is minus 0.2.

A real pattern does not vanish when a setting moves by two days. The 1.5 was luck at one exact setting. A rule that scores about the same at 55, 60 and 65 days is on firmer ground, even with a lower score.

What it does not tell you

  • That a rule which passes every check works. The checks can show a result is fragile. They cannot show it is sound. Only its record on prices it has never seen speaks to that.
  • About two other ways a test flatters itself. One is using facts that were not known on the day. The other is testing only companies that still exist, which leaves out the ones that failed. Quantis tests shares that are listed today, so its tests on shares carry the second one. The result says so.
  • What comes next. A test describes the dates it covered and nothing after them.

This leaves out the five checks used to look for overfitting and what each one measures. The exact version is below.

On a Quantis result

The result has a line called Selection and sensitivity. It is a score out of 100, where higher is worse. It measures how much the result depended on which setting of the rule was picked. It does not show that the rule works on prices it has not seen.

The exact detailFor anyone who wants the detail. Nothing above depends on reading it.

The two forms

Overfitting happens when a strategy's parameters were chosen (explicitly or implicitly) to fit the in-sample data so well that they describe the noise and not the signal. In-sample data is the data the choice was made on. The classic form is too many parameters: a 12-input rule “explains” the past better than a 2-input rule, and usually does worse out of sample because the extra inputs were fitting random fluctuations.

The subtler form is selection bias. Testing 1,000 candidate strategies and reporting the best one's Sharpe overfits the process, even if each candidate looks clean. The standard reference is Bailey, Borwein, López de Prado & Zhu (2014), “Pseudo-Mathematics and Financial Charlatanism”.

The five checks

Each of these looks for a different way a result can be fitted. Quantis runs some of them and not others. Each one ends by saying which.

  • 1. Walk-forward Sharpe degradation. The Sharpe of the settings chosen on the data they were fitted on, set beside the Sharpe on data held back (out of sample). Some drop is normal, because held-back data is harder by construction. A drop of half or more means the parameters were fitted to noise that was not there in the held-back window. Quantis runs this in Prove it. Its walk-forward test re-chooses the settings on the years before each of a few folds and runs them on the fold; it passes when the folds keep at least half of the fitted figure. On the result card itself, time-slice stability compares later slices of the run with the period before each, using the same parameters throughout: nothing is re-fit there, so it is not out-of-sample validation. Quantis also holds back each idea's newest months until the sealed test is opened, and goal search chooses on the first 70% of the history and reports the last 30%.
  • 2. PSR-DSR gap. PSR allows for sampling noise; DSR also adjusts for selection across candidates. A wide gap (50 percentage points or more) means the search among variants drove the headline Sharpe. A narrow gap (under 10 points) means the search added little. Quantis runs this. A result shows both figures.
  • 3. CPCV fraction positive. The fraction of CPCV paths with a positive Sharpe. A pattern that is really there shows up across most slices of history; a fitted one shows up on a few and not on the rest, even when the median Sharpe is positive. Quantis does not run this. Its sub-period panel borrows the way of cutting the history and re-fits nothing: it gives the Sharpe of every pair of ten blocks of one fixed run, which is not cross-validation.
  • 4. Parameter sensitivity. Each parameter is varied by about 20% and the test run again. A result that holds degrades smoothly: the Sharpe drops from 1.0 to 0.7 and stays positive across the neighbourhood. An overfit one collapses: a lookback changed from 60 to 65 days takes the Sharpe from 1.5 to -0.2. A plateau with a lower Sharpe is firmer ground than a single peak. Quantis runs this. It moves the main lookback settings by 10% and by 20% each way and runs the test again at each.
  • 5. IC decay shape. A factor whose IC is positive in sample and then changes sign at the next horizon along is very likely an artefact of the window it was built on. One whose IC does not fade at all as the horizon lengthens is also unusual: a real signal usually fades smoothly. The IC decay panel is held back from the Quantis report until its automatic check exists.

How a result gets overfitted

  • Many configurations tried, the best reported. Even with careful out-of-sample testing, the act of selection inflates the expected best-of-N result. DSR exists to put a number on this.
  • Peeking at the held-back data. A walk-forward is run, the out-of-sample Sharpe is poor, the parameters are changed and it is run again. The second run is no longer out of sample for the new parameters: they were selected on it.
  • Fine-grained tuning. Trying every lookback from 5 to 252 days finds whichever one happened to catch a rare lucky stretch. A coarse grid (20, 60, 120, 252) leaves less room for that.
  • Look-ahead bias. Using the next bar's data, a closing price to trade at that day's open, or company figures before they were published. Each one puts information into the test that was not available at the time.
  • Survivorship bias. Testing on a universe built today (for example “the current S&P 500”) leaves out the companies that dropped out. A test free of it uses the index's membership as it stood on each date. Quantis tests on symbols that are listed today, so its own backtests on shares carry this bias, and the card flags it on those runs.

What to watch in the result card

  • Every diagnostic pointing the same way. Later time slices in line with the earlier period, PSR-DSR gap narrow, few block pairs at or below zero in the sub-period panel, and a small fall in Sharpe across the settings that were run. This is rare. The IC decay panel is held back from the Quantis report until its automatic check exists.
  • Selection and sensitivity checks. Quantis rolls some of these signals into one score out of 100, where higher is worse (under 30 low, 30 to 59 moderate, 60 and over high): sensitivity to settings, the gap between the single-run and the deflated Sharpe ratio, the number of configurations tried, and the stability of the ranking signal where a run has one. The pill has no colour. Its text lists every check with its weight, including the ones left out for this run, which shows what drove the score. The time-slice check is left out because nothing was fitted, and the pill is hidden when fewer than three checks are available. The score measures how much the result depends on which configuration was picked; it does not show the rule works on data it has not seen.

Read next

  • Sharpe vs PSR vs DSR → two checks on how much of a result could be luck.
  • Walk-forward vs CPCV → two ways of testing a rule on prices it was not tuned on.
  • Start here → shares, funds and tests on past prices, from zero.
  • Bailey, Borwein, López de Prado & Zhu (2014). Pseudo-mathematics and financial charlatanism: the effects of backtest overfitting on out-of-sample performance. Notices of the AMS.