e609b433b0
New signal_log.py logs each SignalReport to logs/signals.db via a fail-safe hook in SignalAggregator.analyze_pair — the live-only entry point used by the bot, daemon, CLI and dashboard. Backtester calls analyze_from_dataframes directly, so live==backtest parity is preserved (test-locked). Rows carry signal/grade/price/spread, MTF + trade-setup + reasons/warnings JSON, and news-at-scan-time (calendar events + scored headlines JSON via NewsEngine class-level caches). Config: signal_log block (enabled, path; env SIGNAL_LOG_ENABLED/PATH), source tagged per consumer (telegram/oanda_daemon/cli/dashboard). 381 tests pass (24 modules).
52 lines
1.4 KiB
Python
52 lines
1.4 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,
|
|
log_source: str = "dashboard",
|
|
) -> 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, log_source=log_source)
|
|
|
|
|
|
from pair_signals import xauusd as _xau_mod
|
|
from config import XAUUSD
|
|
|
|
register_pair(XAUUSD, _xau_mod.make_config)
|