exchange.Log
Outputs order placement and cancellation logs in the log column area. When this function is called, it does not actually place an order; it is only used to output and record trading logs.
exchange.Log(orderType, price, amount)
exchange.Log(orderType, price, amount, ...args)Examples
Using exchange.Log(orderType, price, amount) allows you to perform live order-following tests and simulated order placement, and it can also assist in recording order information.
The most common use case is: accessing the exchange's conditional order creation interface through the exchange.IO function, but calling the exchange.IO() function does not output trading log information in the live log.
In this case, you can use the exchange.Log() function to supplement the log output in order to record the order information. The same applies to cancellation operations.
javascript
var id = 123
function main() {
// Order type buy, price 999, quantity 0.1
exchange.Log(LOG_TYPE_BUY, 999, 0.1)
// Cancel order
exchange.Log(LOG_TYPE_CANCEL, id)
}
python
id = 123
def main():
exchange.Log(LOG_TYPE_BUY, 999, 0.1)
exchange.Log(LOG_TYPE_CANCEL, id)
rust
fn main() {
let id = 123;
// Order type buy, price 999, quantity 0.1
exchange.Log(LOG_TYPE_BUY, 999, 0.1);
// Cancel order; when orderType is LOG_TYPE_CANCEL, the price parameter is the order Id to be canceled (in Rust the amount parameter is required and can be passed as 0)
exchange.Log(LOG_TYPE_CANCEL, id, 0);
}Returns
| Type | Description |
string / bool | When |
Arguments
| Name | Type | Required | Description |
orderType | number | Yes | Type of log to output. The available values are |
price | number | Yes | Price displayed in the log. |
amount | number | Yes | Order quantity displayed in the log. |
arg | string / number / bool / object / array / any | No | An extension parameter used to output additional information to this log entry. Multiple |
See Also
Remarks
When the orderType parameter is LOG_TYPE_CANCEL, the price parameter represents the order Id to be canceled, which is used to print the cancellation log when canceling an order by directly calling the exchange.IO() function.
The exchange.Log() function is a member function of the exchange object, which is distinct from the global function Log.