Binance API获取现货资产余额



我想从我的Binance账户中获得我的Spot钱包资产的余额。

我试过了:

bal = client.get_account()
print(bal)

返回:

"makerCommission": 15,
"takerCommission": 15,
"buyerCommission": 0,
"sellerCommission": 0,
"canTrade": true,
"canWithdraw": true,
"canDeposit": true,
"balances": [
{
"asset": "BTC",
"free": "4723846.89208129",
"locked": "0.00000000"
},
{
"asset": "LTC",
"free": "4763368.68006011",
"locked": "0.00000000"
}
]
}

为了得到平衡值,我尝试了:

bal = client.get_account()
for i in bal:
if(i == 'balances'):
for e in i:
print(e)

但是这个返回这个:

b
a
l
a
n
c
e
s

那么我如何访问我的资产余额呢?

提前感谢。

直接尝试get_asset_balance()方法

client.get_asset_balance(asset='BTC')

或者尝试从嵌套字典bal中提取值,如下所示:

if "balances" in bal: 
for b in bal['balances']:
print(b)

相关内容

  • 没有找到相关文章

最新更新