Skip to content

Commit c87455c

Browse files
committed
[Binance] add futures exchange get_account_id
1 parent e8b8068 commit c87455c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Trading/Exchange/binance/binance_exchange.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,15 @@ def get_adapter_class(self):
102102
return BinanceCCXTAdapter
103103

104104
async def get_account_id(self, **kwargs: dict) -> str:
105-
raw_balance = await self.connector.client.fetch_balance()
106105
try:
107-
return raw_balance[ccxt_constants.CCXT_INFO]["uid"]
108-
except KeyError:
109106
if self.exchange_manager.is_future:
110-
raise NotImplementedError("get_account_id is not implemented on binance futures account")
111-
# should not happen in spot
107+
raw_binance_balance = await self.connector.client.fapiPrivateV3GetBalance()
108+
return raw_binance_balance[0]["accountAlias"]
109+
else:
110+
raw_balance = await self.connector.client.fetch_balance()
111+
return raw_balance[ccxt_constants.CCXT_INFO]["uid"]
112+
except (KeyError, IndexError):
113+
# should not happen
112114
raise
113115

114116
def _infer_account_types(self, exchange_manager):

0 commit comments

Comments
 (0)