{"record":{"id":"70cd3534675e13a5","repo":"HKUDS/Vibe-Trading","slug":"market-returns-is-missing-len-missing-market-la","errorCode":null,"errorMessage":"market_returns is missing {len(missing_market)} label(s) present in returns; align them before calling","messagePattern":"market_returns is missing (.+?) label\\(s\\) present in returns; align them before calling","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/eventstudy.py","lineNumber":363,"sourceCode":"    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))\n    window_len = len(relative_days)\n\n    outcomes: list[EventOutcome] = []\n    dropped: list[tuple[str, object, str]] = []\n\n    for symbol, event_date in events:\n        if symbol not in returns.columns:\n            dropped.append((symbol, event_date, \"symbol not in returns frame\"))\n            continue\n\n        position = int(index.searchsorted(event_date, side=\"right\")) - 1\n        if position < 0:","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/eventstudy.py#L345-L381","documentation":"event_study aligns market_returns onto returns.index via reindex; if any label (date) present in the asset returns is absent from the market index, the market return for that day would become NaN and silently corrupt estimates, so the mismatch is raised instead.","triggerScenarios":"Asset returns indexed by business days while the market index uses calendar days, a market series ending earlier than the asset series, or different date tz/normalisation producing unequal Timestamps.","commonSituations":"Merging data from different vendors with different calendars, forgetting to reindex after a concat, timezone-aware vs naive timestamps, or string dates parsed differently.","solutions":["Align first: market = market_returns.reindex(returns.index).","Fix the index construction: normalise both to the same DatetimeIndex (same tz, same frequency) before calling."],"exampleFix":"# before\nresult = event_study(returns, market_returns, events, (0, 0))\n# after\nmarket = market_returns.reindex(returns.index)\nresult = event_study(returns, market, events, (0, 0))","handlingStrategy":"validation","validationCode":"missing = returns.index.difference(market_returns.index)\nassert len(missing) == 0, missing[:5]","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardise both series to the same DatetimeIndex (tz, freq) at load time.","reindex market onto returns before any event-study call."],"tags":["event-study","pandas","index-alignment"],"backgroundTag":"index-misalignment","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}