HKUDS/Vibe-Trading · error · ValueError
market_returns is missing {len(missing_market)} label(s) pre
Error message
market_returns is missing {len(missing_market)} label(s) present in returns; align them before calling What it means
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.
Source
Thrown at agent/src/quantlib/eventstudy.py:363
start, end = event_window
if start > end:
raise ValueError(f"event_window start must be <= end, got {event_window}")
if estimation_gap < 0:
raise ValueError(f"estimation_gap must be >= 0, got {estimation_gap}")
if estimation_window < MIN_ESTIMATION_OBSERVATIONS:
raise ValueError(
f"estimation_window must be at least {MIN_ESTIMATION_OBSERVATIONS}, "
f"got {estimation_window}"
)
if model not in NORMAL_RETURN_MODELS:
raise ValueError(f"model must be one of {NORMAL_RETURN_MODELS}, got {model!r}")
if not events:
raise ValueError("events is empty")
index = returns.index
missing_market = index.difference(market_returns.index)
if len(missing_market):
raise ValueError(
f"market_returns is missing {len(missing_market)} label(s) present in "
"returns; align them before calling"
)
market_aligned = market_returns.reindex(index)
relative_days = list(range(start, end + 1))
window_len = len(relative_days)
outcomes: list[EventOutcome] = []
dropped: list[tuple[str, object, str]] = []
for symbol, event_date in events:
if symbol not in returns.columns:
dropped.append((symbol, event_date, "symbol not in returns frame"))
continue
position = int(index.searchsorted(event_date, side="right")) - 1
if position < 0:View on GitHub (pinned to 80ffdda44c)
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.
Example fix
# before result = event_study(returns, market_returns, events, (0, 0)) # after market = market_returns.reindex(returns.index) result = event_study(returns, market, events, (0, 0))
Defensive patterns
Strategy: validation
Validate before calling
missing = returns.index.difference(market_returns.index) assert len(missing) == 0, missing[:5]
Prevention
- Standardise both series to the same DatetimeIndex (tz, freq) at load time.
- reindex market onto returns before any event-study call.
When it happens
Trigger: 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.
Common situations: Merging data from different vendors with different calendars, forgetting to reindex after a concat, timezone-aware vs naive timestamps, or string dates parsed differently.
Related errors
- market_caps is missing {len(missing)} asset(s) present in va
- find_hedge_ratio needs y and x sharing one index
- returns and var must cover exactly the same labels; {len(onl
- need >= {min_bars} bars in each window (calm={len(calm)}, ev
- ts_max window must be >= 1, got {n}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/70cd3534675e13a5.
Report an issue: GitHub.