diff --git a/piker/brokers/deribit/api.py b/piker/brokers/deribit/api.py index 12e0944f..d7d888a9 100644 --- a/piker/brokers/deribit/api.py +++ b/piker/brokers/deribit/api.py @@ -392,7 +392,7 @@ class Client: kind: str = 'option', expired: bool = False - ) -> dict[str, dict]: + ) -> dict[str, Pair] | Pair: ''' Get symbol infos. @@ -412,14 +412,29 @@ class Client: params, ) # convert to symbol-keyed table + pair_type: Type = PAIRTYPES[kind] results: list[dict] | None = resp.result - instruments: dict[str, dict] = { - item['instrument_name'].lower(): item - for item in results - } + + instruments: dict[str, Pair] = {} + for item in results: + symbol=item['instrument_name'].lower() + try: + pair: Pair = pair_type( + symbol=symbol, + **item + ) + except Exception as e: + e.add_note( + "\nDon't panic, prolly stupid deribit changed their symbology schema again..\n" + 'Check out their API docs here:\n\n' + 'https://docs.deribit.com/?python#deribit-api-v2-1-1' + ) + raise + + instruments[symbol] = pair if instrument is not None: - return instruments[instrument] + return instruments[instrument.lower()] else: return instruments