From d535d0bea130476166b18b1dab692f41ebc4fe00 Mon Sep 17 00:00:00 2001 From: OpenSquared Date: Sat, 18 Jul 2026 23:05:16 +0200 Subject: [PATCH] feat: saxo --- backend/services/saxo_client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/services/saxo_client.py b/backend/services/saxo_client.py index 0f24543..1eaf4bb 100644 --- a/backend/services/saxo_client.py +++ b/backend/services/saxo_client.py @@ -122,7 +122,11 @@ def resolve_instrument(symbol: str, asset_types: str = _OPTION_ASSET_TYPES) -> D if not items: raise ValueError(f"Aucun instrument Saxo trouvé pour '{symbol}' (AssetTypes={asset_types})") - item = items[0] + # An exact symbol match always wins over Saxo's own search ranking — e.g. searching + # "EURUSD" must resolve to the plain EURUSD root, not one of the "EURUSD Weekly (2)..." + # futures-option variants that also match the keyword and could rank first. + exact = next((i for i in items if str(_first(i, "Symbol", "symbol") or "").upper() == symbol.upper()), None) + item = exact or items[0] uic = _first(item, "Identifier", "Uic", "uic") if uic is None: raise ValueError(f"Champ Uic introuvable dans la réponse instruments pour '{symbol}': {item}")