{"record":{"id":"2995fb4ca9e7a457","repo":"HKUDS/Vibe-Trading","slug":"compounding-compounding-r-is-not-one-of-preferr","errorCode":null,"errorMessage":"compounding={compounding!r} is not one of {PREFERRED_COMPOUNDING}","messagePattern":"compounding=(.+?) is not one of (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/fundmath.py","lineNumber":963,"sourceCode":"            ``rate * years``.\n        days_per_year: Day basis for the year fraction.\n        contribution_kinds: Kind labels counted as capital in.\n\n    Returns:\n        The preferred return owed, as a positive magnitude excluding the return\n        of capital itself. ``0.0`` when nothing has been drawn.\n\n    Raises:\n        TypeError: If ``series`` is not a ``CashFlowSeries``.\n        ValueError: If the rate is negative, the compounding convention is\n            unknown, ``as_of`` precedes a contribution, or ``as_of`` is omitted\n            for an empty series.\n    \"\"\"\n    _require_series(series)\n    if rate < 0.0:\n        raise ValueError(f\"preferred rate must be non-negative, got {rate!r}\")\n    if compounding not in PREFERRED_COMPOUNDING:\n        raise ValueError(\n            f\"compounding={compounding!r} is not one of {PREFERRED_COMPOUNDING}\"\n        )\n    if days_per_year <= 0:\n        raise ValueError(f\"days_per_year must be positive, got {days_per_year!r}\")\n\n    contributions = tuple(series.filter(kind=contribution_kinds))\n    if not contributions:\n        return 0.0\n\n    if as_of is None:\n        if series.is_empty:\n            raise ValueError(\"as_of is required for an empty series\")\n        measurement = max(series.dates())\n    else:\n        measurement = normalize_date(as_of, field_name=\"as_of\")\n\n    total = 0.0\n    for flow in contributions:","sourceCodeStart":945,"sourceCodeEnd":981,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/fundmath.py#L945-L981","documentation":"The preferred-return calculation only supports the compounding conventions enumerated in PREFERRED_COMPOUNDING (typically 'simple' and 'compound'). Any other string is rejected up front rather than silently falling back to a default.","triggerScenarios":"Calling preferred_return_amount(series, rate=0.08, compounding=\"monthly\") or \"continuous\", or a typo like \"compond\".","commonSituations":"Assuming arbitrary compounding frequencies are supported; passing a value from user config without whitelisting it; typo in the literal.","solutions":["Use one of the accepted values: inspect PREFERRED_COMPOUNDING (e.g. 'simple' or 'compound')","Whitelist/validate user-supplied compounding strings before passing them through","For custom frequencies, compute the preferred return yourself outside this API"],"exampleFix":"# before\npreferred_return_amount(series, rate=0.08, compounding=\"monthly\")\n\n# after\npreferred_return_amount(series, rate=0.08, compounding=\"compound\")","handlingStrategy":"type-guard","validationCode":"from agent.src.quantlib.fundmath import PREFERRED_COMPOUNDING\nassert compounding in PREFERRED_COMPOUNDING","typeGuard":"def is_valid_compounding(c: str) -> bool:\n    return c in PREFERRED_COMPOUNDING","tryCatchPattern":null,"preventionTips":["Whitelist user input against PREFERRED_COMPOUNDING before calling","Fail fast on unknown compounding strings in config parsing"],"tags":["fund-math","preferred-return","compounding","enum-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}