Add session filter + auto-toggle, extend trade journal diagnostics

Session filter restricts trades to a UTC hour window (default 07-16,
London + NY) — opt-in via --session-filter, with --session-start /
--session-end overrides. Wired into both the backtester (cheap hour
check next to the regime gate) and live mode (downgrades signal to
NEUTRAL/F when current UTC hour is outside the window).

Auto-toggle (--auto-session-filter) tracks rolling mean pnl_pct over
the last N closed trades; when it falls below threshold, the session
filter activates, releasing once expectancy recovers. Default lookback
10 trades, threshold -0.3%.

Trade dataclass extended with diagnostic fields captured at entry:
entry_hour, entry_dow, ADX, ATR%, market_regime, volatility_regime,
mtf_agreement. These let --journal-csv exports surface loss-pattern
clusters when a window underperforms.

Validated on 2024 trend / 2023 chop / 2026 recent windows. Auto-toggle
preserves ~50% of trend edge while still cutting ~25% of recent-regime
losses — pure regime filter is still best on cumulative, so both
session flags ship default-off.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Harwinder
2026-05-07 18:38:49 -04:00
parent dcd98fffa2
commit b38ed17c96
5 changed files with 139 additions and 1 deletions
+9
View File
@@ -30,6 +30,15 @@ class Trade:
grade: str # signal grade at entry
score_at_entry: float
confidence_at_entry: float
# Diagnostic fields captured at entry — used to mine for loss-pattern
# filters when a window underperforms.
entry_hour: int = -1 # UTC hour 0-23
entry_dow: int = -1 # 0=Mon, 6=Sun
adx_at_entry: float = 0.0
atr_pct_at_entry: float = 0.0
market_regime: str = "" # trending_up / trending_down / ranging
volatility_regime: str = "" # low / medium / high
mtf_agreement: bool = False
@dataclass