{"record":{"id":"11b9e63234d9e603","repo":"HKUDS/Vibe-Trading","slug":"event-window-start-must-be-end-got-event-wind","errorCode":null,"errorMessage":"event_window start must be <= end, got {event_window}","messagePattern":"event_window start must be <= end, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/eventstudy.py","lineNumber":347,"sourceCode":"        estimation_window: Rows used to fit the normal-return model.\n        estimation_gap: Rows left between the estimation window and the event\n            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\"","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/eventstudy.py#L329-L365","documentation":"event_study validates that the (start, end) tuple defining the event window in relative days is internally consistent: start must not exceed end. A reversed tuple would silently produce an empty window, so it is rejected up front.","triggerScenarios":"Passing event_window=(5, -5) or any tuple where the first element is larger than the second, e.g. mixing up the order of pre-event and post-event bounds.","commonSituations":"Refactoring that swaps tuple elements, computing bounds from user input without ordering them, off-by-one confusion between inclusive/exclusive conventions.","solutions":["Swap the tuple so the earlier relative day comes first: event_window=(start, end) with start <= end.","If bounds come from configuration, normalise them: lo, hi = sorted(event_window)."],"exampleFix":"# before\nresult = event_study(returns, market, events, event_window=(5, -5))\n# after\nlo, hi = sorted(event_window)\nresult = event_study(returns, market, events, event_window=(lo, hi))","handlingStrategy":"validation","validationCode":"start, end = event_window\nassert start <= end","typeGuard":"def is_valid_event_window(w: tuple[int, int]) -> bool:\n    return len(w) == 2 and w[0] <= w[1]","tryCatchPattern":null,"preventionTips":["Normalise windows with sorted() when they come from config.","Document the inclusive (start, end) convention at call sites."],"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"}