Backtest Data Leakage: Use Only Information Available at the Time

A backtest can have correct arithmetic and still use future information. Ask a simple question: could this value actually have been known at the decision time?


English · 한국어

A backtest can have correct arithmetic and still use future information. Ask a simple question: could this value actually have been known at the decision time?

A 10 a.m. decision cannot use 11 a.m. information. Leave out information that arrived after the decision.
Concept illustration: A backtest can only use information that was available at the decision time.

Using a 1 p.m. close at 12:30

The final high, low, and close of a noon-to-1 p.m. bar are not known at 12:30. Assigning the final values throughout that hour lets an earlier decision see the future.

Store observation time separately from first availability time. Check whether API timestamps mark bar open or close. Publication delays require more than a join on observation timestamps.

When is the close available? 12:00 · Candle opens · Final high, low and close are unknown.; 12:30 · Still in progress · Using the 13:00 final close leaks the future.; 13:00+ · Closed and received · Use the final value only once it is available.
Illustrative example: Record data time and availability time separately.

Four frequent failures

A pivot requires later bars for confirmation; backdating its signal to the pivot bar leaks information. Completed higher-timeframe values are likewise available only after that bar finishes.

Fitting normalization or selecting features on the full dataset exposes evaluation data. Fit transformations on training data, then apply them forward.

Using today’s surviving symbols throughout history can omit delisted instruments. Reconstruct the eligible universe by date or state the limitation.

Defining a strong move as one followed by a rally embeds the outcome in the event. Keep detection conditions separate from later measurements.

Record the relevant clocks

FieldMeaning
Source timeOriginal observation timestamp and timezone
Available timeFirst confirmed or published timestamp
Event confirmationTime when all detection conditions were knowable
Outcome startBeginning of observation after confirmation
VersionData, code, parameters, and exclusion rules

If you repeatedly inspected evaluation results while adjusting rules, that sample is no longer untouched. Label the process exploratory and evaluate on a separate later period.

Replay in chronological order

Check whether each signal can be recreated using only information available then. Log missing, revised, and excluded observations, and verify reproducibility from the same inputs. Eliminating known leakage is necessary; it is not evidence of profitability.

Continue with common foundations

Python data workflow · Pine Script guide · Research 001 · Research 002

Research methods and reporting standards

For education and research. Numerical examples are teaching assumptions unless explicitly identified otherwise. Historical results do not guarantee future performance.

ABOUT THIS ARTICLE

This article is for education and research, not advice tailored to your finances. Historical findings do not guarantee future returns.

Methodology · Disclosure · Corrections

TRADE EVIDENCE에서 더 알아보기

지금 구독하여 계속 읽고 전체 아카이브에 액세스하세요.

계속 읽기