Skip to main content

get_balance

Input​

  exchange: string;
currency: string;

Return​

  balance: Balance;

Check Balance

Example​

To get base and quote balance, and to print available base and quot amount.

Note get_balance will return the SAME response each time the callback is triggered. Recalling CA.get_balance will not get the updated result. The result will be upated the next time the callback is triggered. We are improving this experience - you can leverge on_order_state_change to trigger side effect

exchange, pair, base, quote = CA.get_exchange_pair()
base_balance = CA.get_balance(exchange, base)
quote_balance = CA.get_balance(exchange, quote)
available_base_amount = base_balance.available
available_quote_amount = quote_balance.available
total_base_amount = base_balance.total
total_quote_amount = quote_balance.total
CA.log('available ' + str(base) + ' amount: ' + str(available_base_amount))
CA.log('available ' + str(quote) + ' amount: ' + str(available_quote_amount))
CA.log('total ' + str(base) + ' amount: ' + str(total_base_amount))
CA.log('total ' + str(quote) + ' amount: ' + str(total_quote_amount))