validate_strategy_no_lookahead
Detect lookahead bias in strategy code before backtesting. Scans the AST for negative shifts, forward indexing, and future-dated attributes to flag common backtest-invalidating patterns.
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. |