The exchange.Log()
function is used to output the log of order placement and withdrawal in the log column area. When called, no orders are placed, only the transaction log is output and recorded.
exchange.Log(orderType, price, amount) exchange.Log(orderType, price, amount, …args)
The orderType
parameter is used to set the output log type, the optional values are {@var/LOG_TYPE/LOG_TYPE_BUY LOG_TYPE_BUY}, {@var/LOG_TYPE/LOG_TYPE_SELL LOG_TYPE_SELL}, {@var/LOG_TYPE/LOG_TYPE_CANCEL LOG_TYPE_CANCEL}.
orderType
true
number
The price
parameter is used to set the price displayed in the output log.
price
true
number
The amount
parameter is used to set the amount of orders placed displayed in the output log.
amount
true
number
Extended parameters that can output accompanying information to this log, arg
parameters can be passed more than one.
arg
false
string, number, bool, object, array, null and any other type supported by the system
var id = 123
function main() {
// Order type buy, price 999, amount 0.1
exchange.Log(LOG_TYPE_BUY, 999, 0.1)
// Cancel the order
exchange.Log(LOG_TYPE_CANCEL, id)
}
id = 123
def main():
exchange.Log(LOG_TYPE_BUY, 999, 0.1)
exchange.Log(LOG_TYPE_CANCEL, id)
void main() {
auto id = 123;
exchange.Log(LOG_TYPE_BUY, 999, 0.1);
exchange.Log(LOG_TYPE_CANCEL, id);
}
Using exchange.Log(orderType, price, amount)
can be used for live trading order following tests, simulated order placement, and it can assist in logging order placement. One of the most common scenarios is to use the {@fun/Trade/exchange.IO exchange.IO} function to access the exchange’s interface for creating conditional orders, but using the exchange.IO()
function does not output the transaction log information in the live trading log record. This is where the exchange.Log()
function can be used to supplement the output log in order to record order placement information, and the same is true for order withdrawal operations.
When the orderType
parameter is LOG_TYPE_CANCEL
, the price
parameter is the order Id of the withdrawn order, which is used to print the withdrawal log when the order is withdrawn directly using the exchange.IO()
function. The exchange.Log()
function is a member function of the {@var/EXCHANGE exchange} exchange object, as distinguished from the global function {@fun/Log Log}.
{@fun/Log Log}, {@var/EXCHANGE exchange}, {@var/LOG_TYPE/LOG_TYPE_BUY LOG_TYPE_BUY}, {@var/LOG_TYPE/LOG_TYPE_SELL LOG_TYPE_SELL}, {@var/LOG_TYPE/LOG_TYPE_CANCEL LOG_TYPE_CANCEL}
exchange.IO exchange.Encode