Skip to main content

log

用來印出指定訊息,可印最大長度為 200 個字串。 回測時最多顯示(最後) 500 筆訊息。

Input

  message: string;

範例

印出開盤價、收盤價與交易量。

exchange, pair, base, quote = CA.get_exchange_pair()
CA.log(str(candles[exchange][pair][0]['open']))
CA.log(str(candles[exchange][pair][0]['close']))
CA.log(str(candles[exchange][pair][0]['volume']))

印出可用、所有資產。

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))