Type/to search
Built-in Functions
Global
Log
Log
LogStatus
LogProfit
LogProfitReset
LogReset
LogVacuum
EnableLog
Chart
KLineChart
console.log
console.error
exchange.Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

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

TypeDescription

string / bool

When orderType is LOG_TYPE_BUY or LOG_TYPE_SELL, a virtual order ID string is returned, formatted as V followed by a 5-digit incrementing number, for example V00001; when orderType is LOG_TYPE_CANCEL, JavaScript and Python return true and Rust returns an empty string.

Arguments

NameTypeRequiredDescription

orderType

number

Yes

Type of log to output. The available values are LOG_TYPE_BUY, LOG_TYPE_SELL, LOG_TYPE_CANCEL.

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 arg parameters can be passed in.

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.