主页 > 苹果手机imtoken怎么下载 > 查看账户余额 - fetchBalance
查看账户余额 - fetchBalance
苹果手机imtoken怎么下载 2023-06-28 08:57:05
查看账户余额 - fetchBalance
要查询账户余额,获取可用于交易的资金量,或者订单锁定的资金量,使用fetchBalance方法。
fetchBalance (params = {})
该方法返回的余额结构如下:
{
'info': { ... }, // the original untouched non-parsed reply with details
//-------------------------------------------------------------------------
// indexed by availability of funds first, then by currency
'free': { // money, available for trading, by currency
'BTC': 321.00, // floats...
'USD': 123.00,
...
},
'used': { ... }, // money on hold, locked, frozen, or pending, by currency
'total': { ... }, // total (free + used), by currency
//-------------------------------------------------------------------------
// indexed by currency first, then by availability of funds
'BTC': { // string, three-letter currency code, uppercase
'free': 321.00 // float, money available for trading
'used': 234.00, // float, money on hold, locked, frozen or pending
'total': 555.00, // float, total balance (free + used)
},
'USD': { // ...
'free': 123.00 // ...
'used': 456.00,
'total': 579.00,
},
...
}
某些交易所可能不会返回完整的余额信息。许多交易所不会退回您的空帐户或未使用的帐户,在这种情况下区块链怎么查询账户余额,返回的余额结构中可能会缺少某些货币信息。
JavaScript 示例代码:
(async () => {
console.log (await exchange.fetchBalance ())
}) ()
Python 示例代码:
print (exchange.fetch_balance ())
PHP 示例代码:
var_dump ($exchange->fetch_balance ());
余额信息的推导
有些交易所的 API 不会返回完整的余额信息区块链怎么查询账户余额,它们只返回可用余额或只返回资金总额。在这种情况下,ccxt 将尝试从订单缓存中获取丢失的数据,并根据已知信息猜测完整的余额信息。但是,在某些极端情况下,这可能不足以得出正确的余额信息,开发人员应该意识到这种可能性。