{"record":{"id":"69a04348e2565f64","repo":"HKUDS/Vibe-Trading","slug":"comps-run-comps-unknown-calendarisation-policy-c","errorCode":null,"errorMessage":"comps.run_comps: unknown calendarisation_policy {calendarisation_policy!r}, must be one of {CALENDARISATION_POLICIES}","messagePattern":"comps\\.run_comps: unknown calendarisation_policy (.+?), must be one of (.+?)","errorType":"exception","errorClass":"ValuationError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/comps.py","lineNumber":1169,"sourceCode":"            input (see :mod:`.contracts`). This is distinct from the\n            boundary case where peers were supplied but every one of them\n            was later excluded from a given multiple by its own non-positive\n            denominator -- that case returns a normal `CompsResult` whose\n            `distributions[name]` is empty and carries a warning, because\n            the peers themselves were not missing, only their multiples were\n            not computable.\n        ValuationError: If `calendarisation_policy` is not recognised, if\n            two peers share a name, or if peers/target do not all declare\n            the same `eps_basis` (mixing GAAP and adjusted EPS across the\n            comp set would skew the P/E distribution by whatever one-time\n            items the adjustment removes, the same kind of silent distortion\n            the calendarisation-policy rule exists to prevent).\n        MissingInputError: (propagated from `calendarise_metric`) if any\n            peer's or the target's fiscal-period data lacks a field\n            `calendarisation_policy` needs.\n    \"\"\"\n    if calendarisation_policy not in CALENDARISATION_POLICIES:\n        raise ValuationError(\n            f\"comps.run_comps: unknown calendarisation_policy {calendarisation_policy!r}, \"\n            f\"must be one of {CALENDARISATION_POLICIES}\"\n        )\n    if len(peers) == 0:\n        raise MissingInputError((\"peers\",), \"comps.run_comps\")\n\n    names = [peer.name for peer in peers]\n    if len(set(names)) != len(names):\n        raise ValuationError(f\"comps.run_comps: duplicate peer names in {names}\")\n\n    all_bases = {peer.eps_basis for peer in peers} | {target.eps_basis}\n    if len(all_bases) > 1:\n        raise ValuationError(\n            \"comps.run_comps: mixed eps_basis across the comp set \"\n            f\"{sorted(all_bases)} -- every peer and the target must declare the \"\n            \"same EPS basis, or the P/E distribution mixes GAAP and adjusted \"\n            \"earnings\"\n        )","sourceCodeStart":1151,"sourceCodeEnd":1187,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/comps.py#L1151-L1187","documentation":"run_comps validates calendarisation_policy against CALENDARISATION_POLICIES (e.g. 'ltm', 'ntm'/calendar-year styles). An unknown policy string is rejected because choosing the fiscal-alignment rule silently changes every multiple.","triggerScenarios":"Calling run_comps(calendarisation_policy='LTM') (case mismatch), 'fy', 'ttm', or a typo, or passing None when the argument became required.","commonSituations":"Config-driven policy strings drifting from the library's vocabulary after a version upgrade renames/adds policies; copy-pasted examples with outdated policy names.","solutions":["Import CALENDARISATION_POLICIES and validate/select from it directly.","Check the module constant to see the exact accepted strings in your installed version.","Normalize config input (strip/lower) and fail loudly at config-load time."],"exampleFix":"# before\nresult = run_comps(target, peers, calendarisation_policy='ttm')\n\n# after\nfrom quantlib.valuation.comps import CALENDARISATION_POLICIES\npolicy = policy.strip().lower()\nassert policy in CALENDARISATION_POLICIES, CALENDARISATION_POLICIES\nresult = run_comps(target, peers, calendarisation_policy=policy)","handlingStrategy":"type-guard","validationCode":"from quantlib.valuation.comps import CALENDARISATION_POLICIES\npolicy = policy.strip().lower()\nif policy not in CALENDARISATION_POLICIES:\n    raise ValueError(f'policy must be one of {CALENDARISATION_POLICIES}')","typeGuard":"def valid_policy(p):\n    from quantlib.valuation.comps import CALENDARISATION_POLICIES\n    return p in CALENDARISATION_POLICIES","tryCatchPattern":null,"preventionTips":["Validate config-driven policy strings at load time","Pin and review CALENDARISATION_POLICIES on library upgrades"],"tags":["valuation","policy","enum","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}