exchange.GetAccount
The exchange.GetAccount() function is used to request exchange account information. The GetAccount() function is a member function of the exchange object exchange. The member functions (methods) of the exchange object are only related to exchange, which will not be repeated in subsequent documentation.
exchange.GetAccount()Examples
Set trading pair and contract code, get current account information.
javascript
function main(){
// 切换交易对
exchange.IO("currency", "BTC_USDT")
// 以OKX期货为例,设置合约为当周合约,当前交易对为BTC_USDT,所以当前合约为BTC的U本位当周合约
exchange.SetContractType("this_week")
// 获取当前账户资产数据
var account = exchange.GetAccount()
// USDT作为保证金的可用余额
Log(account.Balance)
// USDT作为保证金的冻结金额
Log(account.FrozenBalance)
// 当前资产权益
Log(account.Equity)
// 当前资产作为保证金的所有持仓的未实现盈亏
Log(account.UPnL)
}
python
def main():
exchange.IO("currency", "BTC_USDT")
exchange.SetContractType("this_week")
account = exchange.GetAccount()
Log(account["Balance"])
Log(account["FrozenBalance"])
Log(account["Equity"])
Log(account["UPnL"])
c++
void main() {
exchange.IO("currency", "BTC_USDT");
exchange.SetContractType("this_week");
auto account = exchange.GetAccount();
Log(account.Balance);
Log(account.FrozenBalance);
Log(account.Equity);
Log(account.UPnL);
}Returns
| Type | Description |
| Query account asset information. Returns |
See Also
Remarks
If the exchange object is set to a cryptocurrency futures contract exchange and switched to contracts using USDT as margin (for switching methods, please refer to exchange.SetCurrency, exchange.SetContractType functions), assets are margined in USDT and recorded in the Balance and FrozenBalance properties of the Account structure.
If the exchange object is set to a cryptocurrency futures contract exchange and switched to coin-margined contracts, assets are margined in coins and recorded in the Stocks and FrozenStocks properties of the Account structure.
When using Binance Futures unified account, when calling the exchange.GetAccount() function to request account information, the encapsulated data is the amount of all assets converted to **USD**, displayed in the Balance field of the Account structure. To calculate the converted amount of other assets, divide the USD converted amount by the index price (of the asset to be converted) and then divide by the collateral rate (of the asset to be converted).