{"record":{"id":"b72474417c7194c8","repo":"hsliuping/TradingAgents-CN","slug":"get-yfin-data-end-date-is-outside-of-the-data-r","errorCode":null,"errorMessage":"Get_YFin_Data: {end_date} is outside of the data range of 2015-01-01 to 2025-03-25","messagePattern":"Get_YFin_Data: (.+?) is outside of the data range of 2015-01-01 to 2025-03-25","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"tradingagents/dataflows/interface.py","lineNumber":918,"sourceCode":"\n    return header + csv_string\n\n\ndef get_YFin_data(\n    symbol: Annotated[str, \"ticker symbol of the company\"],\n    start_date: Annotated[str, \"Start date in yyyy-mm-dd format\"],\n    end_date: Annotated[str, \"End date in yyyy-mm-dd format\"],\n) -> str:\n    # read in data\n    data = pd.read_csv(\n        os.path.join(\n            DATA_DIR,\n            f\"market_data/price_data/{symbol}-YFin-data-2015-01-01-2025-03-25.csv\",\n        )\n    )\n\n    if end_date > \"2025-03-25\":\n        raise Exception(\n            f\"Get_YFin_Data: {end_date} is outside of the data range of 2015-01-01 to 2025-03-25\"\n        )\n\n    # Extract just the date part for comparison\n    data[\"DateOnly\"] = data[\"Date\"].str[:10]\n\n    # Filter data between the start and end dates (inclusive)\n    filtered_data = data[\n        (data[\"DateOnly\"] >= start_date) & (data[\"DateOnly\"] <= end_date)\n    ]\n\n    # Drop the temporary column we created\n    filtered_data = filtered_data.drop(\"DateOnly\", axis=1)\n\n    # remove the index from the dataframe\n    filtered_data = filtered_data.reset_index(drop=True)\n\n    return filtered_data","sourceCodeStart":900,"sourceCodeEnd":936,"githubUrl":"https://github.com/hsliuping/TradingAgents-CN/blob/74783e8817d6cf6de29867880631cc555153f36b/tradingagents/dataflows/interface.py#L900-L936","documentation":"Raised by get_YFin_data when the requested end_date exceeds 2025-03-25, the upper bound of the bundled offline Yahoo Finance CSV (2015-01-01 to 2025-03-25). The function serves only pre-downloaded local data, so later dates are impossible.","triggerScenarios":"Calling get_YFin_data(symbol, end_date='2025-06-01') or with today's date after 2025-03-25 while using the offline/cached data mode.","commonSituations":"Running the project with default offline data as time passes beyond the dataset's horizon; tests using datetime.now() as end date.","solutions":["Clamp end_date to '2025-03-25' when using offline YFin data","Switch to the online data path (get_YFin_data_online) for current dates","Regenerate/re-download the CSV and update the hardcoded range constant"],"exampleFix":"# before\ndf = get_YFin_data('AAPL', '2025-12-31', '2025-01-01')\n# after\ndf = get_YFin_data('AAPL', '2025-03-25', '2025-01-01')","handlingStrategy":"validation","validationCode":"end_date = min(end_date, '2025-03-25')\ndf = get_YFin_data(symbol, end_date, look_back_days)","typeGuard":null,"tryCatchPattern":"try:\n    df = get_YFin_data(symbol, end_date, look_back_days)\nexcept Exception as e:\n    if 'outside of the data range' in str(e):\n        df = get_YFin_data(symbol, '2025-03-25', look_back_days)\n    else:\n        raise","preventionTips":["Clamp dates to the dataset window when using offline mode","Use the online fetchers for current-dated analysis","Regenerate the bundled CSV periodically and update the range check"],"tags":["python","yfinance","offline-data","date-range"],"backgroundTag":"data-out-of-range","analyzedSha":"74783e8817d6cf6de29867880631cc555153f36b","analyzedAt":"2026-08-28T11:39:07.729Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}