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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user