TauricResearch/TradingAgents · warning · NoMarketDataError
Yahoo Finance returned no rows
Error message
Yahoo Finance returned no rows
What it means
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.
Source
Thrown at tradingagents/dataflows/stockstats_utils.py:206
not cached.empty
and "Close" in cached.columns
and not _needs_same_day_refresh(data_file, curr_date_dt, today_date)
):
data = cached
if data is None:
downloaded = yf_retry(lambda: yf.download(
canonical,
start=start_str,
end=end_str,
multi_level_index=False,
progress=False,
auto_adjust=True,
))
downloaded = _ensure_date_column(downloaded.reset_index())
# Only cache real data — never persist an empty frame.
if downloaded.empty or "Close" not in downloaded.columns:
raise NoMarketDataError(
symbol, canonical, "Yahoo Finance returned no rows"
)
downloaded.to_csv(data_file, index=False, encoding="utf-8")
data = downloaded
data = _clean_dataframe(data)
# Filter to curr_date to prevent look-ahead bias in backtesting
data = data[data["Date"] <= curr_date_dt]
# Reject a stale frame (latest row far older than curr_date) rather than
# feeding year-old prices into indicators (#1021).
_assert_ohlcv_not_stale(data, curr_date, symbol, canonical)
return data
def filter_financials_by_date(data: pd.DataFrame, curr_date: str) -> pd.DataFrame:View on GitHub (pinned to a33fd4c0f1)
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
Example fix
# before
get_stock_data_indicators_window_sma("ZZZZZZ", "2025-06-10", 10, 10)
# -> NoMarketDataError: ... Yahoo Finance returned no rows
# after
from tradingagents.dataflows.errors import NoMarketDataError
try:
out = get_stock_data_indicators_window_sma(symbol, "2025-06-10", 10, 10)
except NoMarketDataError:
out = f"No data for {symbol}; skip analysis" # never fabricate prices Defensive patterns
Strategy: fallback
Validate before calling
import yfinance as yf
def yahoo_covers(symbol: str) -> bool:
try:
return not yf.Ticker(symbol).history(period="5d").empty
except Exception:
return False Try / catch
from tradingagents.dataflows.errors import NoMarketDataError
try:
out = get_stock_data_indicators_window_sma(sym, curr_date, 10, 10)
except NoMarketDataError as e:
out = f"NO_DATA: {e.symbol} — report unavailable, do not estimate" Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No OHLCV data available for {symbol}.
- No OHLCV rows on or before {curr_date} for {symbol}.
- latest row is {latest.date()}, {stale_days} days before the
- ticker must be a non-empty string, got {value!r}
- ticker exceeds {max_len} chars: {value!r}
AI-assisted analysis of TauricResearch/TradingAgents@a33fd4c0f1 (2026-08-14).
Data as JSON: /api/errors/48bd0786851cfe89.
Report an issue: GitHub.