{"record":{"id":"b1c0fd4886df2161","repo":"HKUDS/Vibe-Trading","slug":"paid-in-capital-is-paid-in-r-a-capital-multiple","errorCode":null,"errorMessage":"paid-in capital is {paid_in!r}; a capital multiple is undefined with no capital drawn. Confirm the contribution kinds match the file.","messagePattern":"paid-in capital is (.+?); a capital multiple is undefined with no capital drawn\\. Confirm the contribution kinds match the file\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/fundmath.py","lineNumber":710,"sourceCode":"        )\n    return value\n\n\ndef _require_paid_in(paid_in: float) -> float:\n    \"\"\"Reject a zero or negative denominator for a capital multiple.\n\n    Args:\n        paid_in: Paid-in capital as a positive magnitude.\n\n    Returns:\n        The same value.\n\n    Raises:\n        ValueError: If it is not strictly positive -- a multiple of nothing is\n            undefined, and returning ``inf`` or ``0`` would both be wrong.\n    \"\"\"\n    if paid_in <= 0.0:\n        raise ValueError(\n            f\"paid-in capital is {paid_in!r}; a capital multiple is undefined \"\n            \"with no capital drawn. Confirm the contribution kinds match the file.\"\n        )\n    return paid_in\n\n\ndef dpi(\n    series: CashFlowSeries,\n    *,\n    contribution_kinds: Iterable[str] = CONTRIBUTION_KINDS,\n    distribution_kinds: Iterable[str] = DISTRIBUTION_KINDS,\n) -> float:\n    \"\"\"Distributions to paid-in: realised cash returned per unit drawn.\n\n    Args:\n        series: The cash flows.\n        contribution_kinds: Kind labels counted as capital in.\n        distribution_kinds: Kind labels counted as capital out.","sourceCodeStart":692,"sourceCodeEnd":728,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/fundmath.py#L692-L728","documentation":"Capital multiples (DPI, RVPI, TVPI, MOIC) divide by paid-in capital, which is undefined when nothing has been drawn. The guard rejects paid_in <= 0 instead of returning inf or 0, either of which would corrupt downstream analytics.","triggerScenarios":"Calling dpi/rvpi/tvpi/moic/fund_multiples with paid_in=0.0 or a negative sum, typically because the series contains no flows whose kind matches the configured contribution kinds.","commonSituations":"A feed or CSV where contributions are labeled 'drawdown' or 'capital_call' but the code expects 'contribution'; a brand-new fund with no draws yet; filtered series that accidentally excluded contributions.","solutions":["Inspect series.filter(kind=contribution_kinds) — verify your contribution kind strings match what the file actually uses","Pass the correct contribution_kinds argument matching your data's labels","If the fund genuinely has no draws yet, skip the multiple rather than calling it"],"exampleFix":"# before\npaid_in = sum(-f.amount for f in series.filter(kind=(\"contribution\",)))\ndpi(series, paid_in)  # raises if labels differ\n\n# after\nCONTRIB_KINDS = (\"contribution\", \"capital_call\", \"drawdown\")\npaid_in = sum(-f.amount for f in series.filter(kind=CONTRIB_KINDS))\nif paid_in > 0:\n    print(dpi(series, paid_in))","handlingStrategy":"validation","validationCode":"paid_in = sum(-f.amount for f in series.filter(kind=CONTRIB_KINDS))\nif paid_in <= 0:\n    return None  # no multiples for undrawn funds","typeGuard":null,"tryCatchPattern":"try:\n    dpi(series, paid_in)\nexcept ValueError as e:\n    if \"paid-in capital\" in str(e):\n        logging.warning(\"skipping multiple: no capital drawn\")\n    else:\n        raise","preventionTips":["Centralize contribution-kind constants shared by loader and analytics","Unit-test kind labels against a sample file","Guard batch loops with paid_in > 0 checks"],"tags":["fund-math","paid-in-capital","dpi","moic","configuration"],"backgroundTag":"division-by-zero-guard","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}