{"record":{"id":"cf5285a5de8f1016","repo":"HKUDS/Vibe-Trading","slug":"management-fee-rate-must-be-a-decimal-fraction-in","errorCode":null,"errorMessage":"management_fee_rate must be a decimal fraction in [0, 1] (0.02 means 2%), got {self.management_fee_rate!r}","messagePattern":"management_fee_rate must be a decimal fraction in \\[0, 1\\] \\(0\\.02 means 2%\\), got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/models.py","lineNumber":322,"sourceCode":"            raise ValueError(\n                f\"unknown structure {self.structure!r}; expected one of: {valid}\"\n            ) from exc\n        if self.vintage_year is not None and not 1800 <= int(self.vintage_year) <= 2200:\n            raise ValueError(\n                f\"vintage_year={self.vintage_year!r} is outside the plausible \"\n                \"range 1800-2200\"\n            )\n        if self.commitment is not None:\n            if float(self.commitment) < 0:\n                raise ValueError(\n                    f\"commitment must be non-negative (it is a size, not a signed \"\n                    f\"cash flow), got {self.commitment!r}\"\n                )\n            object.__setattr__(self, \"commitment\", float(self.commitment))\n        if self.management_fee_rate is not None:\n            rate = float(self.management_fee_rate)\n            if not 0.0 <= rate <= 1.0:\n                raise ValueError(\n                    f\"management_fee_rate must be a decimal fraction in [0, 1] \"\n                    f\"(0.02 means 2%), got {self.management_fee_rate!r}\"\n                )\n            object.__setattr__(self, \"management_fee_rate\", rate)\n\n\n@dataclass(frozen=True)\nclass Bond(Instrument):\n    \"\"\"A debt instrument paying scheduled coupons and returning principal.\n\n    Attributes:\n        face_value: Redemption amount per unit, in ``currency``. Positive.\n        coupon_rate: Annual coupon as a decimal fraction (``0.05`` means 5%),\n            not a percentage. Zero marks a zero-coupon bond.\n        coupon_frequency: Coupon payments per year. Zero is only valid for a\n            zero-coupon bond.\n        maturity_date: Redemption date, when known.\n        day_count: Day-count convention label, e.g. ``\"30/360\"`` or","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/models.py#L304-L340","documentation":"Fund.__post_init__ validates management_fee_rate as a decimal fraction in [0, 1] — 0.02 means 2%. A rate outside that interval (typically 2.0 meaning 2%) is rejected to prevent hundred-fold fee errors.","triggerScenarios":"Fund(..., management_fee_rate=2.0) (percentage instead of fraction), management_fee_rate=150 (basis points), or a negative rate. Values like 0.02 pass; 2 fails only if >1.0, negatives fail the lower bound.","commonSituations":"User input or vendor data expressing fees in percent; basis-point values (200 bp) passed raw; mixing conventions between a UI showing '2%' and the model expecting 0.02.","solutions":["Divide percentages by 100 before passing: 2% -> 0.02","If the value is in basis points, divide by 10_000","Add a UI/ingest conversion step so the model always receives the decimal fraction"],"exampleFix":"# before\nFund(instrument_id='f1', management_fee_rate=2.0)  # meant 2%\n\n# after\nFund(instrument_id='f1', management_fee_rate=0.02)","handlingStrategy":"validation","validationCode":"rate = row.get('management_fee_rate')\nif rate is not None:\n    rate = float(rate)\n    if rate > 1.0:\n        rate /= 100.0  # percent -> fraction\nFund(..., management_fee_rate=rate)","typeGuard":"def is_valid_fee_rate(r) -> bool:\n    return r is None or 0.0 <= float(r) <= 1.0","tryCatchPattern":null,"preventionTips":["Agree on a fraction convention across UI, API, and storage","Convert percent/bps inputs at the system boundary","Document 0.02 = 2% wherever fees are configured"],"tags":["python","dataclass","unit-conversion","funds","rate-validation"],"backgroundTag":"percent-vs-fraction-unit-error","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}