HKUDS/Vibe-Trading · error · CurrencyMismatchError
cash flows span multiple currencies ({', '.join(sorted(prese
Error message
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 What it means
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.
Source
Thrown at agent/src/entities/cashflow.py:249
f"CashFlowSeries members must be CashFlow, got "
f"{type(item).__name__}"
)
declared = (
normalize_currency(self.currency) if self.currency is not None else None
)
present = {flow.currency for flow in flows}
if self.pre_translated:
if declared is None:
raise ValueError(
"pre_translated=True asserts the flows were already converted, "
"so the reporting currency must be named explicitly via "
"currency=..."
)
else:
if len(present) > 1:
raise CurrencyMismatchError(
"cash flows span multiple currencies "
f"({', '.join(sorted(present))}); convert them first and pass "
"pre_translated=True with the reporting currency, rather than "
"summing across currencies"
)
if declared is None:
declared = next(iter(present)) if present else None
elif present and declared not in present:
raise CurrencyMismatchError(
f"declared currency {declared!r} does not match the flows' "
f"currency {next(iter(present))!r}"
)
object.__setattr__(self, "currency", declared)
object.__setattr__(self, "flows", tuple(sorted(flows, key=lambda f: f.date)))
# ─── Access ───
View on GitHub (pinned to 80ffdda44c)
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
Example fix
# before CashFlowSeries(flows=mixed_currency_flows) # after table = FxRateTable.from_rates(rates, quote_currency='USD') translated = table.translate_cashflows(mixed_currency_flows) series = CashFlowSeries(flows=translated, currency='USD', pre_translated=True)
Defensive patterns
Strategy: validation
Validate before calling
currencies = {f.currency for f in flows}
if len(currencies) > 1:
flows = fx_table.translate_cashflows(flows)
series = CashFlowSeries(flows=flows, currency='USD', pre_translated=True) Try / catch
from agent.src.entities.cashflow import CurrencyMismatchError
try:
CashFlowSeries(flows=flows)
except CurrencyMismatchError:
flows = fx_table.translate_cashflows(flows)
series = CashFlowSeries(flows=flows, currency=fx_table.quote_currency, pre_translated=True) Prevention
- Always run FX translation before aggregating multi-currency data
- Keep a single reporting currency configured app-wide
When it happens
Trigger: CashFlowSeries(flows=[CashFlow(..., currency='EUR'), CashFlow(..., currency='USD')]) without pre_translated.
Common situations: 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.
Related errors
- declared currency {declared!r} does not match the flows' cur
- amount must be numeric, got {self.amount!r}
- amount must be a finite number, got {self.amount!r}; a missi
- kind={self.kind!r} must have a {direction} amount under the
- metadata must be a mapping, got {type(self.metadata).__name_
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/a91316d61731cb01.
Report an issue: GitHub.