From 17249205c957eed162f0f2bf0fad1bd7e1cf1b84 Mon Sep 17 00:00:00 2001 From: Nelson Torres Date: Tue, 26 Nov 2024 15:15:01 -0300 Subject: [PATCH] get_instrumets for cryptofeed.FeedHandler --- piker/brokers/deribit/api.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/piker/brokers/deribit/api.py b/piker/brokers/deribit/api.py index 1297193b..67301911 100644 --- a/piker/brokers/deribit/api.py +++ b/piker/brokers/deribit/api.py @@ -361,6 +361,35 @@ class Client: return flat + async def get_instruments( + self, + currency: str = 'btc', + kind: str = 'option', + expired: bool = False, + + ) -> list[Symbol]: + """ + Get instruments for cryptoFeed.FeedHandler. + """ + params: dict[str, str] = { + 'currency': currency.upper(), + 'kind': kind, + 'expired': expired, + } + + r: JSONRPCResult = await self._json_rpc_auth_wrapper( + 'public/get_instruments', + params, + ) + resp = r.result + response_list = [] + + for i in range(len(resp) // 10): + element = resp[i] + response_list.append(piker_sym_to_cb_sym(element['instrument_name'])) + + return response_list + async def submit_limit( self, symbol: str,