Skip to content

"Vibe-Trading: Your Personal Trading Agent"

feat(portfolio): validate display currency against available rates

zeus2293dffefad2eca
diff --git a/agent/src/portfolio/config.py b/agent/src/portfolio/config.py
index cd6b5288e..733ed59b6 100644
--- a/agent/src/portfolio/config.py
+++ b/agent/src/portfolio/config.py
@@ -12,6 +12,8 @@ from typing import Any
from src.config.paths import get_runtime_root
from src.portfolio.compatibility import profile_compatibility
+from src.portfolio.fx import DISPLAY_RATE_CURRENCIES
+from src.portfolio.iso4217 import is_iso_currency
from src.trading.connections import (
ConnectionStore,
is_portfolio_connection_profile,
@@ -143,8 +145,13 @@ def parse_settings(
"""
store = connection_store or ConnectionStore()
currency = str(payload.get("display_currency") or "USD").strip().upper()
- if currency not in {"USD", "CNY"}:
- raise ValueError("display_currency must be USD or CNY")
+ if not is_iso_currency(currency):
+ raise ValueError(f"display_currency is not a valid ISO-4217 code: {currency}")
+ if currency not in DISPLAY_RATE_CURRENCIES:
+ supported = ", ".join(sorted(DISPLAY_RATE_CURRENCIES))
+ raise ValueError(
+ f"display_currency {currency} has no production FX rate; choose one of: {supported}"
+ )
raw_sources = payload.get("sources")
if not isinstance(raw_sources, list):