{"record":{"id":"aa005cdad2ec9774","repo":"HKUDS/Vibe-Trading","slug":"comps-enterprise-value-market-cap-must-be-a-finit","errorCode":null,"errorMessage":"comps.enterprise_value: market_cap must be a finite number, got {market_cap!r}","messagePattern":"comps\\.enterprise_value: market_cap must be a finite number, got (.+?)","errorType":"exception","errorClass":"ValuationError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/comps.py","lineNumber":498,"sourceCode":"        MissingInputError: If `market_cap`, `total_debt` or\n            `cash_and_equivalents` is absent.\n        ValuationError: If `market_cap` or any supplied bridge line is not a\n            finite number.\n    \"\"\"\n    require_inputs(\n        {\n            \"market_cap\": market_cap,\n            \"total_debt\": total_debt,\n            \"cash_and_equivalents\": cash_and_equivalents,\n        },\n        (\"market_cap\", \"total_debt\", \"cash_and_equivalents\"),\n        \"comps.enterprise_value\",\n    )\n    delta, omitted = _bridge_delta(\n        total_debt, cash_and_equivalents, minority_interest, preferred_stock, investments_in_associates\n    )\n    if not math.isfinite(market_cap):\n        raise ValuationError(\n            f\"comps.enterprise_value: market_cap must be a finite number, got {market_cap!r}\"\n        )\n    ev = float(market_cap) + delta\n    return EVBridgeResult(\n        direction=\"equity_to_ev\",\n        equity_value=float(market_cap),\n        enterprise_value=ev,\n        total_debt=float(total_debt),\n        cash_and_equivalents=float(cash_and_equivalents),\n        minority_interest=minority_interest,\n        preferred_stock=preferred_stock,\n        investments_in_associates=investments_in_associates,\n        omitted_components=omitted,\n    )\n\n\ndef equity_value_from_enterprise_value(\n    *,","sourceCodeStart":480,"sourceCodeEnd":516,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/comps.py#L480-L516","documentation":"enterprise_value validates that market_cap is finite before adding the bridge delta. A NaN or infinite market cap (the anchor of the whole EV computation) would make every downstream multiple meaningless, so it is rejected.","triggerScenarios":"Calling enterprise_value(market_cap=math.nan) or with inf; commonly a market cap computed as price * shares where shares is NaN, or a ' MISSING' string converted badly.","commonSituations":"Price feed gaps producing NaN; share counts of 0 combined with inf prices; API responses with null market cap coerced to NaN.","solutions":["Validate market cap at its source (price * shares) with a finite check.","Backfill or drop the peer whose market cap is unavailable.","Guard before calling: if not math.isfinite(market_cap): skip/exclude the peer."],"exampleFix":"# before\nev = enterprise_value(price * shares, ...)  # shares = nan\n\n# after\nmarket_cap = price * shares\nif not math.isfinite(market_cap):\n    raise ValueError(f'bad market cap for {ticker}')\nev = enterprise_value(market_cap, ...)","handlingStrategy":"validation","validationCode":"if market_cap is None or not math.isfinite(market_cap):\n    raise ValueError(f'bad market cap: {market_cap!r}')","typeGuard":"def is_finite_number(v):\n    return isinstance(v, (int, float)) and math.isfinite(v)","tryCatchPattern":"try:\n    ev = enterprise_value(market_cap, ...)\nexcept ValuationError:\n    skip_peer(peer)  # excluded from the comp set","preventionTips":["Check price*shares for finiteness at computation time","Exclude peers with missing market data before valuation"],"tags":["valuation","market-cap","nan","finite-check"],"backgroundTag":"nan-input-validation","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}