backtest: explain the regime-gated empty window + toggle to view raw-criteria trades
Owner saw a blank /backtest — it was CORRECT (the regime gate sat out every recent session) but unexplained. Now: ?regime=0|1 override on /api/backtest, an 'apply regime gate (as deployed)' checkbox, and an empty-state message saying WHY there are no trades and what to click. Gated view = what the bot would do; ungated = the raw simple criteria. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3ce8594605
commit
053c927cf7
3 files changed
+43
-3
No files matched your search
@@ -244,3 +244,24 @@ def test_replay_window_replays_live_track_only():
|
||||
from research.experiments.replay import replay_window
|
||||
out = replay_window(store, str(SESS1), str(SESS2))
|
||||
assert len(out["trades"]) == 4 # the 4 v1 fires only; liq1 excluded
|
||||
|
||||
|
||||
def test_backtest_regime_override_bypasses_gate(monkeypatch):
|
||||
"""/backtest UX fix (owner: 'no data in backtest'): when the regime gate
|
||||
zeroes a whole window the page must be able to show RAW-criteria trades
|
||||
via ?regime=0, and the response must echo which mode ran."""
|
||||
import api.main as m
|
||||
store = _seed_store()
|
||||
monkeypatch.setenv("TRADING_REGIME_GATE_ENABLED", "1")
|
||||
# unfavorable scores for BOTH sessions -> gated run has zero trades
|
||||
from research import regime as rg
|
||||
rg.apply_schema(store.con)
|
||||
for sess in (SESS1, SESS2):
|
||||
store.con.execute(
|
||||
"INSERT INTO regime_scores (model_version, session_date, p_profit, favorable, computed_at) "
|
||||
"VALUES ('meta_v1', ?, 0.1, false, now()) ON CONFLICT DO NOTHING", [sess])
|
||||
state = m.DashboardState("momentum")
|
||||
gated = state.backtest(days=10)
|
||||
raw = state.backtest(days=10, regime_override=False)
|
||||
assert gated["summary"]["n"] == 0 and gated["settings"]["regime_gate"] is True
|
||||
assert raw["summary"]["n"] == 4 and raw["settings"]["regime_gate"] is False
|
||||
Reference in new issue
Block a user