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 None
Nelson Torres 2025-01-30 01:44:39 +00:00
parent 4e9e72f0f1
commit 92a861a397
1 changed files with 9 additions and 4 deletions

View File

@ -382,6 +382,7 @@ class Client:
currency: str = 'btc', currency: str = 'btc',
kind: str = 'option', kind: str = 'option',
expired: bool = False, expired: bool = False,
expiry_date: str = None,
) -> list[Symbol]: ) -> list[Symbol]:
""" """
@ -400,8 +401,10 @@ class Client:
resp = r.result resp = r.result
response_list = [] response_list = []
for i in range(len(resp) // 10): for i in range(len(resp)):
element = resp[i] element = resp[i]
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'])) response_list.append(piker_sym_to_cb_sym(element['instrument_name']))
return response_list return response_list
@ -879,7 +882,9 @@ async def open_oi_feed(
) as client: ) as client:
# to get all currencies available in deribit # to get all currencies available in deribit
# currencies = await client.get_currencies() # 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]]]]] = {} open_interests: dict[str, dict[str, dict[str, list[dict[str, Decimal]]]]] = {}
fh: FeedHandler fh: FeedHandler