From 9d362bd568b0d51be3b548a12050c681ed5dd97b Mon Sep 17 00:00:00 2001 From: Dennis Thiessen Date: Mon, 13 Jul 2026 16:51:55 +0200 Subject: [PATCH] Default online backtest to production GTL --- README.md | 5 +++++ app/services/backtest_service.py | 13 +++++++++++-- docs/research/sr-levels-and-exits.md | 6 ++++++ tests/unit/test_backtest_service.py | 3 +++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 734f8b6..3bd9fad 100644 --- a/README.md +++ b/README.md @@ -459,6 +459,11 @@ metrics. Keep the SSH tunnel open only while creating the snapshot; the backtest run itself is local/offline. `backtest_snapshots/` and generated backtest reports are git-ignored. +Without a research override, both this runner and the scheduled/Admin online +backtest use `explicit_target_ladder`, matching the live scanner's gate-target +path. Clean Structural S/R detector arms must be selected explicitly with +`--sr-variant`; they are not production backtest defaults. + ### Archived GTL tuning decision The completed replacement, cohort-composition, and strength-sensitivity diff --git a/app/services/backtest_service.py b/app/services/backtest_service.py index 7b2b601..6ff8927 100644 --- a/app/services/backtest_service.py +++ b/app/services/backtest_service.py @@ -176,8 +176,17 @@ SR_RESEARCH_VARIANTS = { def _sr_research_variant() -> str: - """S/R policy arm for local research; never read by the live scanner.""" - value = os.getenv("BACKTEST_SR_VARIANT", "rewrite").strip().lower() + """Backtest target policy; research arms require an explicit override. + + The unconfigured online/scheduled backtest must replay the same transient + Gate Target Ladder as the live scanner. Clean Structural S/R remains an + opt-in research arm here because it is intentionally chart/alert structure, + not the production gate's target source. + """ + value = os.getenv( + "BACKTEST_SR_VARIANT", + EXPLICIT_TARGET_LADDER_VARIANT, + ).strip().lower() if value not in SR_RESEARCH_VARIANTS: allowed = ", ".join(sorted(SR_RESEARCH_VARIANTS)) raise ValueError(f"Unknown BACKTEST_SR_VARIANT={value!r}; expected one of {allowed}") diff --git a/docs/research/sr-levels-and-exits.md b/docs/research/sr-levels-and-exits.md index 35c650d..73c3174 100644 --- a/docs/research/sr-levels-and-exits.md +++ b/docs/research/sr-levels-and-exits.md @@ -912,6 +912,12 @@ model. This snapshot is now exhausted for GTL fitting; any future challenger must be pre-registered and evaluated on genuinely new forward data rather than another iteration over the same history. +The scheduled/Admin online backtest and the unconfigured local snapshot +backtest therefore default to `explicit_target_ladder`. Structural detector +variants remain explicit research overrides. After deployment, rerun the Admin +backtest once to replace any cached report produced by the former `rewrite` +default. + The temporary GTL matrix scripts, configurable detector branches, and confirmation hooks were removed after this decision. The normal snapshot backtester and frozen `explicit_target_ladder` parity arm remain. diff --git a/tests/unit/test_backtest_service.py b/tests/unit/test_backtest_service.py index 8047788..ffe3d75 100644 --- a/tests/unit/test_backtest_service.py +++ b/tests/unit/test_backtest_service.py @@ -793,6 +793,9 @@ def test_window_setups_too_short_returns_empty(): def test_sr_research_variant_is_explicit_and_validated(monkeypatch): + monkeypatch.delenv("BACKTEST_SR_VARIANT", raising=False) + assert bt._sr_research_variant() == bt.EXPLICIT_TARGET_LADDER_VARIANT + for variant in ( "production_control", "legacy_range_grid_touch",