ccxt: Bitget.fetchBalance does not return the total USDT of my account

Operating System

Windows

Programming Languages

Python

CCXT Version

No response

Description

Hello, I am developing my futures trading bot on Bitget. The code below returns Total USDT = $256.8, while my Bitget futures test account has a total of $343 However, I would like to use the total amount of my account to calculate the quantities to buy or shorten for my trading bot. Could you give me the right command/parameter to use in cctx.biget to recover the right amount? Thank you!

Code

import ccxt bitget = ccxt.bitget({ ‘apiKey’: ‘apikey’, ‘secret’: ‘secret’, ‘password’: ‘pswd’, ‘options’: { ‘defaultType’: ‘swap’, }

Récupération balance du compte Bitget

balance = bitget.fetchBalance() #correction dev print(‘Total USDT:’,balance[“USDT”])

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

@Eddyroll You would need to iterate through the info list in your balance response then pull the equity value, something like this might work:

info = balance['info']
for x in range(0, len(info)):
    entry = info[x]
    equity = entry['equity']

By the way the equity value includes the unrealized PNL of your open positions, there’s some descriptions of the values returned by the exchange here: https://bitgetlimited.github.io/apidoc/en/mix/#get-account-list

It works perfectly! Many thanks @Dan-krm @carlosmiei @germangar