validate_strategy_no_lookahead
Detect lookahead bias in backtest strategy code by static analysis. Flags negative .shift(N), forward-index arithmetic, and future-dated attributes to prevent unreliable backtests.
Instructions
Static-analysis check for the most common backtest bug: lookahead bias. Walks the strategy code's AST and flags negative .shift(N), forward-index arithmetic like df.iloc[i+1], open-upper slices inside per-bar callbacks, and attribute names that look future-dated (next_*, future_*, lookahead_*). Heuristic, not a proof — false negatives are possible. Run before trusting any backtest result.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python source of the strategy module / class. |