{"record":{"id":"a91316d61731cb01","repo":"HKUDS/Vibe-Trading","slug":"cash-flows-span-multiple-currencies-join-so","errorCode":null,"errorMessage":"cash flows span multiple currencies ({', '.join(sorted(present))}); convert them first and pass pre_translated=True with the reporting currency, rather than summing across currencies","messagePattern":"cash flows span multiple currencies \\((.+?)\\); convert them first and pass pre_translated=True with the reporting currency, rather than summing across currencies","errorType":"validation","errorClass":"CurrencyMismatchError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/cashflow.py","lineNumber":249,"sourceCode":"                    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}\"\n                )\n\n        object.__setattr__(self, \"currency\", declared)\n        object.__setattr__(self, \"flows\", tuple(sorted(flows, key=lambda f: f.date)))\n\n    # ─── Access ───\n","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/cashflow.py#L231-L267","documentation":"When pre_translated is False, CashFlowSeries refuses to aggregate flows spanning more than one currency, because summing across currencies produces meaningless numbers. The error lists the offending currencies and tells you to convert first, then declare pre_translated=True with the reporting currency.","triggerScenarios":"CashFlowSeries(flows=[CashFlow(..., currency='EUR'), CashFlow(..., currency='USD')]) without pre_translated.","commonSituations":"Multi-currency brokerage or fund statements loaded raw; appending new flows in a different currency to an existing list; forgetting an FX translation step before aggregation.","solutions":["Translate the flows to one reporting currency with FxRateTable.translate_cashflows, then construct the series with pre_translated=True and currency=<reporting>","If you did translate but kept per-flow currencies, overwrite each flow's currency to the reporting currency before building the series","Split into one series per currency if aggregation across currencies is not intended"],"exampleFix":"# before\nCashFlowSeries(flows=mixed_currency_flows)\n# after\ntable = FxRateTable.from_rates(rates, quote_currency='USD')\ntranslated = table.translate_cashflows(mixed_currency_flows)\nseries = CashFlowSeries(flows=translated, currency='USD', pre_translated=True)","handlingStrategy":"validation","validationCode":"currencies = {f.currency for f in flows}\nif len(currencies) > 1:\n    flows = fx_table.translate_cashflows(flows)\nseries = CashFlowSeries(flows=flows, currency='USD', pre_translated=True)","typeGuard":null,"tryCatchPattern":"from agent.src.entities.cashflow import CurrencyMismatchError\ntry:\n    CashFlowSeries(flows=flows)\nexcept CurrencyMismatchError:\n    flows = fx_table.translate_cashflows(flows)\n    series = CashFlowSeries(flows=flows, currency=fx_table.quote_currency, pre_translated=True)","preventionTips":["Always run FX translation before aggregating multi-currency data","Keep a single reporting currency configured app-wide"],"tags":["python","cashflow","currency-mismatch"],"backgroundTag":"currency-mismatch","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}