Access to crypto account and balances
Get access to current crypto account information.
Last updated
Get access to current crypto account information.
Last updated
While developing a trading strategy, you will definitely need information about the current balance of the selected account. To get this value, you need to use the Balance property of class.
But what about crypto balances? For example, if we have some crypto connection and we need to get all available balances of ‘BTC’ currency, or ‘ETH’ currency or both. How do we get these values? The answer is ‘Easy”)
Quantower API supports a special class for most crypto connections. This class is derived from the base class and extends its functionality with additional property - and special event. In your code, you need to make sure the account you choose implements the class.
AssetId - base currency identifier
TotalBalance - total amount of currency
ReservedBalance - amount of reserved currency (submitting limit orders etc.)
AvailableBalance - amount of available currency (TotalBalance - ReservedBalance)
TotalInBTC - converted total amount of currency in ‘BTC’
TotalInUSD - converted total amount of currency in ‘USD’
All you need to do:
Run Debug-mode and find the required element in AdditionalInfo collection.
Store identifier(Id property) of this element as a constant.
Use 'TryGetItem' method with stored identifier to get required element.
Below is an example how to find the "BTC wallet balance" element for an Bybit-account.
Now, we can store this identifier as a constant and use it to get required additional field. Example below:
The property is an array that contains info about all available crypto coins and their states in this moment of time. Each item of this collection is an instance of class.
Let's take a look at the main properties of class:
Unfortunately, not all crypto connections support class. The main reason for this is imperfection current broker API. For such connections, information about crypto balances is stored in a special AdditionalInfo collection.