Live news gate: stop capping signal confidence near events (XAU default)
Replaying the live danger/caution gates against the validated 12mo XAU M5 book showed they suppress 25-35 trades worth +4.6..+7.2R/yr — trades entered near USD releases outperform the book average (+0.475R vs +0.256R). New NewsConfig.event_risk_caps_signals (default False = XAU-tuned) keeps EVENT RISK warnings in alerts but no longer guts confidence; EUR factory re-enables the caps (evidence is gold-specific). Pinned XAU M5 regression: 547 trades, +139.94R, trade-identical. Tests: 177 passed.
This commit is contained in:
+37
@@ -1203,6 +1203,43 @@ def _():
|
||||
assert report.action_recommendation != ""
|
||||
|
||||
|
||||
@test("Event-risk signal gating obeys news.event_risk_caps_signals")
|
||||
def _():
|
||||
config = PlatformConfig()
|
||||
agg = SignalAggregator(config)
|
||||
dfs = {
|
||||
Timeframe.H1: make_ohlcv(300, seed=42),
|
||||
Timeframe.M15: make_ohlcv(300, seed=43),
|
||||
Timeframe.H4: make_ohlcv(300, seed=44),
|
||||
}
|
||||
report = agg.analyze_from_dataframes("XAU/USD", dfs, use_news=False)
|
||||
|
||||
def recompute(risk, caps):
|
||||
config.news.event_risk_caps_signals = caps
|
||||
report.event_risk = risk
|
||||
report.event_description = "USD Test Event in 10min"
|
||||
report.warnings = []
|
||||
agg._compute_final_signal(report)
|
||||
return report.final_confidence
|
||||
|
||||
baseline = recompute("clear", True)
|
||||
# default XAU behavior (caps off): danger warns but does not gut
|
||||
conf_off = recompute("danger", False)
|
||||
assert conf_off == baseline, "flag off must not change confidence"
|
||||
assert any("EVENT RISK" in w for w in report.warnings), "warning must persist"
|
||||
# caps on: danger hard-caps confidence at 30
|
||||
conf_on = recompute("danger", True)
|
||||
assert conf_on <= 30, f"danger with caps on must cap conf at 30, got {conf_on}"
|
||||
# caution with caps off is also warning-only
|
||||
conf_caut_off = recompute("caution", False)
|
||||
assert conf_caut_off == baseline
|
||||
assert any("Upcoming event" in w for w in report.warnings)
|
||||
# PlatformConfig default is off (XAU-tuned); EUR factory re-enables
|
||||
assert PlatformConfig().news.event_risk_caps_signals is False
|
||||
from pair_signals.eurusd import make_config as eur_make
|
||||
assert eur_make(Timeframe.M15).news.event_risk_caps_signals is True
|
||||
|
||||
|
||||
@test("SignalAggregator._generate_trade_setup BUY direction")
|
||||
def _():
|
||||
config = PlatformConfig()
|
||||
|
||||
Reference in New Issue
Block a user