{"record":{"id":"874138b15e5becd8","repo":"HKUDS/Vibe-Trading","slug":"estimation-window-must-be-at-least-min-estimation","errorCode":null,"errorMessage":"estimation_window must be at least {MIN_ESTIMATION_OBSERVATIONS}, got {estimation_window}","messagePattern":"estimation_window must be at least (.+?), got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/eventstudy.py","lineNumber":351,"sourceCode":"\n    Returns:\n        An :class:`EventStudyResult`. Events that cannot be measured -- unknown\n        symbol, event date before the frame starts, not enough estimation rows,\n        an all-NaN window -- appear in ``dropped`` with a reason instead of\n        being silently skipped.\n\n    Raises:\n        ValueError: If the window bounds are inconsistent, ``estimation_gap`` is\n            negative, ``model`` is unknown, the market series does not cover the\n            frame's index, or no event at all could be measured.\n    \"\"\"\n    start, end = event_window\n    if start > end:\n        raise ValueError(f\"event_window start must be <= end, got {event_window}\")\n    if estimation_gap < 0:\n        raise ValueError(f\"estimation_gap must be >= 0, got {estimation_gap}\")\n    if estimation_window < MIN_ESTIMATION_OBSERVATIONS:\n        raise ValueError(\n            f\"estimation_window must be at least {MIN_ESTIMATION_OBSERVATIONS}, \"\n            f\"got {estimation_window}\"\n        )\n    if model not in NORMAL_RETURN_MODELS:\n        raise ValueError(f\"model must be one of {NORMAL_RETURN_MODELS}, got {model!r}\")\n    if not events:\n        raise ValueError(\"events is empty\")\n\n    index = returns.index\n    missing_market = index.difference(market_returns.index)\n    if len(missing_market):\n        raise ValueError(\n            f\"market_returns is missing {len(missing_market)} label(s) present in \"\n            \"returns; align them before calling\"\n        )\n    market_aligned = market_returns.reindex(index)\n\n    relative_days = list(range(start, end + 1))","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/eventstudy.py#L333-L369","documentation":"event_study enforces that estimation_window (its length in periods) is at least MIN_ESTIMATION_OBSERVATIONS, the same floor estimate_market_model applies to finite observations. A shorter window cannot yield reliable alpha/beta or residual variance estimates.","triggerScenarios":"Passing estimation_window=10 when the minimum is larger (e.g. 30), often while tuning for short-history assets or trying to speed up tests.","commonSituations":"Optimising runtime by shrinking windows, backtesting newly listed tickers with limited history, or a config default copied from another library with a lower floor.","solutions":["Raise estimation_window to at least MIN_ESTIMATION_OBSERVATIONS (check the constant in agent/src/quantlib/eventstudy.py).","If history is genuinely short, event_study cannot run; use a different benchmark or drop the event."],"exampleFix":"# before\nresult = event_study(..., estimation_window=20)\n# after\nfrom quantlib.eventstudy import MIN_ESTIMATION_OBSERVATIONS\nresult = event_study(..., estimation_window=max(MIN_ESTIMATION_OBSERVATIONS, 20))","handlingStrategy":"validation","validationCode":"from quantlib.eventstudy import MIN_ESTIMATION_OBSERVATIONS\nassert estimation_window >= MIN_ESTIMATION_OBSERVATIONS","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Import the constant rather than hard-coding the floor.","Ensure the returns history extends at least estimation_window + gap + |window start| periods before each event."],"tags":["event-study","minimum-sample","argument-validation"],"backgroundTag":"insufficient-data-validation","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}