{"record":{"id":"03dcaf414d5fb29f","repo":"TauricResearch/TradingAgents","slug":"no-balance-sheet-data","errorCode":null,"errorMessage":"no balance sheet data","messagePattern":"no balance sheet data","errorType":"exception","errorClass":"NoMarketDataError","httpStatus":null,"severity":"error","filePath":"tradingagents/dataflows/y_finance.py","lineNumber":359,"sourceCode":"def get_balance_sheet(\n    ticker: Annotated[str, \"ticker symbol of the company\"],\n    freq: Annotated[str, \"frequency of data: 'annual' or 'quarterly'\"] = \"quarterly\",\n    curr_date: Annotated[str, \"current date in YYYY-MM-DD format\"] = None\n):\n    \"\"\"Get balance sheet data from yfinance.\"\"\"\n    canonical = normalize_symbol(ticker)\n    try:\n        ticker_obj = yf.Ticker(canonical)\n\n        if freq.lower() == \"quarterly\":\n            data = yf_retry(lambda: ticker_obj.quarterly_balance_sheet)\n        else:\n            data = yf_retry(lambda: ticker_obj.balance_sheet)\n\n        data = filter_financials_by_date(data, curr_date)\n\n        if data.empty:\n            raise NoMarketDataError(ticker, canonical, \"no balance sheet data\")\n\n        # Convert to CSV string for consistency with other functions\n        csv_string = data.to_csv()\n\n        # Add header information\n        header = f\"# Balance Sheet data for {canonical} ({freq})\\n\"\n        header += f\"# Data retrieved on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\\n\\n\"\n\n        return header + csv_string\n\n    except NoMarketDataError:\n        raise\n    except Exception as e:\n        return f\"Error retrieving balance sheet for {ticker}: {str(e)}\"\n\n\ndef get_cashflow(\n    ticker: Annotated[str, \"ticker symbol of the company\"],","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/TauricResearch/TradingAgents/blob/a33fd4c0f134485a43553a2c23a63cb14adbd88f/tradingagents/dataflows/y_finance.py#L341-L377","documentation":"NoMarketDataError raised by get_balance_sheet (y_finance.py) when the (date-filtered) balance-sheet frame from yfinance is empty. Either Yahoo returned no statements for the symbol, or filter_financials_by_date removed every column because no statement period falls on/before curr_date. The typed error gives the router one clean unavailable signal.","triggerScenarios":"Calling get_balance_sheet(ticker, freq, curr_date) with an unknown symbol, or with a curr_date earlier than the company's first available statement period (e.g. asking for 2015 data when statements start in 2020). After filter_financials_by_date, data.empty is true.","commonSituations":"Recently IPO'd companies with short statement history, backtest date ranges that predate the company, delisted symbols, or curr_date far in the past relative to the data yfinance exposes.","solutions":["Use a curr_date at or after the symbol's first financial statement date (or today for the latest).","Verify the symbol exists and has balance-sheet data on Yahoo before running.","Catch NoMarketDataError and skip fundamentals balance-sheet analysis for that symbol/date."],"exampleFix":"# before\nstmt = get_balance_sheet('FOOBAR', 'yearly', '2010-01-01')\n\n# after\nfrom tradingagents.dataflows.errors import NoMarketDataError\ntry:\n    stmt = get_balance_sheet('FOOBAR', 'yearly', '2010-01-01')\nexcept NoMarketDataError:\n    stmt = None  # no statements at/before this date","handlingStrategy":"try-catch","validationCode":"import yfinance as yf\nfrom datetime import datetime\n\ndef has_statements(symbol: str, freq: str = 'yearly') -> bool:\n    obj = yf.Ticker(symbol)\n    frame = obj.quarterly_balance_sheet if freq == 'quarterly' else obj.balance_sheet\n    return frame is not None and not frame.empty and frame.columns.max() <= pd.Timestamp(datetime.now())","typeGuard":null,"tryCatchPattern":"from tradingagents.dataflows.errors import NoMarketDataError\n\ntry:\n    stmt = get_balance_sheet(symbol, freq, curr_date)\nexcept NoMarketDataError:\n    stmt = None  # no statements at/before curr_date; skip or try a later date","preventionTips":["For backtests, verify each symbol's statement history start date first.","Prefer curr_date=today unless you truly need historical statements.","Catch NoMarketDataError once in the analyst layer for all three statement getters."],"tags":["market-data","yfinance","balance-sheet","financials"],"backgroundTag":null,"analyzedSha":"a33fd4c0f134485a43553a2c23a63cb14adbd88f","analyzedAt":"2026-08-14T19:45:16.920Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}