exchange.GetAccount
Requests the exchange account information. GetAccount() is a member function of the exchange object exchange and acts only on the account bound to that exchange object (with several accounts, use exchanges[i].GetAccount() to pick one).
exchange.GetAccount()Examples
-
Get the available and frozen balance of the current account.
javascriptfunction main() { var account = exchange.GetAccount() if (!account) return Log("Available", account.Balance, "Frozen", account.FrozenBalance) // Output: Available <available quote currency> Frozen <frozen quote currency> }pythondef main(): account = exchange.GetAccount() if not account: return Log("Available", account["Balance"], "Frozen", account["FrozenBalance"]) # Output: Available <available quote currency> Frozen <frozen quote currency>rustfn main() { let Ok(account) = exchange.GetAccount() else { return }; Log!("Available", account.Balance, "Frozen", account.FrozenBalance); // Output: Available <available quote currency> Frozen <frozen quote currency> } -
Set the trading pair and contract code, and get the current account information.
javascriptfunction 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) }pythondef 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"])rustfn 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); }
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.
Under cross-currency margin modes such as a unified (portfolio margin) account, the Balance on some exchanges is all assets converted to USD, for example Futures_Binance; see "Margin, Account and Simulation" on each exchange page for how the account is reported.