Add pair_signals per-pair producer registry
Ported from feature/eurusd-support: PAIR_PRODUCERS registry with make_config() factories per pair. xauusd.make_config is a pure PlatformConfig-defaults wrapper (equality with the inline construction is enforced by test); eurusd.make_config carries the donor branch's regime weights and gates as a pre-realism baseline. Adds 4 registry tests. 154/154 pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+54
-1
@@ -1761,7 +1761,60 @@ def _():
|
||||
assert r1.market_regime == r2.market_regime
|
||||
|
||||
|
||||
print("\n═══ Module 9: Engine Bug Fix Regressions ═══")
|
||||
print("\n═══ Module 9: pair_signals registry ═══")
|
||||
|
||||
@test("pair_signals registry includes XAU/USD and EUR/USD")
|
||||
def _():
|
||||
import pair_signals
|
||||
pairs = pair_signals.get_supported_pairs()
|
||||
assert XAUUSD in pairs, f"XAU missing from registry: {pairs}"
|
||||
assert "EUR/USD" in pairs, f"EUR missing from registry: {pairs}"
|
||||
|
||||
|
||||
@test("xauusd.make_config equals inline PlatformConfig construction")
|
||||
def _():
|
||||
import dataclasses
|
||||
from pair_signals import PAIR_PRODUCERS
|
||||
for tf, ctfs in [
|
||||
(Timeframe.M5, [Timeframe.M15, Timeframe.H1]),
|
||||
(Timeframe.M15, [Timeframe.M5, Timeframe.H1]),
|
||||
(Timeframe.H1, [Timeframe.M15, Timeframe.H4]),
|
||||
]:
|
||||
factory_cfg = PAIR_PRODUCERS[XAUUSD](tf, ctfs)
|
||||
inline_cfg = PlatformConfig(
|
||||
symbol=XAUUSD,
|
||||
display_name="XAU/USD",
|
||||
pip_value=0.10,
|
||||
primary_timeframe=tf,
|
||||
confirmation_timeframes=ctfs,
|
||||
)
|
||||
assert dataclasses.asdict(factory_cfg) == dataclasses.asdict(inline_cfg), \
|
||||
f"XAU factory config differs from inline construction for {tf}"
|
||||
|
||||
|
||||
@test("eurusd.make_config produces EUR config with XAU strategy disabled")
|
||||
def _():
|
||||
from pair_signals import PAIR_PRODUCERS
|
||||
cfg = PAIR_PRODUCERS["EUR/USD"](Timeframe.M5, None)
|
||||
assert cfg.symbol == "EUR/USD"
|
||||
assert cfg.pip_value == 0.0001
|
||||
assert cfg.xau_strategy.enabled is False
|
||||
assert cfg.eur_strategy.enabled is True
|
||||
assert cfg.technical.regime_weights_override, "EUR regime weights not applied"
|
||||
assert cfg.confirmation_timeframes == [Timeframe.M15, Timeframe.H1]
|
||||
|
||||
|
||||
@test("produce_signal raises for unregistered pair")
|
||||
def _():
|
||||
from pair_signals import produce_signal
|
||||
try:
|
||||
produce_signal("GBP/JPY", Timeframe.H1, None)
|
||||
assert False, "Expected ValueError for unregistered pair"
|
||||
except ValueError as e:
|
||||
assert "GBP/JPY" in str(e)
|
||||
|
||||
|
||||
print("\n═══ Module 9b: Engine Bug Fix Regressions ═══")
|
||||
|
||||
# ── 9a. Swing point NaN fix ──────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user