Skip to content
Reading settings

Reading settings

Export or import reading records
Keep your reading records

Completion, bookmarks, reading positions and preferences belong to this browser origin. They do not automatically move to another address.

Export at the original address, then choose that backup at the new address. Everything stays in your browser; nothing is uploaded or deleted at the original address.

The file is checked before you confirm. Completion and bookmarks are combined; existing positions, last-read state and preferences win conflicts.

G41 · Guided learning

Look-Ahead Bias and Data Leakage

Trace when information became usable, repair three isolated leakage errors, and test whether changing future inputs alters past decisions.

Not marked completeMaterials ↓

The return calculation is correct, and the final cash reconciles. Then Lin notices that a March decision used a financial figure first published in May. The arithmetic describes an account that could not have made that decision with the information available at the time.

Look-ahead bias lets later information influence an earlier decision or evaluation. Data leakage also includes information crossing a boundary where it was not available for the intended task—for example, test observations influencing parameters supposedly learned only from training data.1 Correct arithmetic does not remove these errors.

What you will be able to do

  • Follow an observation through publication, acquisition, processing, a signal, and execution.
  • Repair three isolated errors involving fills, historical data versions, and preprocessing.
  • Save cutoff and future-perturbation checks that test specific information paths without claiming to certify an entire strategy.

Trace availability, not just the date on a row

For one signal, write the sequence: economic event → public release → acquisition → verification and processing → signal → execution. Different data can occupy different positions on that timeline.

A quarter-end date describes the period a report covers. It is not necessarily the report's publication date. A release can be public before your system obtains it, and obtained before its processing finishes. A current value can be accurate today while still being the wrong historical version for an earlier decision.

This chapter uses an isolated C4 error laboratory. The first example reuses the synthetic five-day account from G39; the financial-report and feature examples are separate exercises. They do not change the C4 ledger or supply results for the real C2 SPY study. You need no programming software to follow the numbers.

Error 1: fill an order before its signal is usable

Recall the complete C4 rules: start with $1,000 and zero shares; after each close, target 20 shares only if the close is strictly greater than 11, otherwise zero. Submit the difference from current shares, fill at the next listed open, and charge $1 per filled order. Reject an unaffordable purchase entirely without a fee. There are no missing intermediate prices, corporate actions, external flows, taxes, slippage, cash interest, borrowing, or settlement delays.

DayOpenClose
D11010
D21012
D31311
D41010
D51010

The D2 close creates the buy order. At D3's open, 20 × $13 plus the fee leaves $739 in cash. The D3 close of exactly 11 creates the sell order; the D4 open sale at 10, less its fee, leaves $938. The return is −6.2%.

The faulty version buys at D2's close of 12 and sells at D3's close of 11. Its final cash is $1,000 − $240 − $1 + $220 − $1 = $978, or −2.2%. The $40 advantage comes from violating the specified decision-to-fill sequence.

That does not mean every trade at a closing price is invalid. A separately specified strategy might submit a known order through a verified closing-auction process. It would need evidence about what was known, order submission, and execution. Those are not the rules of this exercise.

Repair the timing and retain both ledgers. A worse return after the repair can mean the check succeeded. Do not restore the error because its chart was more attractive. Conversely, an unchanged result does not prove there is no timing error: it may simply have had no effect on this particular path.

Error 2: move a report backward to its period end

Use this independent report example. All timestamps below share the same explicitly specified time zone; no conversion is hidden.

ItemTime or value
Reporting period endsMarch 31
Initially reported revenue100
Public releaseMay 13, 08:00
Your system obtains the releaseMay 13, 08:05
Verification and processing finishMay 13, 08:10
Later correctionJune 10: revenue changes to 90

The March 31 date does not make 100 usable in March. Under these supplied processing assumptions, it becomes eligible for a signal only after May 13 at 08:10. Whether an order can then trade depends on the applicable calendar and execution rules; publication does not itself create a fill.

For a decision on May 15, the then-available version is 100, not the 90 first supplied by the June correction. Using the corrected value throughout the earlier history can leak later information even though it is now the better statement of revenue.

Keep the original filing, release and acquisition times, processing completion, and later revisions. Public filing systems such as EDGAR help locate reports: /A appended to the form type identifies an amendment.2 Inspect the actual contents and availability times individually. An amendment indicator does not guarantee that every data vendor preserves every historical version. If you cannot verify the version available at the decision time, limit the claim accordingly.

Historical membership needs the same care. A company announced in July to join an index in August cannot automatically be placed in the January research universe because it is a member today. Distinguish announcement, effective membership, and what your system actually knew.

A blanket instruction to delay every row by one day does not solve a report released weeks after period-end. Nor does a date field prove that its contents were available then. Trace the value's route into the signal.

Error 3: learn a past transformation from future data

Consider a synthetic feature with training values 2 and 4, followed by test values 100 and 102. The transformation subtracts the mean. The correct training mean is 3, so the training observation 4 becomes 1.

If you first calculate the mean of all four values, you obtain 52. The same past observation becomes −48. A toy signal that acts only when the transformed value is strictly positive now changes its decision because of later test data. The dates may be neatly split in the final tables, but information crossed the boundary during preprocessing.

Split first, learn preprocessing parameters from the permitted training data, and apply those fixed parameters to the test observations.1 The same issue can arise in feature selection. A transformation's apparent simplicity does not exempt it from an availability check. This numerical threshold illustrates a mechanism; it is not evidence of a useful trading signal.

