{"record":{"id":"7dd59c39f209b3a6","repo":"TauricResearch/TradingAgents","slug":"no-ohlcv-rows-on-or-before-curr-date-for-symbol","errorCode":null,"errorMessage":"No OHLCV rows on or before {curr_date} for {symbol}.","messagePattern":"No OHLCV rows on or before (.+?) for (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"tradingagents/dataflows/market_data_validator.py","lineNumber":44,"sourceCode":"\n\ndef _verified_rows(symbol: str, curr_date: str) -> pd.DataFrame:\n    \"\"\"OHLCV on or before curr_date, date-sorted. Raises if nothing usable.\n\n    ``load_ohlcv`` already normalizes the Date column and filters out\n    look-ahead rows, but we re-apply the cutoff defensively — this is a\n    verification path, so it must not trust its input to be pre-filtered.\n    \"\"\"\n    data = load_ohlcv(symbol, curr_date)\n    if data is None or data.empty:\n        raise ValueError(f\"No OHLCV data available for {symbol}.\")\n\n    df = data.copy()\n    df[\"Date\"] = pd.to_datetime(df[\"Date\"], errors=\"coerce\")\n    df = df.dropna(subset=[\"Date\"])\n    df = df[df[\"Date\"] <= pd.to_datetime(curr_date)].sort_values(\"Date\")\n    if df.empty:\n        raise ValueError(f\"No OHLCV rows on or before {curr_date} for {symbol}.\")\n    return df\n\n\ndef _fmt(value) -> str:\n    if value is None or pd.isna(value):\n        return \"N/A\"\n    if isinstance(value, pd.Timestamp):\n        return value.strftime(\"%Y-%m-%d\")\n    if isinstance(value, bool):\n        return str(value)\n    if isinstance(value, (int,)):\n        return str(value)\n    if isinstance(value, float):\n        return f\"{value:.2f}\"\n    return str(value)\n\n\ndef build_verified_market_snapshot(","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/TauricResearch/TradingAgents/blob/a33fd4c0f134485a43553a2c23a63cb14adbd88f/tradingagents/dataflows/market_data_validator.py#L26-L62","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\n_verified_rows(\"AAPL\", \"2000-01-05\")  # cache only holds 2024-2025 rows\n# -> ValueError: No OHLCV rows on or before 2000-01-05 for AAPL.\n\n# after\n# fetch covering range first, then verify\nget_historical_prices(\"AAPL\", \"1999-12-01\", \"2000-01-05\")\nrows = _verified_rows(\"AAPL\", \"2000-01-05\")","handlingStrategy":"validation","validationCode":"from datetime import datetime\nfrom tradingagents.dataflows.stockstats_utils import load_ohlcv\n\ndef covers_date(symbol: str, curr_date: str) -> bool:\n    data = load_ohlcv(symbol, curr_date)\n    if data is None or data.empty:\n        return False\n    dates = pandas.to_datetime(data[\"Date\"], errors=\"coerce\").dropna()\n    return bool((dates <= pandas.to_datetime(curr_date)).any())","typeGuard":null,"tryCatchPattern":"try:\n    rows = _verified_rows(symbol, curr_date)\nexcept ValueError as e:\n    if \"on or before\" in str(e):\n        # date predates all available rows (pre-IPO / short cache)\n        return f\"Cannot verify {symbol} on {curr_date}: no rows on or before that date\"\n    raise","preventionTips":["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"],"tags":["data-quality","ohlcv","backtesting","look-ahead","validation"],"backgroundTag":null,"analyzedSha":"a33fd4c0f134485a43553a2c23a63cb14adbd88f","analyzedAt":"2026-08-14T19:45:16.920Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}