HKUDS/Vibe-Trading · error · ValueError
index_levels is empty; a public market equivalent needs a be
Error message
index_levels is empty; a public market equivalent needs a benchmark to compare against
What it means
A public-market-equivalent calculation needs at least one benchmark level to compute growth factors against; an empty index_levels Series is refused rather than producing NaN results.
Source
Thrown at agent/src/quantlib/fundmath.py:1369
the index's level on each date (a price or a total-return index
value, not a return).
Returns:
Mapping from ``datetime.date`` to the index level on that date.
Raises:
TypeError: If ``index_levels`` is not a ``pandas.Series``.
ValueError: If it is empty, a level is not finite and positive, or two
entries normalize to the same date (an ambiguous lookup, refused
rather than guessed at by taking the first or last).
"""
if not isinstance(index_levels, pd.Series):
raise TypeError(
"index_levels must be a pandas Series of index levels indexed by "
f"date, got {type(index_levels).__name__}"
)
if index_levels.empty:
raise ValueError(
"index_levels is empty; a public market equivalent needs a "
"benchmark to compare against"
)
lookup: dict[_dt.date, float] = {}
for raw_date, raw_level in index_levels.items():
day = normalize_date(raw_date, field_name="index_levels date")
if day in lookup:
raise ValueError(
f"index_levels has more than one entry for {day}; resolve the "
"duplicate before calling, rather than have this function "
"guess which one is authoritative"
)
level = float(raw_level)
if not math.isfinite(level) or level <= 0.0:
raise ValueError(
f"index level on {day} is {raw_level!r}; index levels must be "
"finite and positive to serve as a growth-factor denominator"
)View on GitHub (pinned to 80ffdda44c)
Solutions
- Inspect why the benchmark series is empty (symbol, date range, filter)
- Widen the date range to cover all cash-flow dates
- Skip the PME calc for assets with no benchmark data rather than calling it
Example fix
# before
levels = bench[bench.index >= "2025-01-01"]["close"] # empty if data ends 2024
ks_pme(series, levels)
# after
levels = bench["close"].dropna()
if not levels.empty:
ks_pme(series, levels) Defensive patterns
Strategy: validation
Validate before calling
if index_levels.empty:
raise DataAvailabilityError("benchmark series is empty") Prevention
- Validate benchmark downloads for non-emptiness at ingest
- Alert on zero-row vendor responses
When it happens
Trigger: Calling ks_pme/pme_plus/direct_alpha with index_levels=pd.Series(dtype=float) — e.g. a benchmark query whose date filter matched nothing.
Common situations: Ticker symbol typo yielding an empty download; date-range filter that excludes all rows; empty CSV; upstream API returning zero rows.
Related errors
- index_levels must be a pandas Series of index levels indexed
- index_levels has more than one entry for {day}; resolve the
- index level on {day} is {raw_level!r}; index levels must be
- index_levels has no entry for {day} (needed for {flow_descri
- run_bench_strict requires random_control to be passed explic
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/459067b673825bf5.
Report an issue: GitHub.