Missing values can create another route. Suppose M5's feature is missing and someone fills it using a figure first published in M6 because that is the nearest observation. That future value was unavailable at M5. Forward-filling from an earlier known observation is not necessarily the same time-travel error, but its age, economic meaning, and permitted missing-data policy still need review. “Filled” does not mean “valid.”

Check whether labels have matured

Inputs available at D5 might be used to predict an outcome measured through D10. At a training cutoff of D5's close, that label is not yet known. Starting a test at D6 does not make the training label available earlier. Exclude labels that have not matured by the training cutoff or change the boundary and explain it. Overlapping outcome windows can also share information across nominally separate samples.

A chronological splitting utility can help implement ordered folds and gaps, but it does not know your report-release delays, label horizon, exchange calendar, or relationships among assets. The documented TimeSeriesSplit gap counts observations; its assumptions also include equally spaced samples for comparable fold durations.3 Choosing a default gap does not certify financial data as leakage-free.

A researcher can cross the boundary too

Suppose the implementation uses only timely inputs, but the researcher examines a weak test result, changes the window, and repeats until a satisfactory version appears. The test has influenced selection. Calling that same history “holdout” again does not restore its earlier status.

Record which outcomes were seen, what changed afterward, and all attempted versions. Redesign the evaluation to distinguish data already used for development from an actually new observation period. Chronological code checks and an honest research history address different paths of information use; neither replaces the other.

Test a cutoff, then perturb the future

Work on copies and preserve the raw materials. At a specified cutoff, save the inputs, versions, learned parameters, and past outputs that the system should have been able to produce. Then remove or deliberately change information unavailable until later and compare those saved objects.

For the report example, changing the June 10 correction to some other value should not change the May 15 input of 100. For the preprocessing example, changing the test values 100 and 102 should not change the training mean of 3 or the past transformed value of 1. If either changes, follow the dependency to find where the later input entered.

For execution, connect each signal's usable time to the order and fill. A replay containing only the history available up to each cutoff should reproduce the corresponding past outputs. This check concerns past inputs, parameters, signals, and decisions. Final equity can legitimately change when you change later market prices; that alone is not evidence of leakage.

Passing these tests supports only the paths and modifications actually checked. It does not prove the absence of every future-information dependency. A fixed one-day delay might still miss slow report availability while unnecessarily moving a price that was immediately usable. State what each test was designed to reveal.

Explain the error, then transfer the repair

Explanation. The faulty C4 version ends at $978 instead of $938. Why is that not a better strategy result?

Reference answers · reveal

Answer. It buys and sells at closes that generate the decisions, although the rules require next-open fills. The additional $40 comes from an inadmissible sequence. A performance comparison requires permissible account histories first.

Application. Someone proposes fixing all leakage by shifting every input one day. What evidence is still missing?

Answer. You still need the public, acquisition, processing, and version times for the actual value, plus the decision and execution rules. A one-day shift from March 31 cannot make a May release known in early April. It also does not address test-informed preprocessing or labels that mature later.

Transfer. Training feature values are 10 and 14; later test values are 30 and 34. A system subtracts the full-sample mean and transforms the training observation 14. Calculate the wrong result, then the permitted training-only result and a future-perturbation check.

Answer. The full-sample mean is 22, producing −8. The training mean is 12, producing 2. Learn the mean only after establishing the split. Change the later 30 and 34 to other values: the training mean of 12 and past transformed output of 2 should remain unchanged. If they do not, investigate the parameter's source. This repair does not test real historical members, trades, or returns, or show that the feature predicts anything useful.

Save an information-flow audit

Choose one signal and record the observation range, public and acquisition times, version, processing completion, and permitted use for its prices, reports, membership records, corporate actions, preprocessing parameters, and labels. Connect those records to its orders and fills. Mark evidence and gaps rather than assuming every timestamp is verified.

Retain at least three reproducible errors, their before-and-after inputs and outputs, the reason for each change, and its scope. Repair one error at a time before checking them together. If costs, samples, or rules also change, list those changes separately; do not attribute the entire return difference to one leakage repair.

Another reader should be able to reproduce the first time-boundary violation and the future-perturbation test. Unverified historical versions or membership records must restrict the conclusion. An AI's “passed” message is not independent evidence.

The question is how information traveled, not whether a row looks old. Link the version, processing, and label to the decision, then link the decision to execution. A repair can reduce reported performance; unchanged performance can conceal an untested error. Preserve the test record and the unchecked paths before judging how much evidence remains.

References

  1. scikit-learn: Common Pitfalls—Data Leakage. Training/test separation, fitting preprocessing, and feature selection. Numerical inputs above are independently synthetic.
  2. Investor.gov: Using EDGAR to Research Investments. Public filings and amendments; not a guarantee of complete historical vendor versions.
  3. scikit-learn: TimeSeriesSplit. Chronological folds and gaps illustrate method boundaries. No programming or software installation is required for these exercises.

Editorial status

AI-assisted draft synchronized to the accepted second-round Chinese source. C4 paths and supplementary examples are synthetic, and no real study is certified free of leakage. See the author review. A separate AI reviewer has completed an independent full-text review. Human financial review and target-reader testing have not been performed and are not scheduled for this edition.

Article Materials

C4 · 6 files
Browse all materials →
Sources, Version, and Review

Last updated: 2026-10-30

SHA256 5d127444b412197950dda451fed4b07eaefcd2af756f7b208ce3ead3482d738b

Cases: C4

This page uses the corresponding manuscript. AI review, bilingual checks, and unresolved issues are tracked separately. Human financial review and target-reader testing have not been conducted.

Report an issue with this article
Handbook contents

Records stay in this browser.

On this page
Search handbook