From c4600a039261aab633dc01c94a8284716de1b777 Mon Sep 17 00:00:00 2001 From: Nelson Torres Date: Thu, 5 Dec 2024 23:29:45 -0300 Subject: [PATCH] auxiliar methods --- piker/brokers/deribit/api.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/piker/brokers/deribit/api.py b/piker/brokers/deribit/api.py index 07aed466..336a3636 100644 --- a/piker/brokers/deribit/api.py +++ b/piker/brokers/deribit/api.py @@ -246,6 +246,20 @@ def get_config() -> dict[str, Any]: return section +def check_if_complete( + oi: dict[str, dict[str, Decimal | None]], + + ) -> bool: + for strike in oi: + if ( + oi[strike]['C'] == None + or + oi[strike]['P'] == None + ): + return False + + return True + class Client: ''' @@ -410,6 +424,27 @@ class Client: return response_list + def get_strikes_dict( + self, + instruments: list[Symbol], + + ) -> dict[str, dict[str, Decimal | None]]: + """ + Get a dict with strike prices as keys. + """ + + response: dict[str, dict[str, Decimal | None]] = {} + + for i in range(len(instruments)): + element = instruments[i] + strike = f'{str(element).split('-')[1]}' + response[f'{strike}'] = { + 'C': None, + 'P': None, + } + + return response + async def submit_limit( self, symbol: str,