Audit fixes: mixed-regime bias, live==backtest session parity, parallel replay

Fix 1 — mixed-"trending" regime (ADX strong, EMAs unaligned) was
hard-coded bullish in 5 sites: RSI reinterpretation used the uptrend
playbook (RSI 38-55 -> STRONG_BUY conf 75), BUY-only confidence
bonuses, BUY-only extension penalties, no counter-trend penalty.
Now: extremes-only RSI (as transitioning), no directional bonuses,
symmetric extension penalties. 6yr validation: H1 +67.2->+61.9R
(mixed skew 16B/11S -> 4B/7S), H4 +31.6->+27.5R (the 4 bias BUYs),
M15 +152.6->+154.7R, M5 +207.1->+206.1R with maxDD 28.7->24.3R.
The ~8R aggregate give-back is bull-market subsidy from the bug.

Fix 2 — live session filter now applies the EXACT replay-loop
predicate (session window + blocked hours on the signal bar's CLOSE
time, from the bar timestamp not wall clock). Replaces a wall-clock
filter gated on a "XAU STRATEGY" marker that no code writes, which
made live diverge from every validated book.

Fix 3 — delete dead _check_xau_oversold_bounce and
_generate_xau_trade_setup (unreachable; the latter hardcoded BUY and
skipped the spread/RR gates).

Backtester: parallel bar replay via forked workers (--workers,
default auto = cores-2 capped 12). Per-bar evaluation is pure; the
entry cooldown is applied in an ordered phase-2 pass. Proven
byte-identical to sequential on the same window; ~300 -> 1030-1680
bars/s (6yr M5: ~26min -> 5-8min). --workers 1 = sequential path.

Tests: 179 passed (new mixed-regime RSI regression test).
This commit is contained in:
Harwinder Sekhon
2026-07-11 22:57:37 -04:00
parent 6f69b9dd90
commit dde41fbeb8
5 changed files with 282 additions and 287 deletions
+7 -5
View File
@@ -955,7 +955,7 @@ class TechnicalEngine:
rsi_val = rsi_ind.value
regime = result.market_regime
if regime in ("trending_up", "trending"):
if regime == "trending_up":
if 38 <= rsi_val <= 55:
signal = SignalStrength.STRONG_BUY
conf = 75
@@ -1001,10 +1001,12 @@ class TechnicalEngine:
desc = f"RSI {rsi_val:.1f} — Overbought in downtrend, possible reversal"
else:
return
elif regime == "transitioning":
# Trend is being born — RSI can't tell direction yet, and
# range-fade rules would sell the newborn trend. Only extremes
# carry information here.
elif regime in ("transitioning", "trending"):
# Trend being born (transitioning) or strong ADX with EMAs
# unaligned (mixed "trending") — in both, RSI can't tell
# direction. Treating mixed-"trending" as an uptrend here was
# a systematic bullish bias (23 BUY / 1 SELL, -6.8R on the
# 6yr M15 book). Only extremes carry information.
if rsi_val >= 70:
signal = SignalStrength.SELL
conf = 50