{"record":{"id":"6db2c95d9bf397d7","repo":"HKUDS/Vibe-Trading","slug":"declared-currency-declared-r-does-not-match-the","errorCode":null,"errorMessage":"declared currency {declared!r} does not match the flows' currency {next(iter(present))!r}","messagePattern":"declared currency (.+?) does not match the flows' currency (.+?)","errorType":"validation","errorClass":"CurrencyMismatchError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/cashflow.py","lineNumber":258,"sourceCode":"        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\n    def __iter__(self) -> Iterator[CashFlow]:\n        \"\"\"Iterate the flows in date order.\n\n        Returns:\n            An iterator over ``CashFlow`` sorted by date.\n        \"\"\"\n        return iter(self.flows)\n\n    def __len__(self) -> int:","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/cashflow.py#L240-L276","documentation":"If you declare a currency on a non-pre-translated series, it must equal the single currency actually present on the flows. A mismatch (e.g. declaring USD for EUR flows) raises CurrencyMismatchError rather than letting totals be attributed to the wrong currency.","triggerScenarios":"CashFlowSeries(flows=eur_flows, currency='USD') where every flow has currency='EUR'.","commonSituations":"Hard-coded reporting currency conflicting with a data source that switched denomination; case/format drift like 'usd' vs 'USD' handled by normalization but genuine currency differences not.","solutions":["Omit currency= and let the series infer it from the flows (single-currency case)","Change currency= to match the flows' actual currency","If you truly want the other currency, translate the flows first (see the multi-currency error)"],"exampleFix":"# before\nCashFlowSeries(flows=eur_flows, currency='USD')\n# after\nCashFlowSeries(flows=eur_flows)  # infers 'EUR'","handlingStrategy":"validation","validationCode":"declared = declared or next(iter({f.currency for f in flows}), None)\nseries = CashFlowSeries(flows=flows, currency=declared)","typeGuard":null,"tryCatchPattern":"from agent.src.entities.cashflow import CurrencyMismatchError\ntry:\n    CashFlowSeries(flows=flows, currency='USD')\nexcept CurrencyMismatchError:\n    series = CashFlowSeries(flows=flows)  # infer from flows","preventionTips":["Prefer omitting currency for single-currency data","Diff configured currency against source data during onboarding"],"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"}