diff --git a/piker/brokers/deribit/api.py b/piker/brokers/deribit/api.py index 49664883..5aa8f208 100644 --- a/piker/brokers/deribit/api.py +++ b/piker/brokers/deribit/api.py @@ -433,10 +433,38 @@ class Client: async def cache_symbols( self, - ) -> dict: + venue: MarketType = 'option', - if not self._pairs: - self._pairs = await self.symbol_info() + ) -> None: + # lookup internal mkt-specific pair table to update + pair_table: dict[str, Pair] = self._pairs + + # make API request(s) + mkt_pairs = await self.symbol_info() + + if not mkt_pairs: + raise SymbolNotFound(f'No market pairs found!?:\n{resp}') + + pairs_view_subtable: dict[str, Pair] = {} + + for instrument in mkt_pairs: + pair_type: Type = PAIRTYPES[venue] + try: + pair: Pair = pair_type(**mkt_pairs[instrument].to_dict()) + except Exception as e: + e.add_note( + "\nDon't panic, prolly stupid binance changed their symbology schema again..\n" + 'Check out their API docs here:\n\n' + 'https://binance-docs.github.io/apidocs/spot/en/#exchange-information' + ) + raise + pair_table[pair.symbol.upper()] = pair + + # update an additional top-level-cross-venue-table + # `._pairs: ChainMap` for search B0 + pairs_view_subtable[pair.bs_fqme] = pair + + self._pairs.maps.append(pairs_view_subtable) return self._pairs