TauricResearch/TradingAgents · error · NoMarketDataError
no rows between {start_date} and {end_date}
Error message
no rows between {start_date} and {end_date} What it means
NoMarketDataError raised by get_YFinData in tradingagents/dataflows/y_finance.py when yfinance returns an empty history frame for the requested start/end range. An empty frame almost always means the symbol is unknown, delisted, or has no trading rows in the window. The routing layer converts this typed error into a single unambiguous 'no data' signal so downstream agents never fabricate prices.
Source
Thrown at tradingagents/dataflows/y_finance.py:41
datetime.strptime(start_date, "%Y-%m-%d")
end_dt = datetime.strptime(end_date, "%Y-%m-%d")
# Resolve broker/forex symbols to Yahoo's convention (XAUUSD+ -> GC=F).
canonical = normalize_symbol(symbol)
ticker = yf.Ticker(canonical)
# yfinance treats ``end`` as EXCLUSIVE, so it would drop the requested
# end_date row (and the current day when end_date is today). Request one day
# past end_date so the requested range is actually inclusive (#986/#987).
end_inclusive = (end_dt + relativedelta(days=1)).strftime("%Y-%m-%d")
data = yf_retry(lambda: ticker.history(start=start_date, end=end_inclusive))
# Empty result means the symbol is unknown/delisted. Raise a typed error
# instead of returning prose: the routing layer turns it into a single
# unambiguous "no data" signal so the agent never fabricates a price.
if data.empty:
raise NoMarketDataError(
symbol, canonical, f"no rows between {start_date} and {end_date}"
)
# Remove timezone info from index for cleaner output
if data.index.tz is not None:
data.index = data.index.tz_localize(None)
# Reject a stale frame (e.g. a year-old partial response) before it is
# formatted into the report. Raises NoMarketDataError, which the router
# turns into one clear unavailable signal (#1021).
_assert_ohlcv_not_stale(data, end_date, symbol, canonical)
# Round numerical values to 2 decimal places for cleaner display
numeric_columns = ["Open", "High", "Low", "Close", "Adj Close"]
for col in numeric_columns:
if col in data.columns:
data[col] = data[col].round(2)
View on GitHub (pinned to a33fd4c0f1)
Solutions
- Verify the ticker exists on Yahoo Finance (e.g. open finance.yahoo.com or call yf.Ticker(sym).info) before running the pipeline.
- Widen the date range or ensure it contains at least one trading day for the symbol's exchange.
- Catch NoMarketDataError at the orchestration layer and report 'market data unavailable' rather than retrying with the same inputs.
- If Yahoo is intermittently empty, retry once after a short delay before giving up.
Example fix
# before
data = get_YFinData(start_date, end_date, 'FOOBAR')
# after
from tradingagents.dataflows.errors import NoMarketDataError
try:
data = get_YFinData(start_date, end_date, 'FOOBAR')
except NoMarketDataError:
data = None # handle unavailable symbol explicitly Defensive patterns
Strategy: try-catch
Validate before calling
import yfinance as yf
def symbol_has_history(symbol: str, start: str, end: str) -> bool:
hist = yf.Ticker(symbol).history(start=start, end=end)
return not hist.empty Try / catch
from tradingagents.dataflows.errors import NoMarketDataError
try:
data = get_YFin_data_window(start_date, end_date, symbol)
except NoMarketDataError as e:
logger.warning('no market data for %s: %s', symbol, e)
return None # or report 'unavailable' upstream; do not retry same inputs Prevention
- Pre-screen tickers against a known-good universe before running the pipeline.
- Keep NoMarketDataError handling in one orchestration layer so every data call is covered.
- Treat empty windows (holidays/weekends) as config bugs: assert the range contains a trading day.
When it happens
Trigger: Calling get_YFinData(symbol, start_date, end_date) with an unrecognized/delisted ticker (e.g. 'FOOBAR'), a symbol with no trading days inside [start_date, end_date], or a date range entirely in the future. yf.Ticker(...).history(...) returns an empty DataFrame and the check raises.
Common situations: Typo'd tickers, delisted symbols, requesting a window before the IPO date, weekend/holiday-only windows, or Yahoo Finance temporarily returning empty payloads for valid symbols.
Related errors
- no fundamentals returned
- no fundamental fields returned
- no balance sheet data
- no cash flow data
- no income statement data
AI-assisted analysis of TauricResearch/TradingAgents@a33fd4c0f1 (2026-08-14).
Data as JSON: /api/errors/a6c947c492ad9576.
Report an issue: GitHub.