HKUDS/Vibe-Trading · error · ValueError
events is empty
Error message
events is empty
What it means
event_study requires a non-empty events collection; with no events there is nothing to aggregate into AAR/CAAR and statistics would be undefined, so it fails fast with a clear message.
Source
Thrown at agent/src/quantlib/eventstudy.py:358
Raises:
ValueError: If the window bounds are inconsistent, ``estimation_gap`` is
negative, ``model`` is unknown, the market series does not cover the
frame's index, or no event at all could be measured.
"""
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:View on GitHub (pinned to 80ffdda44c)
Solutions
- Guard before calling: if not events: skip/log.
- Widen the event date selection or fix the upstream filter that emptied the collection.
Example fix
# before result = event_study(returns, market, events, (0, 0)) # after result = event_study(returns, market, events, (0, 0)) if events else None
Defensive patterns
Strategy: validation
Validate before calling
if not events:
raise SystemExit("no events to study") Type guard
def has_events(events) -> bool:
return bool(events) Prevention
- Filter empty event collections in the data-prep stage.
- Log event counts per run to catch silent upstream filtering.
When it happens
Trigger: Passing events=[] or an empty dict/list, usually because an upstream filter (e.g. date range or universe screen) removed all events.
Common situations: Backtesting a period with no qualifying event dates, an events DataFrame filtered to zero rows, or a loop iteration where the last chunk is empty.
Related errors
- brinson_fachler needs at least one sector
- label_end_times is empty
- groups array cannot be empty
- estimation window needs at least {MIN_ESTIMATION_OBSERVATION
- market returns are constant over the estimation window, so b
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/6312548061d23aac.
Report an issue: GitHub.