exchange.GetAccount
The exchange.GetAccount() function is used to request the 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 the subsequent documentation.
exchange.GetAccount()Examples
Set the trading pair and contract code, and get the current account information.
javascript
function main(){
// Switch the trading pair
exchange.IO("currency", "BTC_USDT")
// Taking OKX Futures as an example, set the contract to the current-week contract. The current trading pair is BTC_USDT, so the current contract is the USDT-margined current-week contract of BTC
exchange.SetContractType("this_week")
// Get the current account asset data
var account = exchange.GetAccount()
// Available balance with USDT as margin
Log(account.Balance)
// Frozen amount with USDT as margin
Log(account.FrozenBalance)
// Current asset equity
Log(account.Equity)
// Unrealized profit and loss of all positions with the current assets as margin
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"])
rust
fn main() {
// Switch the trading pair
exchange.IO(("currency", "BTC_USDT")).unwrap();
// Taking OKX Futures as an example, set the contract to the current-week contract. The current trading pair is BTC_USDT, so the current contract is the USDT-margined current-week contract of BTC
exchange.SetContractType("this_week").unwrap();
// Get the current account asset data
let account = exchange.GetAccount().unwrap();
// Available balance with USDT as margin
Log!(account.Balance);
// Frozen amount with USDT as margin
Log!(account.FrozenBalance);
// Current asset equity
Log!(account.Equity);
// Unrealized profit and loss of all positions with the current assets as margin
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 |
| Queries the account asset information. Returns the |
See Also
Remarks
If the exchange object is set to a cryptocurrency futures contract exchange and switched to a contract that uses USDT as margin (for the switching method, please refer to the exchange.SetCurrency and exchange.SetContractType functions), the assets are then denominated in USDT as margin 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 a coin-margined contract, the assets are then denominated in the coin as margin and recorded in the Stocks and FrozenStocks properties of the Account structure.
When using a Binance Futures unified account, calling the exchange.GetAccount() function to request account information returns encapsulated data where all assets are converted into their value in **USD**, displayed in the Balance field of the Account structure. If you need to calculate the converted value of other assets, you can divide the USD-converted amount by the index price (of the asset to be converted), and then divide by the collateral ratio (of the asset to be converted).