Update api.py
Now we get the data for an e specific expiration date if and expiry_date is passed, or for all expiration if expiry_date is Nonemax_pain_deribit
parent
9abbd8ca1e
commit
a9110b1196
|
@ -123,7 +123,7 @@ def str_to_cb_sym(name: str) -> Symbol:
|
|||
|
||||
if option_type == 'put':
|
||||
option_type = PUT
|
||||
elif option_type == 'call':
|
||||
elif option_type == 'call':
|
||||
option_type = CALL
|
||||
else:
|
||||
raise Exception("Couldn\'t parse option type")
|
||||
|
@ -382,6 +382,7 @@ class Client:
|
|||
currency: str = 'btc',
|
||||
kind: str = 'option',
|
||||
expired: bool = False,
|
||||
expiry_date: str = None,
|
||||
|
||||
) -> list[Symbol]:
|
||||
"""
|
||||
|
@ -400,9 +401,11 @@ class Client:
|
|||
resp = r.result
|
||||
response_list = []
|
||||
|
||||
for i in range(len(resp) // 10):
|
||||
for i in range(len(resp)):
|
||||
element = resp[i]
|
||||
response_list.append(piker_sym_to_cb_sym(element['instrument_name']))
|
||||
name = f'{element["instrument_name"].split("-")[1]}'
|
||||
if not expiry_date or name == expiry_date.upper():
|
||||
response_list.append(piker_sym_to_cb_sym(element['instrument_name']))
|
||||
|
||||
return response_list
|
||||
|
||||
|
@ -879,7 +882,9 @@ async def open_oi_feed(
|
|||
) as client:
|
||||
# to get all currencies available in deribit
|
||||
# currencies = await client.get_currencies()
|
||||
instruments = await client.get_instruments()
|
||||
instruments = await client.get_instruments(
|
||||
expiry_date='6DEC24'
|
||||
)
|
||||
|
||||
open_interests: dict[str, dict[str, dict[str, list[dict[str, Decimal]]]]] = {}
|
||||
fh: FeedHandler
|
||||
|
|
Loading…
Reference in New Issue