Lookahead bias: the one-day shift that invents returns.

The most common backtesting bug is one missing line, and nothing warns you. What it is, the quieter forms, and how to check your own results.

What it is

Lookahead bias is a backtest using information that was not available at the moment of the trade. The most common form is one line of code: a signal computed from today's close, applied to today's return.

You only know today's close once the day is over. Any rule that buys at that close because of that close has bought at a price it could not have traded at. The backtest gets the move for free, and the equity curve looks better than anything you could have done.

The one-day shift

The fix is to shift every signal forward one bar. A signal from Monday's close sets Tuesday's position, which earns Tuesday's return. Every strategy in Finertia ends with that shift, and each one's tests check the position on a given day depends only on prices up to the day before.

signal   = close > close.rolling(50).mean()
position = signal.shift(1)        # trade tomorrow on today's signal
returns  = position * close.pct_change()

Drop the .shift(1) and the code still runs, the chart still draws and nothing warns you. That is why it is so common.

Quieter forms

Stops checked inside the bar

A stop-loss assumed to fill at exactly the stop price, when the price gapped through it overnight. Finertia checks stops at the close, so a gap costs the whole gap.

Volatility measured over the whole period

Sizing a position by a volatility that includes the future. Volatility targeting here uses a trailing window ending the day before.

Parameters chosen on the full history

Tuning on all the data and then reporting the same data. This is lookahead at the level of the whole study, and walk-forward validation exists to prevent it.

Survivorship

Only testing companies that still exist today. Price history is only there for the survivors, so this one no backtest on today's tickers can fully remove.

How to check your own

If a strategy's result changes very little when you add a one-day delay, it was probably fine. If it collapses, the edge was the lookahead. A result much better here than in another tool, on the same idea, is worth that check first.

On real stocks

Every figure on the 39 stock pages comes from the same engine, with each signal acting on the bar after it is known. If another tool shows a much better result for the same rule on the same stock, that gap is worth the one-day-delay check above.

All the stocks

See it on a real strategy.

Finertia runs these checks on any stock you pick. The free plan runs the backtest; Pro adds the validation.