{"record":{"id":"8feed2b7d70a8b05","repo":"HKUDS/Vibe-Trading","slug":"estimation-gap-must-be-0-got-estimation-gap","errorCode":null,"errorMessage":"estimation_gap must be >= 0, got {estimation_gap}","messagePattern":"estimation_gap must be >= 0, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/eventstudy.py","lineNumber":349,"sourceCode":"            window so the model cannot see the event.\n        model: One of :data:`NORMAL_RETURN_MODELS`.\n\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)","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/eventstudy.py#L331-L367","documentation":"event_study requires estimation_gap — the number of trading days kept between the estimation window and the event window to avoid contamination — to be non-negative. A negative gap would make the estimation window overlap or run past the event, biasing normal-return estimates.","triggerScenarios":"Passing estimation_gap=-5 or any negative value, typically when computing the gap as a difference that can go negative for event windows extending far back.","commonSituations":"Parameter arithmetic (e.g. estimation_gap = pre_event_len - window_len) yielding negatives, config typos, or a copy-paste from code using the opposite sign convention.","solutions":["Clamp or correct the gap: estimation_gap = max(0, computed_gap).","Re-check the convention: gap counts days strictly between the estimation window end and the event window start."],"exampleFix":"# before\nresult = event_study(..., estimation_gap=event_start - est_end)  # can be negative\n# after\nresult = event_study(..., estimation_gap=max(0, event_start - est_end))","handlingStrategy":"validation","validationCode":"assert estimation_gap >= 0","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp computed gaps: max(0, gap).","Treat the gap as a buffer count, never a signed offset."],"tags":["event-study","argument-validation"],"backgroundTag":"argument-range-validation","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}