{"record":{"id":"4af79756d5469743","repo":"HKUDS/Vibe-Trading","slug":"fxrate-entry-base-currency-entry-quote-currency","errorCode":null,"errorMessage":"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","messagePattern":"FxRate (.+?)/(.+?)@(.+?) does not quote against this table's currency (.+?); a table may only hold rates quoted against one reporting currency","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/entities/cashflow.py","lineNumber":539,"sourceCode":"\n    def __post_init__(self) -> None:\n        \"\"\"Validate the quote currency and every entry's consistency.\n\n        Raises:\n            ValueError: If ``quote_currency`` is invalid, a value is not an\n                ``FxRate``, an entry quotes against a different currency than\n                the table's, or an entry is stored under a key that does not\n                match its own ``(base_currency, date)``.\n        \"\"\"\n        quote = normalize_currency(self.quote_currency, field_name=\"quote_currency\")\n        rates = dict(self.rates)\n        for key, entry in rates.items():\n            if not isinstance(entry, FxRate):\n                raise ValueError(\n                    f\"FxRateTable entries must be FxRate, got {type(entry).__name__}\"\n                )\n            if entry.quote_currency != quote:\n                raise ValueError(\n                    f\"FxRate {entry.base_currency}/{entry.quote_currency}@\"\n                    f\"{entry.date} does not quote against this table's \"\n                    f\"currency {quote!r}; a table may only hold rates quoted \"\n                    \"against one reporting currency\"\n                )\n            expected_key = (entry.base_currency, entry.date)\n            if key != expected_key:\n                raise ValueError(\n                    f\"FxRate stored under key {key!r} does not match its own \"\n                    f\"(base_currency, date) = {expected_key!r}\"\n                )\n        object.__setattr__(self, \"quote_currency\", quote)\n        object.__setattr__(self, \"rates\", MappingProxyType(rates))\n\n    @classmethod\n    def from_rates(cls, rates: Iterable[FxRate], *, quote_currency: str) -> \"FxRateTable\":\n        \"\"\"Build a table from a sequence of individual quotes.\n","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/entities/cashflow.py#L521-L557","documentation":"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.","triggerScenarios":"FxRateTable(quote_currency='USD', rates={('EUR', d): FxRate('EUR','GBP',d,0.85)}) — the rate quotes EUR/GBP inside a USD table.","commonSituations":"Merging rate sets from multiple sources quoted against different bases; a quote_currency typo; cross-rate tables mislabeled at import.","solutions":["Convert or re-fetch the offending entries so every rate is quoted against the table's currency","Or split entries into one table per quote currency and pick the right table at lookup time","Check the table's quote_currency spelling matches the entries' quote_currency exactly"],"exampleFix":"# before\nFxRateTable(quote_currency='USD', rates={('EUR', d): FxRate('EUR','GBP',d,0.85)})\n# after\nFxRateTable(quote_currency='USD', rates={('EUR', d): FxRate('EUR','USD',d,1.0850)})","handlingStrategy":"validation","validationCode":"from agent.src.entities.cashflow import FxRate\nbad = [e for e in rates if e.quote_currency != table_quote]\nrates = [e for e in rates if e.quote_currency == table_quote]","typeGuard":null,"tryCatchPattern":"try:\n    FxRateTable(quote_currency=q, rates=indexed)\nexcept ValueError as e:\n    if 'does not quote against' in str(e):\n        split into per-quote-currency tables and retry","preventionTips":["Group fetched rates by quote currency before table construction","Store quote currency alongside rate rows in your cache"],"tags":["python","fx-rate","currency-mismatch"],"backgroundTag":"currency-mismatch","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}