Skip to content

fix(backtest): put leftover WFO runners on the canonical clock - #187

Merged
Trujillofa merged 4 commits into
mainfrom
cursor/wfo-canonical-clock-c2d3
Sep 1, 2026
Merged

fix(backtest): put leftover WFO runners on the canonical clock#187
Trujillofa merged 4 commits into
mainfrom
cursor/wfo-canonical-clock-c2d3

Conversation

@Trujillofa

@Trujillofa Trujillofa commented Aug 30, 2026

Copy link
Copy Markdown
Owner

Summary

Advertised WFO still used a different clock than canonical autopilot. scripts/run_wfo.py (and leftover comparison/overlap callers) built 30-day months, fetched inclusive test_end bars, and inherited legacy_v1 signal-close fills. The quality bar only locked autopilot/search onto calendar + half-open + v2.

Type of Change

  • Bug fix
  • New feature
  • Refactoring
  • Documentation update
  • Tests

Problem

After #185, experiment_autopilot and the search CLIs translate half-open WFO windows before the inclusive reader. The documented run_wfo.py path did not:

  • timedelta(days=months * 30) instead of calendar build_wfo_windows
  • raw test_end into fetch_range (time <= end), so a v2 next-open fill on the exclusive boundary can complete a trade a half-open window would leave unfilled
  • no --execution-profile, so it inherited run_backtest.py default legacy_v1

analyze_entry_overlap.py also passed raw window.test_end and defaulted to legacy_v1. Paper-vs-backtest overlap could therefore disagree with gated WFO.

Approach

  • run_wfo.py: calendar windows, wfo_inclusive_fetch_bounds(), default execution_parity_v2. Honest docstring: fixed-config OOS, not parameter optimization.
  • run_wfo_short_comparison.py: same clock + live-go refusal.
  • analyze_entry_overlap.py: same fetch bounds + v2 fills + live-go refusal.
  • Quality bar now covers these leftover runners (source contract + oos_fetch_windows equals canonical bounds + 30-day vs calendar divergence).
  • Docs (BACKTEST_AND_WFO.md, RESEARCH_FRAMEWORK.md, CLAUDE.md) point gated WFO at autopilot.

Test evidence

uv run ruff check .
uv run ruff format --check .
uv run pytest -v

1404 passed locally. CI lint already green on this SHA; test job was still running at PR update.

Residual risk

  • Frozen historical WFO CSVs/reports stay as written; do not rerun them to “fix” old gates.
  • run_backtest.py single-window default remains legacy_v1 for old-run reproducibility.
  • run_wfo.py still shells out to run_backtest.py (needs DB for a real run). Clock/profile are now explicit.
  • Sharpe-on-flat-bars and spot/futures return_pct denominator (June audit D/E) are unchanged.

live: no

No paper→live flip, size change, kill-switch change, or Binance keys.

Testing

  • Tests pass locally: uv run pytest -v (1404 passed)
  • Lint passes: uv run ruff check . (CI uses ruff, not black)
  • Format check: uv run ruff format --check .

Checklist

  • Code follows project style
  • Self-review completed
  • Documentation updated (if needed)
  • Tests added/updated (if needed)
Open in Web Open in Cursor 

Advertised run_wfo.py still used 30-day months, inclusive test_end
fetches, and legacy_v1 fills while the quality bar only covered
autopilot/search. Wire it, the short-comparison script, and entry
overlap to calendar windows, half-open fetch bounds, and
execution_parity_v2. This is not a live-go.

Co-Authored-By: Grok 4.6 <noreply@x.ai>

Co-authored-by: Yderf <Trujillofa@users.noreply.github.com>
@Trujillofa
Trujillofa marked this pull request as ready for review September 1, 2026 15:07
@Trujillofa

Copy link
Copy Markdown
Owner Author

Refreshing this PR onto current main after the Sharpe Ratio parser fix. Reopening the same PR; not a replacement.

@Trujillofa Trujillofa closed this Sep 1, 2026
Trujillofa and others added 2 commits September 1, 2026 10:09
run_wfo.py matched Sharpe: and silently filled 0.0 into every fold.
Parse the actual Sharpe Ratio: label and lock it with an e2e test.

Co-Authored-By: Grok 4.6 <noreply@x.ai>
@Trujillofa Trujillofa reopened this Sep 1, 2026
@Trujillofa
Trujillofa force-pushed the cursor/wfo-canonical-clock-c2d3 branch from 788f6f6 to 274784d Compare September 1, 2026 15:09
@Trujillofa
Trujillofa changed the base branch from main to tmp-pr187-base-refresh September 1, 2026 15:11
@Trujillofa
Trujillofa changed the base branch from tmp-pr187-base-refresh to main September 1, 2026 15:11
Empty commit so pull_request.synchronize runs against 7dd22b1.

Co-Authored-By: Grok 4.6 <noreply@x.ai>
@Trujillofa
Trujillofa force-pushed the cursor/wfo-canonical-clock-c2d3 branch from 274784d to 788f6f6 Compare September 1, 2026 15:11
@Trujillofa
Trujillofa merged commit 5f1b459 into main Sep 1, 2026
3 checks passed
@Trujillofa
Trujillofa deleted the cursor/wfo-canonical-clock-c2d3 branch September 1, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants