{"record":{"id":"a6f907f8dfb95c77","repo":"HKUDS/Vibe-Trading","slug":"pre-translated-true-asserts-the-flows-were-already","errorCode":null,"errorMessage":"pre_translated=True asserts the flows were already converted, so the reporting currency must be named explicitly via currency=...","messagePattern":"pre_translated=True asserts the flows were already converted, so the reporting currency must be named explicitly via currency=\\.\\.\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/cashflow.py","lineNumber":242,"sourceCode":"            CurrencyMismatchError: If the flows span multiple currencies while\n                ``pre_translated`` is False, or contradict a declared currency.\n        \"\"\"\n        flows = tuple(self.flows)\n        for item in flows:\n            if not isinstance(item, CashFlow):\n                raise ValueError(\n                    f\"CashFlowSeries members must be CashFlow, got \"\n                    f\"{type(item).__name__}\"\n                )\n\n        declared = (\n            normalize_currency(self.currency) if self.currency is not None else None\n        )\n        present = {flow.currency for flow in flows}\n\n        if self.pre_translated:\n            if declared is None:\n                raise ValueError(\n                    \"pre_translated=True asserts the flows were already converted, \"\n                    \"so the reporting currency must be named explicitly via \"\n                    \"currency=...\"\n                )\n        else:\n            if len(present) > 1:\n                raise CurrencyMismatchError(\n                    \"cash flows span multiple currencies \"\n                    f\"({', '.join(sorted(present))}); convert them first and pass \"\n                    \"pre_translated=True with the reporting currency, rather than \"\n                    \"summing across currencies\"\n                )\n            if declared is None:\n                declared = next(iter(present)) if present else None\n            elif present and declared not in present:\n                raise CurrencyMismatchError(\n                    f\"declared currency {declared!r} does not match the flows' \"\n                    f\"currency {next(iter(present))!r}\"","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/cashflow.py#L224-L260","documentation":"pre_translated=True is an assertion that the flows were already converted to one reporting currency, so the series needs to know which currency that is. Without an explicit currency= argument the claim is unverifiable and construction fails.","triggerScenarios":"CashFlowSeries(flows=already_converted_flows, pre_translated=True) with currency omitted (None).","commonSituations":"Rebuilding a series from a translated output where the currency attribute was dropped; copy-pasting construction code and deleting the currency argument.","solutions":["Pass currency='USD' (the reporting currency) alongside pre_translated=True","If the flows are not yet converted, leave pre_translated at its default and let a single-currency series infer the currency"],"exampleFix":"# before\nCashFlowSeries(flows=flows, pre_translated=True)\n# after\nCashFlowSeries(flows=flows, pre_translated='USD', currency='USD', pre_translated=True)","handlingStrategy":"validation","validationCode":"currency = currency or infer_reporting_currency(flows)\nseries = CashFlowSeries(flows=flows, currency=currency, pre_translated=True)","typeGuard":null,"tryCatchPattern":"try:\n    CashFlowSeries(flows=flows, pre_translated=True)\nexcept ValueError as e:\n    if 'reporting currency must be named' in str(e):\n        series = CashFlowSeries(flows=flows, currency=REPORTING_CCY, pre_translated=True)","preventionTips":["Pair pre_translated=True with an explicit currency= by convention","Wrap series construction in a helper that always supplies the reporting currency"],"tags":["python","cashflow","currency","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}