HKUDS/Vibe-Trading · error · ValueError

FxRate {entry.base_currency}/{entry.quote_currency}@{entry.d

Error message

FxRate {entry.base_currency}/{entry.quote_currency}@{entry.date} does not quote against this table's currency {quote!r}; a table may only hold rates quoted against one reporting currency

What it means

A single FxRateTable holds rates all quoted against one reporting (quote) currency; every entry's quote_currency must equal the table's quote_currency. An entry quoted against something else breaks the table's invariant that lookups return X-per-reporting-unit rates.

Source

Thrown at agent/src/entities/cashflow.py:539

    def __post_init__(self) -> None:
        """Validate the quote currency and every entry's consistency.

        Raises:
            ValueError: If ``quote_currency`` is invalid, a value is not an
                ``FxRate``, an entry quotes against a different currency than
                the table's, or an entry is stored under a key that does not
                match its own ``(base_currency, date)``.
        """
        quote = normalize_currency(self.quote_currency, field_name="quote_currency")
        rates = dict(self.rates)
        for key, entry in rates.items():
            if not isinstance(entry, FxRate):
                raise ValueError(
                    f"FxRateTable entries must be FxRate, got {type(entry).__name__}"
                )
            if entry.quote_currency != quote:
                raise ValueError(
                    f"FxRate {entry.base_currency}/{entry.quote_currency}@"
                    f"{entry.date} does not quote against this table's "
                    f"currency {quote!r}; a table may only hold rates quoted "
                    "against one reporting currency"
                )
            expected_key = (entry.base_currency, entry.date)
            if key != expected_key:
                raise ValueError(
                    f"FxRate stored under key {key!r} does not match its own "
                    f"(base_currency, date) = {expected_key!r}"
                )
        object.__setattr__(self, "quote_currency", quote)
        object.__setattr__(self, "rates", MappingProxyType(rates))

    @classmethod
    def from_rates(cls, rates: Iterable[FxRate], *, quote_currency: str) -> "FxRateTable":
        """Build a table from a sequence of individual quotes.

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Convert or re-fetch the offending entries so every rate is quoted against the table's currency
  2. Or split entries into one table per quote currency and pick the right table at lookup time
  3. Check the table's quote_currency spelling matches the entries' quote_currency exactly

Example fix

# before
FxRateTable(quote_currency='USD', rates={('EUR', d): FxRate('EUR','GBP',d,0.85)})
# after
FxRateTable(quote_currency='USD', rates={('EUR', d): FxRate('EUR','USD',d,1.0850)})
Defensive patterns

Strategy: validation

Validate before calling

from agent.src.entities.cashflow import FxRate
bad = [e for e in rates if e.quote_currency != table_quote]
rates = [e for e in rates if e.quote_currency == table_quote]

Try / catch

try:
    FxRateTable(quote_currency=q, rates=indexed)
except ValueError as e:
    if 'does not quote against' in str(e):
        split into per-quote-currency tables and retry

Prevention

When it happens

Trigger: FxRateTable(quote_currency='USD', rates={('EUR', d): FxRate('EUR','GBP',d,0.85)}) — the rate quotes EUR/GBP inside a USD table.

Common situations: Merging rate sets from multiple sources quoted against different bases; a quote_currency typo; cross-rate tables mislabeled at import.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/4af79756d5469743. Report an issue: GitHub.