Skip to content

Commit c1988a9

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

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Trading/Exchange/binance/binance_exchange.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,17 @@ 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+
# accountAlias = unique account code
109+
# from https://binance-docs.github.io/apidocs/futures/en/#futures-account-balance-v3-user_data
110+
return raw_binance_balance[0]["accountAlias"]
111+
else:
112+
raw_balance = await self.connector.client.fetch_balance()
113+
return raw_balance[ccxt_constants.CCXT_INFO]["uid"]
114+
except (KeyError, IndexError):
115+
# should not happen
112116
raise
113117

114118
def _infer_account_types(self, exchange_manager):

0 commit comments

Comments
 (0)