fix(data): normalize symbols on the identity and reflection paths

resolve_instrument_identity and the reflection return lookup queried Yahoo with
the raw ticker, so broker/forex/commodity symbols (XAUUSD, BTCUSD, EURUSD)
failed identity or could mismatch the priced instrument even though the price
path already normalized them. Route both through normalize_symbol (#983, #984).
This commit is contained in:
Yijia-Xiao committed 2026-06-13 20:39:52 +00:00
1 parent 2a58c2208f
commit 7c8fe2fe9f
3 files changed
+66 -2

No files matched your search

+6 -1
View File
@@ -232,12 +232,17 @@ class TradingAgentsGraph:
actual_holding_days)`` or ``(None, None, None)`` if price data is
unavailable (too recent, delisted, or network error).
"""
from tradingagents.dataflows.symbol_utils import normalize_symbol
try:
start = datetime.strptime(trade_date, "%Y-%m-%d")
end = start + timedelta(days=holding_days + 7) # buffer for weekends/holidays
end_str = end.strftime("%Y-%m-%d")
stock = yf.Ticker(ticker).history(start=trade_date, end=end_str)
# Normalize so the realized-return lookup hits the same instrument
# the analysis priced (e.g. XAUUSD -> GC=F) (#984). The benchmark is
# already a canonical Yahoo symbol from ``_resolve_benchmark``.
stock = yf.Ticker(normalize_symbol(ticker)).history(start=trade_date, end=end_str)
bench = yf.Ticker(benchmark).history(start=trade_date, end=end_str)
if len(stock) < 2 or len(bench) < 2: