mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-25 14:02:38 +03:00
fix(dataflows): stop telling a historical run today's date
- yfinance headers no longer stamp the wall clock (Data retrieved on)
This commit is contained in:
@@ -110,7 +110,6 @@ class TestLiveRunUnchanged:
|
||||
out = _yf(_TODAY)
|
||||
for value in _LEAKY:
|
||||
assert value in out
|
||||
assert "Data retrieved on:" in out
|
||||
assert "withheld" not in out
|
||||
|
||||
def test_yfinance_absent_curr_date_returns_the_full_profile(self):
|
||||
|
||||
@@ -246,3 +246,28 @@ def test_the_price_path_also_tells_an_outage_from_an_unknown_symbol(monkeypatch)
|
||||
monkeypatch.setattr(stockstats_utils, "vendor_reachable", lambda url: True)
|
||||
with pytest.raises(NoMarketDataError):
|
||||
y_finance.get_YFin_data_online("AAPL", "2026-09-01", "2026-09-10")
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@pytest.mark.parametrize("func, args", [
|
||||
("get_YFin_data_online", ("AAPL", "2025-06-02", "2025-06-06")),
|
||||
("get_balance_sheet", ("AAPL", "quarterly", "2025-06-06")),
|
||||
("get_cashflow", ("AAPL", "quarterly", "2025-06-06")),
|
||||
("get_income_statement", ("AAPL", "quarterly", "2025-06-06")),
|
||||
("get_insider_transactions", ("AAPL", "2025-06-06")),
|
||||
])
|
||||
def test_a_historical_run_is_not_told_todays_date(func, args):
|
||||
"""A header stamped with the wall clock tells a backtest when it is really running."""
|
||||
from datetime import date
|
||||
|
||||
statement = pd.DataFrame({pd.Timestamp("2025-03-31"): [1.0]}, index=["Total Assets"])
|
||||
prices = pd.DataFrame({"Open": [1.0], "High": [1.0], "Low": [1.0], "Close": [1.0], "Volume": [1]},
|
||||
index=pd.DatetimeIndex(["2025-06-02"], name="Date"))
|
||||
ticker = mock.Mock(quarterly_balance_sheet=statement, quarterly_cashflow=statement,
|
||||
quarterly_income_stmt=statement,
|
||||
insider_transactions=_insider_frame("2025-05-30"),
|
||||
history=lambda **k: prices)
|
||||
with mock.patch.object(y_finance.yf, "Ticker", return_value=ticker):
|
||||
out = getattr(y_finance, func)(*args)
|
||||
|
||||
assert date.today().isoformat() not in out
|
||||
|
||||
@@ -71,8 +71,7 @@ def get_YFin_data_online(
|
||||
# agent (and user) can see which instrument was actually priced.
|
||||
label = canonical if canonical == symbol.upper() else f"{canonical} (from {symbol})"
|
||||
header = f"# Stock data for {label} from {start_date} to {end_date}\n"
|
||||
header += f"# Total records: {len(data)}\n"
|
||||
header += f"# Data retrieved on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n"
|
||||
header += f"# Total records: {len(data)}\n\n"
|
||||
|
||||
return header + csv_string
|
||||
|
||||
@@ -345,8 +344,7 @@ def get_fundamentals(
|
||||
if not lines:
|
||||
raise NoMarketDataError(ticker, canonical, "no fundamental fields returned")
|
||||
|
||||
header = f"# Company Fundamentals for {canonical}\n"
|
||||
header += f"# Data retrieved on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n"
|
||||
header = f"# Company Fundamentals for {canonical}\n\n"
|
||||
|
||||
return header + "\n".join(lines)
|
||||
|
||||
@@ -381,7 +379,6 @@ def get_balance_sheet(
|
||||
|
||||
# Add header information
|
||||
header = f"# Balance Sheet data for {canonical} ({freq})\n"
|
||||
header += f"# Data retrieved on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n"
|
||||
header += _PERIOD_END_VINTAGE
|
||||
|
||||
return header + csv_string
|
||||
@@ -417,7 +414,6 @@ def get_cashflow(
|
||||
|
||||
# Add header information
|
||||
header = f"# Cash Flow data for {canonical} ({freq})\n"
|
||||
header += f"# Data retrieved on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n"
|
||||
header += _PERIOD_END_VINTAGE
|
||||
|
||||
return header + csv_string
|
||||
@@ -453,7 +449,6 @@ def get_income_statement(
|
||||
|
||||
# Add header information
|
||||
header = f"# Income Statement data for {canonical} ({freq})\n"
|
||||
header += f"# Data retrieved on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n"
|
||||
header += _PERIOD_END_VINTAGE
|
||||
|
||||
return header + csv_string
|
||||
@@ -518,7 +513,6 @@ def get_insider_transactions(
|
||||
|
||||
# Add header information
|
||||
header = f"# Insider Transactions data for {canonical}\n"
|
||||
header += f"# Data retrieved on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n"
|
||||
header += _TRANSACTION_DATE_VINTAGE
|
||||
|
||||
return header + csv_string
|
||||
|
||||
Reference in New Issue
Block a user