TauricResearch/TradingAgents · error · NoMarketDataError

no cash flow data

Error message

no cash flow data

What it means

NoMarketDataError raised by get_cash_flow (y_finance.py) when the date-filtered cash-flow frame from yfinance is empty. Same pattern as the other financial-statement getters: unknown symbol, or curr_date predates the first available statement period, so filter_financials_by_date leaves zero columns and the empty check raises.

Source

Thrown at tradingagents/dataflows/y_finance.py:394

def get_cashflow(
    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 cash flow data from yfinance."""
    canonical = normalize_symbol(ticker)
    try:
        ticker_obj = yf.Ticker(canonical)

        if freq.lower() == "quarterly":
            data = yf_retry(lambda: ticker_obj.quarterly_cashflow)
        else:
            data = yf_retry(lambda: ticker_obj.cashflow)

        data = filter_financials_by_date(data, curr_date)

        if data.empty:
            raise NoMarketDataError(ticker, canonical, "no cash flow data")

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

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

        return header + csv_string

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


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

View on GitHub (pinned to a33fd4c0f1)

Solutions

  1. Use a curr_date after the first available cash-flow statement (or today for latest).
  2. Try freq='yearly' if quarterly data is missing for the symbol.
  3. Catch NoMarketDataError and treat cash-flow analysis as unavailable for that symbol/date.

Example fix

# before
cf = get_cash_flow('FOOBAR', 'quarterly', '2018-01-01')

# after
from tradingagents.dataflows.errors import NoMarketDataError
try:
    cf = get_cash_flow('FOOBAR', 'quarterly', '2018-01-01')
except NoMarketDataError:
    cf = get_cash_flow('FOOBAR', 'yearly', '2018-01-01')  # or None
Defensive patterns

Strategy: try-catch

Validate before calling

import yfinance as yf

def has_cashflow(symbol: str, freq: str = 'yearly') -> bool:
    obj = yf.Ticker(symbol)
    frame = obj.quarterly_cashflow if freq == 'quarterly' else obj.cashflow
    return frame is not None and not frame.empty

Try / catch

from tradingagents.dataflows.errors import NoMarketDataError

try:
    cf = get_cash_flow(symbol, freq, curr_date)
except NoMarketDataError:
    cf = None  # or fall back: get_cash_flow(symbol, 'yearly', curr_date)

Prevention

When it happens

Trigger: Calling get_cash_flow(ticker, freq, curr_date) for a symbol with no cash-flow statements on Yahoo, or with a curr_date before the earliest statement date; freq='quarterly' when only annual statements exist also yields an empty frame.

Common situations: Pre-IPO/backtest dates older than the company's filings, new listings with limited history, delisted tickers, or quarterly granularity not published for the symbol.

Related errors


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