HKUDS/Vibe-Trading · error · ValueError
index level on is ; index levels must be finite and…
Error message
index level on {day} is {raw_level!r}; index levels must be finite and positive to serve as a growth-factor denominator What it means
Each benchmark level serves as a growth-factor denominator (price ratios between dates), so it must be finite and strictly positive. NaN, inf, zero, or negative levels would produce undefined or explosive PME factors.
Solutions
- Drop or interpolate bad values before calling: levels = levels.dropna(); assert (levels > 0).all()
- Fix the vendor placeholder convention (0 or -1 for missing) during ingest
- Validate positivity once at load time
Example fix
# before ks_pme(series, raw_levels) # contains NaN and 0.0 # after clean = raw_levels.dropna() clean = clean[clean > 0] ks_pme(series, clean)
Defensive patterns
Strategy: validation
Validate before calling
levels = levels.dropna() levels = levels[numpy.isfinite(levels) & (levels > 0)] assert not levels.empty
Prevention
- Scrub NaN/0/-1 vendor placeholders during ingest
- Assert positivity once at load time
When it happens
Trigger: Passing an index_levels Series containing NaN (missing close), 0.0 (placeholder fill), inf, or a negative value from a bad adjust factor.
Common situations: Un-filled holidays left as NaN; adjusted-price series with a zero from a bad split adjustment; placeholder zeros from a data vendor; -1 sentinels for missing data.
Related errors
- index_levels has more than one entry for
- index_levels has no entry for
- index_levels is empty; a public market equivalent needs a…
- index_levels must be a pandas Series of index levels…
- no observation has a finite return and a finite var
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/ac4e2c9889761f41.
Report an issue: GitHub.
Appendix: source
Thrown at agent/src/quantlib/fundmath.py:1384
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.
Args:
lookup: Table built by :func:`_index_levels_by_date`.
day: Date to look up.
flow_description: Human-readable description of what needed this
date, quoted in the error message.
View on GitHub (pinned to 80ffdda44c)