TauricResearch/TradingAgents · error · NoMarketDataError

no balance sheet data

Error message

no balance sheet data

What it means

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.

Source

Thrown at tradingagents/dataflows/y_finance.py:359

def get_balance_sheet(
    ticker: Annotated[str, "ticker symbol of the company"],
    freq: Annotated[str, "frequency of data: 'annual' or 'quarterly'"] = "quarterly",
    curr_date: Annotated[str, "current date in YYYY-MM-DD format"] = None
):
    """Get balance sheet data from yfinance."""
    canonical = normalize_symbol(ticker)
    try:
        ticker_obj = yf.Ticker(canonical)

        if freq.lower() == "quarterly":
            data = yf_retry(lambda: ticker_obj.quarterly_balance_sheet)
        else:
            data = yf_retry(lambda: ticker_obj.balance_sheet)

        data = filter_financials_by_date(data, curr_date)

        if data.empty:
            raise NoMarketDataError(ticker, canonical, "no balance sheet data")

        # Convert to CSV string for consistency with other functions
        csv_string = data.to_csv()

        # 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"

        return header + csv_string

    except NoMarketDataError:
        raise
    except Exception as e:
        return f"Error retrieving balance sheet for {ticker}: {str(e)}"


def get_cashflow(
    ticker: Annotated[str, "ticker symbol of the company"],

View on GitHub (pinned to a33fd4c0f1)

Solutions

  1. Use a curr_date at or after the symbol's first financial statement date (or today for the latest).
  2. Verify the symbol exists and has balance-sheet data on Yahoo before running.
  3. Catch NoMarketDataError and skip fundamentals balance-sheet analysis for that symbol/date.

Example fix

# before
stmt = get_balance_sheet('FOOBAR', 'yearly', '2010-01-01')

# after
from tradingagents.dataflows.errors import NoMarketDataError
try:
    stmt = get_balance_sheet('FOOBAR', 'yearly', '2010-01-01')
except NoMarketDataError:
    stmt = None  # no statements at/before this date
Defensive patterns

Strategy: try-catch

Validate before calling

import yfinance as yf
from datetime import datetime

def has_statements(symbol: str, freq: str = 'yearly') -> bool:
    obj = yf.Ticker(symbol)
    frame = obj.quarterly_balance_sheet if freq == 'quarterly' else obj.balance_sheet
    return frame is not None and not frame.empty and frame.columns.max() <= pd.Timestamp(datetime.now())

Try / catch

from tradingagents.dataflows.errors import NoMarketDataError

try:
    stmt = get_balance_sheet(symbol, freq, curr_date)
except NoMarketDataError:
    stmt = None  # no statements at/before curr_date; skip or try a later date

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of TauricResearch/TradingAgents@a33fd4c0f1 (2026-08-14). Data as JSON: /api/errors/03dcaf414d5fb29f. Report an issue: GitHub.