HKUDS/Vibe-Trading · error · ValueError
index_levels has more than one entry for {day}; resolve the
Error message
index_levels has more than one entry for {day}; resolve the duplicate before calling, rather than have this function guess which one is authoritative What it means
When building the date->level lookup, two index entries normalize to the same calendar date (e.g. timestamps '2024-03-01' and '2024-03-01 14:30'). The library refuses to guess which level is authoritative, so it raises instead of taking first/last.
Source
Thrown at agent/src/quantlib/fundmath.py:1377
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"
)
lookup[day] = level
return lookup
def _index_level_at(
lookup: Mapping[_dt.date, float], day: _dt.date, *, flow_description: str
) -> float:
"""Look up one date in an index lookup table, or fail loudly.View on GitHub (pinned to 80ffdda44c)
Solutions
- Resample to daily and take one value per day: levels.resample('1D').last().dropna()
- Deduplicate: levels = levels[~index.duplicated(keep='last')] after normalizing dates
- Drop the time component: levels.index = levels.index.normalize()
Example fix
# before
ks_pme(series, hourly_close_series) # multiple entries per day
# after
daily = hourly_close_series.resample("1D").last().dropna()
ks_pme(series, daily) Defensive patterns
Strategy: validation
Validate before calling
levels = levels[~levels.index.duplicated(keep='last')] levels.index = levels.index.normalize()
Prevention
- Resample intraday benchmark data to daily before PME
- Deduplicate concatenated benchmark sources
When it happens
Trigger: Passing an index_levels Series with intraday timestamps for the same day (hourly bars), or duplicated dates from concatenating overlapping data sources.
Common situations: Feeding daily OHLCV with a datetime index at 09:30/16:00; concatenating two benchmark files with overlapping periods; timezone shifts creating same-day duplicates.
Related errors
- index_levels must be a pandas Series of index levels indexed
- index_levels is empty; a public market equivalent needs a be
- index level on {day} is {raw_level!r}; index levels must be
- index_levels has no entry for {day} (needed for {flow_descri
- style drift needs at least 2 dates, got {exposure_history.sh
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/cb2f711cab9918c0.
Report an issue: GitHub.