HKUDS/Vibe-Trading · error · ValueError
pre_translated=True asserts the flows were already converted
Error message
pre_translated=True asserts the flows were already converted, so the reporting currency must be named explicitly via currency=...
What it means
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.
Source
Thrown at agent/src/entities/cashflow.py:242
CurrencyMismatchError: If the flows span multiple currencies while
``pre_translated`` is False, or contradict a declared currency.
"""
flows = tuple(self.flows)
for item in flows:
if not isinstance(item, CashFlow):
raise ValueError(
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}"View on GitHub (pinned to 80ffdda44c)
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
Example fix
# before CashFlowSeries(flows=flows, pre_translated=True) # after CashFlowSeries(flows=flows, pre_translated='USD', currency='USD', pre_translated=True)
Defensive patterns
Strategy: validation
Validate before calling
currency = currency or infer_reporting_currency(flows) series = CashFlowSeries(flows=flows, currency=currency, pre_translated=True)
Try / catch
try:
CashFlowSeries(flows=flows, pre_translated=True)
except ValueError as e:
if 'reporting currency must be named' in str(e):
series = CashFlowSeries(flows=flows, currency=REPORTING_CCY, pre_translated=True) Prevention
- Pair pre_translated=True with an explicit currency= by convention
- Wrap series construction in a helper that always supplies the reporting currency
When it happens
Trigger: CashFlowSeries(flows=already_converted_flows, pre_translated=True) with currency omitted (None).
Common situations: Rebuilding a series from a translated output where the currency attribute was dropped; copy-pasting construction code and deleting the currency argument.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- amount must be a finite number, got {self.amount!r}; a missi
- kind={self.kind!r} must have a {direction} amount under the
- start {lower} is after end {upper}
- display_currency must be USD or CNY
- flows[{index}]: {exc}
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/a6f907f8dfb95c77.
Report an issue: GitHub.