symbol_info refactor
parent
ac6f52088a
commit
1f4a5b80c4
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue