diff --git a/examples/derivs/__init__.py b/examples/derivs/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/examples/max_pain.py b/examples/max_pain.py index c6f9ec93..5206d306 100644 --- a/examples/max_pain.py +++ b/examples/max_pain.py @@ -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]] diff --git a/examples/max_pain_readme.rst b/examples/max_pain_readme.rst new file mode 100644 index 00000000..e69de29b diff --git a/piker/brokers/deribit/api.py b/piker/brokers/deribit/api.py index 855edb68..12fe4355 100644 --- a/piker/brokers/deribit/api.py +++ b/piker/brokers/deribit/api.py @@ -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],