From 71f3a0a4cd260bb9f422908042aa5d687adb99b7 Mon Sep 17 00:00:00 2001 From: Nelson Torres Date: Fri, 8 Nov 2024 21:46:58 +0000 Subject: [PATCH] get_assets refactor --- piker/brokers/deribit/api.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/piker/brokers/deribit/api.py b/piker/brokers/deribit/api.py index 84a7e06d..03757879 100644 --- a/piker/brokers/deribit/api.py +++ b/piker/brokers/deribit/api.py @@ -302,20 +302,32 @@ class Client: return balances - async def get_assets(self) -> dict[str, float]: + async def get_assets( + self, + venue: str | None = None, + + ) -> dict[str, Asset]: """Return the set of asset balances for this account by symbol. """ - balances = {} + assets = {} + resp = await self.json_rpc( + 'private/get_account_summaries', + params={ + 'extended' : True + } + ) + summaries = resp.result['summaries'] + for summary in summaries: + currency = summary['currency'] + tx_tick = Decimal('1e-08') + atype='crypto_currency' + assets[currency] = Asset( + name=currency, + atype=atype, + tx_tick=tx_tick) + return assets - for currency in self.currencies: - resp = await self.json_rpc( - 'private/get_account_summary', params={ - 'currency': currency.upper()}) - - balances[currency] = resp.result['balance'] - - return balances async def submit_limit( self,