TauricResearch/TradingAgents · warning · ValueError
No OHLCV rows on or before {curr_date} for {symbol}.
Error message
No OHLCV rows on or before {curr_date} for {symbol}. What it means
Raised by _verified_rows() in tradingagents/dataflows/market_data_validator.py when raw OHLCV rows exist but none fall on or before curr_date after date coercion and the cutoff filter — i.e. the only available data is later than the requested date (look-ahead), or all Date values failed to parse. It is a ValueError; the defensive re-filter exists because a verification path must not trust pre-filtered input.
Source
Thrown at tradingagents/dataflows/market_data_validator.py:44
def _verified_rows(symbol: str, curr_date: str) -> pd.DataFrame:
"""OHLCV on or before curr_date, date-sorted. Raises if nothing usable.
``load_ohlcv`` already normalizes the Date column and filters out
look-ahead rows, but we re-apply the cutoff defensively — this is a
verification path, so it must not trust its input to be pre-filtered.
"""
data = load_ohlcv(symbol, curr_date)
if data is None or data.empty:
raise ValueError(f"No OHLCV data available for {symbol}.")
df = data.copy()
df["Date"] = pd.to_datetime(df["Date"], errors="coerce")
df = df.dropna(subset=["Date"])
df = df[df["Date"] <= pd.to_datetime(curr_date)].sort_values("Date")
if df.empty:
raise ValueError(f"No OHLCV rows on or before {curr_date} for {symbol}.")
return df
def _fmt(value) -> str:
if value is None or pd.isna(value):
return "N/A"
if isinstance(value, pd.Timestamp):
return value.strftime("%Y-%m-%d")
if isinstance(value, bool):
return str(value)
if isinstance(value, (int,)):
return str(value)
if isinstance(value, float):
return f"{value:.2f}"
return str(value)
def build_verified_market_snapshot(View on GitHub (pinned to a33fd4c0f1)
Solutions
- Verify the symbol traded on/before curr_date (check listing/IPO date); for pre-listing dates this error is correct behavior
- Fetch a date range that actually covers curr_date (start earlier than curr_date) so load_ohlcv has applicable rows
- Delete the stale/short cache file for that symbol and refetch with the correct range
- Catch ValueError and treat as 'cannot verify for this date' rather than a hard failure in batch backtests
Example fix
# before
_verified_rows("AAPL", "2000-01-05") # cache only holds 2024-2025 rows
# -> ValueError: No OHLCV rows on or before 2000-01-05 for AAPL.
# after
# fetch covering range first, then verify
get_historical_prices("AAPL", "1999-12-01", "2000-01-05")
rows = _verified_rows("AAPL", "2000-01-05") Defensive patterns
Strategy: validation
Validate before calling
from datetime import datetime
from tradingagents.dataflows.stockstats_utils import load_ohlcv
def covers_date(symbol: str, curr_date: str) -> bool:
data = load_ohlcv(symbol, curr_date)
if data is None or data.empty:
return False
dates = pandas.to_datetime(data["Date"], errors="coerce").dropna()
return bool((dates <= pandas.to_datetime(curr_date)).any()) Try / catch
try:
rows = _verified_rows(symbol, curr_date)
except ValueError as e:
if "on or before" in str(e):
# date predates all available rows (pre-IPO / short cache)
return f"Cannot verify {symbol} on {curr_date}: no rows on or before that date"
raise Prevention
- Check listing/IPO dates in your symbol universe before historical backtests
- Fetch date ranges that actually cover curr_date before verification
- Delete short-range cache files when switching backtest periods
When it happens
Trigger: Backtesting an early date (e.g. curr_date='2010-01-05') when the cached/downloaded frame only covers recent dates; an IPO date earlier than the first trading row; a cache file for a different period; malformed Date column where pd.to_datetime coerces everything to NaT.
Common situations: Historical simulations run before the symbol existed; cache pollution from a differently-ranged fetch; date column format changes after vendor output changes; timezone-shifted dates landing after the cutoff.
Related errors
- No OHLCV data available for {symbol}.
- latest row is {latest.date()}, {stale_days} days before the
- Yahoo Finance returned no rows
- Unsupported date format: {date_input}
- Date must be string or datetime object, got {type(date_input
AI-assisted analysis of TauricResearch/TradingAgents@a33fd4c0f1 (2026-08-14).
Data as JSON: /api/errors/7dd59c39f209b3a6.
Report an issue: GitHub.