A model that looks brilliant in backtest is usually guilty until proven innocent. So I built a test that puts every feature on trial.

The result that cleared my pipeline: my alignment flags correlated 0.27 with the past 1-hour move and only 0.10 with the future 1-hour move.

That direction — past > future — is the signature of an honest feature. If it flips, you have leakage.

The intuition

A legitimate market feature describes what has already happened at decision time. It may be predictive, but its information comes from the past.

So:

  • A feature that correlates more with the past than the future = normal.
  • A feature that correlates more with the future than the past = it is reading the future.

That second case is not a "strong signal." It is a bug dressed as alpha.

The test

Define, for each signal timestamp t:

past_1h = spot[t] / spot[t - 60m] - 1 # realised past move future_1h = spot[t + 60m] / spot[t] - 1 # what happened next flag = alignment_flag(t) # feature under audit c_past = corr(flag, past_1h) c_future = corr(flag, future_1h) 

The verdict rule:

if abs(c_future) > abs(c_past) * 1.05: print("LEAK SUSPECT: feature knows more about the future than the past") elif c_past * sign_expected <= 0: print("VALUE SUSPECT: feature points the wrong way") else: print("PASS: information is backward-looking") 

The 1.05 tolerance matters. At 1-minute resolution, some genuine persistence exists — today's momentum really does spill into the next hour a little. You are not looking for c_future == 0. You are looking for c_past to dominate.

My actual numbers

For the LAB alignment flags:

Correlation Value
Feature vs past 1h move 0.27
Feature vs future 1h move 0.10

Past > future, by roughly 2.7×. That is the profile of a feature that describes the current state and happens to help. It is not a time machine.

If I had seen 0.10 past / 0.27 future, I would have thrown the pipeline out and started over.

The code-level proof

The correlation test is necessary but not sufficient. The model could still be fine while the engine peeks. So the second layer is a hard source-code assertion: every bar used must be <= entry timestamp.

# run_engine.py (excerpt) bars = load_bars(symbol, start, end) entry_ts = signal.timestamp features = compute_features(bars[bars.index <= entry_ts]) # ONLY the past label = compute_label(bars[bars.index > entry_ts]) # ONLY the future assert features.index.max() <= entry_ts, "feature leak: future bar used" assert label.index.min() > entry_ts, "label window overlaps features" 

Two assertions. If either fires, the run aborts. No silent leakage, no "it probably used the right window."

The six-point leakage checklist

This is the list I run before any model touches a live signal:

[ ] 1. No feature references the label window [ ] 2. Normalisation/scaling fit ONLY on train folds [ ] 3. Labels derive from shifted closes, never the same bar [ ] 4. Corporate actions adjusted on their event date [ ] 5. Option-chain strikes read only from their own session snapshot [ ] 6. No shuffle before time-series split 

Each one maps to a real failure I have seen:

  1. Label window overlap — the classic. A feature like "5-min realised vol" computed including the label bar.
  2. Scaler leak — StandardScaler().fit(X) on the full dataset. Mean and std now know the test set.
  3. Same-bar label — df['ret'] = close/close.shift(-1) - 1 used as both feature and target.
  4. Corporate-action leak — splits/bonus adjusted retroactively so the past "knows" a future event.
  5. Option snapshot leak — using the settlement-era chain to build features for an intraday decision days earlier.
  6. Shuffle leak — train_test_split(shuffle=True) on time-ordered rows. The most common and most fatal.

Why the correlation test is the one I trust most

The checklist can be argued with. The correlation test cannot.

It does not care about your code structure or your intentions. It asks one empirical question: does this feature know more about what comes next than what came before? If yes, the model is not clever — it is contaminated.

The additional beauty: it is model-agnostic. XGBoost, LightGBM, a neural net, a logistic regression — run the same test on the same feature matrix. If one model "wins" on a feature with a bad past/future ratio, that model is the one exploiting the leak.

The purged walk-forward that goes with it

Correlation checks the features. Validation must check the training procedure. I use purged, anchored walk-forward:

for train_end, test_end in rolling_windows(): train = data[:train_end] test = data[train_end:test_end] # purge: drop train rows whose label window overlaps test start purge_before = test.index.min() - label_horizon train = train[train.index < purge_before] model.fit(train.X, train.y) score = evaluate(model, test.X, test.y) 

The purge step is the part people skip. Clear it and the last training rows' labels overlap the first test rows — another silent leak.

The uncomfortable finding

When I ran the full audit, the slower direction definitions (15-minute DI/RSI, 60-minute return + TWAP) did not replicate on fresh data, while the current-minute alignment did.

That is the opposite of what leakage looks like. A leaker gets better on more data. An honest edge gets smaller and stays small. The fact that the sophisticated features faded while the simple one held is itself evidence that the simple one is real.

The takeaway

A feature correlated 0.27 with the past and 0.10 with the future passes. Flip that ratio and you have a leak, not an edge.

Before you believe any backtest, run two things: the past-vs-future correlation test on every feature, and the purged walk-forward on every fold. Honest features describe the past. Only bugs describe the future.

Educational research only. Not investment advice. Shakti Tiwari is NISM-Series-XII certified as an educator, not a SEBI-registered Research Analyst or Investment Adviser. Options trading carries substantial risk of loss.