{"record":{"id":"ac4e2c9889761f41","repo":"HKUDS/Vibe-Trading","slug":"index-level-on-day-is-raw-level-r-index-level","errorCode":null,"errorMessage":"index level on {day} is {raw_level!r}; index levels must be finite and positive to serve as a growth-factor denominator","messagePattern":"index level on (.+?) is (.+?); index levels must be finite and positive to serve as a growth-factor denominator","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/fundmath.py","lineNumber":1384,"sourceCode":"            f\"date, got {type(index_levels).__name__}\"\n        )\n    if index_levels.empty:\n        raise ValueError(\n            \"index_levels is empty; a public market equivalent needs a \"\n            \"benchmark to compare against\"\n        )\n    lookup: dict[_dt.date, float] = {}\n    for raw_date, raw_level in index_levels.items():\n        day = normalize_date(raw_date, field_name=\"index_levels date\")\n        if day in lookup:\n            raise ValueError(\n                f\"index_levels has more than one entry for {day}; resolve the \"\n                \"duplicate before calling, rather than have this function \"\n                \"guess which one is authoritative\"\n            )\n        level = float(raw_level)\n        if not math.isfinite(level) or level <= 0.0:\n            raise ValueError(\n                f\"index level on {day} is {raw_level!r}; index levels must be \"\n                \"finite and positive to serve as a growth-factor denominator\"\n            )\n        lookup[day] = level\n    return lookup\n\n\ndef _index_level_at(\n    lookup: Mapping[_dt.date, float], day: _dt.date, *, flow_description: str\n) -> float:\n    \"\"\"Look up one date in an index lookup table, or fail loudly.\n\n    Args:\n        lookup: Table built by :func:`_index_levels_by_date`.\n        day: Date to look up.\n        flow_description: Human-readable description of what needed this\n            date, quoted in the error message.\n","sourceCodeStart":1366,"sourceCodeEnd":1402,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/fundmath.py#L1366-L1402","documentation":"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.","triggerScenarios":"Passing an index_levels Series containing NaN (missing close), 0.0 (placeholder fill), inf, or a negative value from a bad adjust factor.","commonSituations":"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.","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"],"exampleFix":"# before\nks_pme(series, raw_levels)  # contains NaN and 0.0\n\n# after\nclean = raw_levels.dropna()\nclean = clean[clean > 0]\nks_pme(series, clean)","handlingStrategy":"validation","validationCode":"levels = levels.dropna()\nlevels = levels[numpy.isfinite(levels) & (levels > 0)]\nassert not levels.empty","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Scrub NaN/0/-1 vendor placeholders during ingest","Assert positivity once at load time"],"tags":["fund-math","pme","nan","data-quality"],"backgroundTag":"invalid-data-values","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}