cache_symbols refactor
parent
89e241c132
commit
156a35b606
|
@ -433,10 +433,38 @@ class Client:
|
||||||
|
|
||||||
async def cache_symbols(
|
async def cache_symbols(
|
||||||
self,
|
self,
|
||||||
) -> dict:
|
venue: MarketType = 'option',
|
||||||
|
|
||||||
if not self._pairs:
|
) -> None:
|
||||||
self._pairs = await self.symbol_info()
|
# 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
|
return self._pairs
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue