From 17123d85fc976bd3b3f5dc936bf2d921026e0182 Mon Sep 17 00:00:00 2001 From: Guillaume De Saint Martin Date: Sun, 1 Dec 2024 18:23:12 +0100 Subject: [PATCH] [Binance] add futures exchange get_account_id --- Trading/Exchange/binance/binance_exchange.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Trading/Exchange/binance/binance_exchange.py b/Trading/Exchange/binance/binance_exchange.py index 5297dc43f..0e6bc4ab3 100644 --- a/Trading/Exchange/binance/binance_exchange.py +++ b/Trading/Exchange/binance/binance_exchange.py @@ -102,13 +102,16 @@ def get_adapter_class(self): return BinanceCCXTAdapter async def get_account_id(self, **kwargs: dict) -> str: - raw_balance = await self.connector.client.fetch_balance() try: - return raw_balance[ccxt_constants.CCXT_INFO]["uid"] - except KeyError: if self.exchange_manager.is_future: - raise NotImplementedError("get_account_id is not implemented on binance futures account") - # should not happen in spot + raw_binance_balance = await self.connector.client.fapiPrivateV3GetBalance() + print(f"raw_binance_balance: {raw_binance_balance}") + return raw_binance_balance[0]["accountAlias"] + else: + raw_balance = await self.connector.client.fetch_balance() + return raw_balance[ccxt_constants.CCXT_INFO]["uid"] + except (KeyError, IndexError): + # should not happen raise def _infer_account_types(self, exchange_manager):