Skip to content

Commit

Permalink
[Binance] add futures exchange get_account_id
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Dec 1, 2024
1 parent e8b8068 commit 17123d8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Trading/Exchange/binance/binance_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 17123d8

Please sign in to comment.