From b6dad747e9251fe2aba7a7e5971ea714076bc2bf Mon Sep 17 00:00:00 2001 From: Yijia-Xiao Date: Thu, 17 Sep 2026 02:37:15 +0000 Subject: [PATCH] fix(dataflows): state the vintage rule on yfinance statements - periods are cut at the fiscal period end and the vendor reports no filing date, so the newest period may not have been published yet --- tradingagents/dataflows/y_finance.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tradingagents/dataflows/y_finance.py b/tradingagents/dataflows/y_finance.py index 7bc9dd18a..7ec45a227 100644 --- a/tradingagents/dataflows/y_finance.py +++ b/tradingagents/dataflows/y_finance.py @@ -374,7 +374,8 @@ 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\n" + header += f"# Data retrieved on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n" + header += _PERIOD_END_VINTAGE return header + csv_string @@ -409,7 +410,8 @@ 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\n" + header += f"# Data retrieved on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n" + header += _PERIOD_END_VINTAGE return header + csv_string @@ -444,7 +446,8 @@ 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\n" + header += f"# Data retrieved on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n" + header += _PERIOD_END_VINTAGE return header + csv_string @@ -454,6 +457,17 @@ def get_income_statement( return f"Error retrieving income statement for {ticker}: {str(e)}" +# This vendor dates a statement by the period it covers, not by the day it was +# filed, and carries no filing date to do better. A company files weeks after its +# period ends, so a run dated in that gap can be served figures that were not yet +# public. Say so rather than implying the stricter guarantee (SEC EDGAR, which +# does carry filing dates, serves US filers as filed). +_PERIOD_END_VINTAGE = ( + "# Periods are cut at the fiscal period end; this vendor does not report " + "filing dates, so the most recent period may not have been published yet.\n\n" +) + + def get_insider_transactions( ticker: Annotated[str, "ticker symbol of the company"], curr_date: Annotated[str | None, "only filings on or before this date, yyyy-mm-dd"] = None,