Add get expiration dates in deribit api
parent
1c0a2e4eb3
commit
596755a9b2
|
@ -23,8 +23,22 @@ def check_if_complete(
|
|||
|
||||
async def max_pain_daemon(
|
||||
) -> None:
|
||||
expiry_date: str = input('Please enter a valid expiration date (7feb25): ').upper()
|
||||
print('Initializing...')
|
||||
oi_by_strikes: dict[str, dict[str, Decimal | None]]
|
||||
expiry_dates: list[str]
|
||||
currency: str = 'btc'
|
||||
kind: str = 'option'
|
||||
|
||||
async with get_client(
|
||||
) as client:
|
||||
expiry_dates: list[str] = await client.get_expiration_dates(
|
||||
currency=currency,
|
||||
kind=kind
|
||||
)
|
||||
|
||||
print(f'Available expiration dates for {currency}-{kind}:')
|
||||
print(f'{expiry_dates}')
|
||||
expiry_date: str = input('Please enter a valid expiration date: ').upper()
|
||||
print('Starting little daemon...')
|
||||
instruments: list[Symbol] = []
|
||||
oi_by_strikes: dict[str, dict[str, Decimal]]
|
||||
|
||||
|
|
|
@ -425,6 +425,29 @@ class Client:
|
|||
|
||||
return response_list
|
||||
|
||||
async def get_expiration_dates(
|
||||
self,
|
||||
currency: str = 'btc',
|
||||
kind: str = 'option',
|
||||
|
||||
) -> list[str]:
|
||||
"""
|
||||
Get a dict with all expiration dates listed as value and currency as key.
|
||||
"""
|
||||
|
||||
params: dict[str, str] = {
|
||||
'currency': currency.upper(),
|
||||
'kind': kind,
|
||||
}
|
||||
|
||||
r: JSONRPCResult = await self._json_rpc_auth_wrapper(
|
||||
'public/get_expirations',
|
||||
params,
|
||||
)
|
||||
resp = r.result
|
||||
|
||||
return resp[currency][kind]
|
||||
|
||||
def get_strikes_dict(
|
||||
self,
|
||||
instruments: list[Symbol],
|
||||
|
|
Loading…
Reference in New Issue