Skip to main content
Getly

Python Scripts

lookahead-guard — Look-Ahead Bias Detector for Quant Backtests

Mechanically prove your backtest is not peeking at the future.

$19.00

Product Description

The bug that silently improves your backtest

scipy.ndimage.minimum_filter1d(x, 20) looks innocent. Its default origin=0 makes it a centered window [t-10, t+9] — it reads 9 future days, runs without error or warning, and only makes the equity curve prettier. One missing parameter once invalidated 14 rounds of research.

lookahead-guard turns "this isn't a lookahead bug, right?" from a prayer into a re-runnable gate.

Four independent layers

  • A — Primitive semantics. Does this rolling/filter primitive equal the true trailing window [t-n+1, t]? Compared cell-by-cell against a reference implementation for a=1..30.

  • B — Future-blind test (the only decisive one). Perturb data after time t; if any output at or before t changes, it is a lookahead bug. Depends on no returns, no assumptions.

  • C — Static AST sentinel. Flags centered windows, negative shift, full-sample standardization, bfill, random splits.

  • D — Permutation test. Uses a circular-shift null rather than naive shuffling — naive shuffling destroys autocorrelation and yields optimistic p-values.

What it does not do

It does not predict returns, rank strategies, or promise profit. It answers exactly one question: does this code or signal peek at the future?

Install

pip install lookahead-guard
pip install "lookahead-guard[full]"   # adds pandas/scipy for the B layer

Honest boundaries — please read

  • Layer C is a heuristic, not a proof. Passing C does not mean you are clean; B is the real test.

  • full-sample-stat deliberately marks cross-sectional statistics MEDIUM, because that pattern is often legitimate.

  • negative-shift alone is usually innocent — shift(-1) is standard when building forward-return labels.

  • Layer A must compare against the same window. An earlier version compared against len(a) instead of n and became a new contamination source; there is a regression test for that bug.

MIT licensed. Pure Python, no network calls, no telemetry, runs fully offline.

What you get

1 file · 31.58 KB

  • lookahead-guard-0.1.0.zipZIP · 31.58 KB

Included in Getly Pro

Download with your Pro subscription

LicenceCommercial use allowed
PublishedOct 10, 2026
File size31.58 KB
File formatZIP
Versionv1.0
S
Signal Vault

Frequently asked questions

Do I get access instantly?

Yes. This is a digital product - you can download it right after checkout, straight from your library.

Can I use it for commercial projects?

Yes. Commercial use is allowed: use it in your own business and in things you sell. You may not resell or redistribute the file itself.

What's your refund policy?

You're covered by a 30-day money-back guarantee. If something isn't right, request a refund from your order and the Getly team reviews it.

What file formats and sizes will I get?

You'll download 1 file - ZIP - 31.58 KB in total.

Do I get free updates?

Yes - when the seller ships a new version, you can re-download the latest files from your library at no extra cost. Check the changelog for recent updates.

Price

$19.00