{"record":{"id":"48bd0786851cfe89","repo":"TauricResearch/TradingAgents","slug":"yahoo-finance-returned-no-rows","errorCode":null,"errorMessage":"Yahoo Finance returned no rows","messagePattern":"Yahoo Finance returned no rows","errorType":"exception","errorClass":"NoMarketDataError","httpStatus":null,"severity":"warning","filePath":"tradingagents/dataflows/stockstats_utils.py","lineNumber":206,"sourceCode":"            not cached.empty\n            and \"Close\" in cached.columns\n            and not _needs_same_day_refresh(data_file, curr_date_dt, today_date)\n        ):\n            data = cached\n\n    if data is None:\n        downloaded = yf_retry(lambda: yf.download(\n            canonical,\n            start=start_str,\n            end=end_str,\n            multi_level_index=False,\n            progress=False,\n            auto_adjust=True,\n        ))\n        downloaded = _ensure_date_column(downloaded.reset_index())\n        # Only cache real data — never persist an empty frame.\n        if downloaded.empty or \"Close\" not in downloaded.columns:\n            raise NoMarketDataError(\n                symbol, canonical, \"Yahoo Finance returned no rows\"\n            )\n        downloaded.to_csv(data_file, index=False, encoding=\"utf-8\")\n        data = downloaded\n\n    data = _clean_dataframe(data)\n\n    # Filter to curr_date to prevent look-ahead bias in backtesting\n    data = data[data[\"Date\"] <= curr_date_dt]\n\n    # Reject a stale frame (latest row far older than curr_date) rather than\n    # feeding year-old prices into indicators (#1021).\n    _assert_ohlcv_not_stale(data, curr_date, symbol, canonical)\n\n    return data\n\n\ndef filter_financials_by_date(data: pd.DataFrame, curr_date: str) -> pd.DataFrame:","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/TauricResearch/TradingAgents/blob/a33fd4c0f134485a43553a2c23a63cb14adbd88f/tradingagents/dataflows/stockstats_utils.py#L188-L224","documentation":"Raised in tradingagents/dataflows/stockstats_utils.py after a yfinance download for the symbol: the returned frame is empty or lacks a 'Close' column, so nothing is cached and a NoMarketDataError (symbol, canonical, 'Yahoo Finance returned no rows') is raised. The router turns it into the NO_DATA_AVAILABLE sentinel; empty frames are deliberately never persisted to the cache.","triggerScenarios":"yf.download for an invalid/delisted ticker; symbols Yahoo does not cover (some exchanges/OTC); an empty date window (start >= end); rate-limit/login walls on Yahoo returning zero rows; canonical symbol resolution producing a Yahoo-unrecognized form.","commonSituations":"LLM-generated or user-typo'd tickers; delisted stocks in historical runs; region-restricted symbols on Yahoo; too-narrow date ranges that exclude all trading days; Yahoo's periodic unauthenticated-access throttling.","solutions":["Verify the ticker exists on Yahoo: yf.Ticker(sym).history(period='5d') — if that is empty too, the symbol/coverage is the problem","Widen the requested date range so it actually spans trading days","Add a second vendor in config (data_vendors=\"yfinance,alpha_vantage\") so uncovered symbols fall through to another source","Catch NoMarketDataError (or check for the NO_DATA_AVAILABLE sentinel string) and report the symbol as unavailable rather than estimating"],"exampleFix":"# before\nget_stock_data_indicators_window_sma(\"ZZZZZZ\", \"2025-06-10\", 10, 10)\n# -> NoMarketDataError: ... Yahoo Finance returned no rows\n\n# after\nfrom tradingagents.dataflows.errors import NoMarketDataError\ntry:\n    out = get_stock_data_indicators_window_sma(symbol, \"2025-06-10\", 10, 10)\nexcept NoMarketDataError:\n    out = f\"No data for {symbol}; skip analysis\"   # never fabricate prices","handlingStrategy":"fallback","validationCode":"import yfinance as yf\n\ndef yahoo_covers(symbol: str) -> bool:\n    try:\n        return not yf.Ticker(symbol).history(period=\"5d\").empty\n    except Exception:\n        return False","typeGuard":null,"tryCatchPattern":"from tradingagents.dataflows.errors import NoMarketDataError\n\ntry:\n    out = get_stock_data_indicators_window_sma(sym, curr_date, 10, 10)\nexcept NoMarketDataError as e:\n    out = f\"NO_DATA: {e.symbol} — report unavailable, do not estimate\"","preventionTips":["Validate symbols exist on Yahoo before feeding them to the pipeline","Configure multi-vendor chains (yfinance,alpha_vantage) for coverage gaps","Check for the NO_DATA_AVAILABLE sentinel string in outputs instead of assuming numeric data"],"tags":["data-quality","yfinance","symbols","ohlcv"],"backgroundTag":null,"analyzedSha":"a33fd4c0f134485a43553a2c23a63cb14adbd88f","analyzedAt":"2026-08-14T19:45:16.920Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}