refactor(dataflows): read company identity and settlement prices through the data layer

- the Yahoo vendor owns get_company_profile and get_closes; agent_utils and the graph no longer import yfinance
- a test keeps vendor libraries inside dataflows
This commit is contained in:
Yijia-Xiao
2026-09-24 00:41:56 +00:00
parent b4479b0c70
commit f197e09dcc
8 changed files with 76 additions and 34 deletions
+3 -3
View File
@@ -8,8 +8,8 @@ hit the right instrument instead of failing/mismatching.
import pandas as pd
import tradingagents.agents.utils.agent_utils as au
import tradingagents.dataflows.y_finance as y_finance
import tradingagents.dataflows.yfinance_news as ynews
import tradingagents.graph.trading_graph as tg
from tradingagents.graph.trading_graph import TradingAgentsGraph
@@ -24,7 +24,7 @@ def test_identity_lookup_normalizes_symbol(monkeypatch):
def info(self):
return {"longName": "Gold Futures", "quoteType": "FUTURE"}
monkeypatch.setattr(au.yf, "Ticker", FakeTicker)
monkeypatch.setattr(y_finance.yf, "Ticker", FakeTicker)
au.resolve_instrument_identity.cache_clear()
identity = au.resolve_instrument_identity("XAUUSD")
@@ -45,7 +45,7 @@ def test_fetch_returns_normalizes_symbol(monkeypatch):
idx = pd.date_range(start="2025-01-02", periods=len(prices), freq="D")
return pd.DataFrame({"Close": prices}, index=idx)
monkeypatch.setattr(tg.yf, "Ticker", FakeTicker)
monkeypatch.setattr(y_finance.yf, "Ticker", FakeTicker)
# _fetch_returns does not use ``self``; call unbound to avoid building the graph.
raw, alpha, days, resolved = TradingAgentsGraph._fetch_returns(