HKUDS/Vibe-Trading · error · ValueError
estimation_window must be at least {MIN_ESTIMATION_OBSERVATI
Error message
estimation_window must be at least {MIN_ESTIMATION_OBSERVATIONS}, got {estimation_window} What it means
event_study enforces that estimation_window (its length in periods) is at least MIN_ESTIMATION_OBSERVATIONS, the same floor estimate_market_model applies to finite observations. A shorter window cannot yield reliable alpha/beta or residual variance estimates.
Source
Thrown at agent/src/quantlib/eventstudy.py:351
Returns:
An :class:`EventStudyResult`. Events that cannot be measured -- unknown
symbol, event date before the frame starts, not enough estimation rows,
an all-NaN window -- appear in ``dropped`` with a reason instead of
being silently skipped.
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))View on GitHub (pinned to 80ffdda44c)
Solutions
- Raise estimation_window to at least MIN_ESTIMATION_OBSERVATIONS (check the constant in agent/src/quantlib/eventstudy.py).
- If history is genuinely short, event_study cannot run; use a different benchmark or drop the event.
Example fix
# before result = event_study(..., estimation_window=20) # after from quantlib.eventstudy import MIN_ESTIMATION_OBSERVATIONS result = event_study(..., estimation_window=max(MIN_ESTIMATION_OBSERVATIONS, 20))
Defensive patterns
Strategy: validation
Validate before calling
from quantlib.eventstudy import MIN_ESTIMATION_OBSERVATIONS assert estimation_window >= MIN_ESTIMATION_OBSERVATIONS
Prevention
- Import the constant rather than hard-coding the floor.
- Ensure the returns history extends at least estimation_window + gap + |window start| periods before each event.
When it happens
Trigger: Passing estimation_window=10 when the minimum is larger (e.g. 30), often while tuning for short-history assets or trying to speed up tests.
Common situations: Optimising runtime by shrinking windows, backtesting newly listed tickers with limited history, or a config default copied from another library with a lower floor.
Related errors
- estimation window needs at least {MIN_ESTIMATION_OBSERVATION
- event_window start must be <= end, got {event_window}
- estimation_gap must be >= 0, got {estimation_gap}
- n_folds must be at least {MIN_FOLDS}, got {n_folds}
- {n_samples} samples cannot make {n_folds} folds
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/874138b15e5becd8.
Report an issue: GitHub.