083a4e8d63
One class per provider (TwelveData, Oanda, Tiingo), all subclassing BaseDataProvider which owns cache, validation/cleaning, freshness + boundary guarantees, fetch_range pagination, and streaming stubs — subclasses implement only _fetch_raw. config.json data_providers.active selects the live feed; data_provider.py / oanda_provider.py stay as back-compat shims. Module 16 provider-abstraction tests (253 total green). Claude-Session: https://claude.ai/code/session_01Mc7XKYyPySVXiUpcN82QEK
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
"""
|
|
Per-pair signal producers.
|
|
|
|
Each pair module exposes:
|
|
make_config(primary_tf, confirmation_tfs) -> PlatformConfig
|
|
|
|
To add a new pair: create pair_signals/<pair>.py with make_config(),
|
|
then register it in this file.
|
|
"""
|
|
|
|
from typing import Optional, List, Dict, Callable
|
|
|
|
from config import PlatformConfig, Timeframe
|
|
from signal_aggregator import SignalAggregator, SignalReport
|
|
from providers import BaseDataProvider
|
|
|
|
PAIR_PRODUCERS: Dict[str, Callable] = {}
|
|
|
|
|
|
def register_pair(symbol: str, config_factory: Callable):
|
|
PAIR_PRODUCERS[symbol] = config_factory
|
|
|
|
|
|
def get_supported_pairs() -> List[str]:
|
|
return list(PAIR_PRODUCERS.keys())
|
|
|
|
|
|
def produce_signal(
|
|
symbol: str,
|
|
primary_tf: Timeframe,
|
|
data_provider: BaseDataProvider,
|
|
confirmation_tfs: Optional[List[Timeframe]] = None,
|
|
) -> SignalReport:
|
|
config_factory = PAIR_PRODUCERS.get(symbol)
|
|
if config_factory is None:
|
|
raise ValueError(
|
|
f"No signal producer registered for {symbol}. "
|
|
f"Available: {list(PAIR_PRODUCERS.keys())}"
|
|
)
|
|
|
|
config = config_factory(primary_tf, confirmation_tfs)
|
|
aggregator = SignalAggregator(config)
|
|
aggregator.data_provider = data_provider
|
|
return aggregator.analyze_pair(symbol=symbol)
|
|
|
|
|
|
from pair_signals import xauusd as _xau_mod
|
|
from config import XAUUSD
|
|
|
|
register_pair(XAUUSD, _xau_mod.make_config)
|