Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
OS
Structures
Built-in Variables and Constants
Conventions
Exchanges

Cancels a conditional order. The format of the conditional order Id is similar to that of a regular order Id, consisting of the exchange symbol code and the exchange's original conditional order Id, separated by an English comma.

When calling the exchange.CancelConditionOrder() function to cancel a conditional order, the conditionOrderId parameter passed in is consistent with the Id attribute of the conditional order structure.

exchange.CancelConditionOrder(conditionOrderId)
exchange.CancelConditionOrder(conditionOrderId, ...args)

Examples

  • Cancel a conditional order.

    javascript
    function main(){ // Create a stop-loss conditional order var condition = { ConditionType: ORDER_CONDITION_TYPE_SL, SlTriggerPrice: 58000, SlOrderPrice: -1 // Market order } var id = exchange.CreateConditionOrder("BTC_USDT", "sell", 0.01, condition) Sleep(1000) exchange.CancelConditionOrder(id) }
    python
    def main(): # Create a stop-loss conditional order condition = { "ConditionType": ORDER_CONDITION_TYPE_SL, "SlTriggerPrice": 58000, "SlOrderPrice": -1 # Market order } id = exchange.CreateConditionOrder("BTC_USDT", "sell", 0.01, condition) Sleep(1000) exchange.CancelConditionOrder(id)
    rust
    fn main() { // Create a stop-loss conditional order let condition = OrderCondition { ConditionType: ORDER_CONDITION_TYPE_SL, SlTriggerPrice: 58000.0, SlOrderPrice: -1.0, // Market order ..Default::default() }; let id = exchange.CreateConditionOrder("BTC_USDT", "sell", 0.01, &condition).unwrap(); Sleep(1000); let _ = exchange.CancelConditionOrder(&id); }
  • Batch cancel condition orders, with condition order information output.

    javascript
    function main() { // Create several condition orders var condition1 = { ConditionType: ORDER_CONDITION_TYPE_TP, TpTriggerPrice: 65000, TpOrderPrice: 65000 } exchange.CreateConditionOrder("BTC_USDT", "sell", 0.01, condition1) var condition2 = { ConditionType: ORDER_CONDITION_TYPE_SL, SlTriggerPrice: 58000, SlOrderPrice: 58000 } exchange.CreateConditionOrder("BTC_USDT", "sell", 0.01, condition2) Sleep(1000) var orders = exchange.GetConditionOrders() for (var i = 0 ; i < orders.length ; i++) { exchange.CancelConditionOrder(orders[i].Id, "Canceled condition order:", orders[i]) Sleep(500) } }
    python
    def main(): # Create several condition orders condition1 = { "ConditionType": ORDER_CONDITION_TYPE_TP, "TpTriggerPrice": 65000, "TpOrderPrice": 65000 } exchange.CreateConditionOrder("BTC_USDT", "sell", 0.01, condition1) condition2 = { "ConditionType": ORDER_CONDITION_TYPE_SL, "SlTriggerPrice": 58000, "SlOrderPrice": 58000 } exchange.CreateConditionOrder("BTC_USDT", "sell", 0.01, condition2) Sleep(1000) orders = exchange.GetConditionOrders() for i in range(len(orders)): exchange.CancelConditionOrder(orders[i]["Id"], "Canceled condition order:", orders[i]) Sleep(500)
    rust
    fn main() { // Create several condition orders let condition1 = OrderCondition { ConditionType: ORDER_CONDITION_TYPE_TP, TpTriggerPrice: 65000.0, TpOrderPrice: 65000.0, ..Default::default() }; let _ = exchange.CreateConditionOrder("BTC_USDT", "sell", 0.01, &condition1); let condition2 = OrderCondition { ConditionType: ORDER_CONDITION_TYPE_SL, SlTriggerPrice: 58000.0, SlOrderPrice: 58000.0, ..Default::default() }; let _ = exchange.CreateConditionOrder("BTC_USDT", "sell", 0.01, &condition2); Sleep(1000); let orders = exchange.GetConditionOrders(None).unwrap(); for i in 0..orders.len() { // In Rust, CancelConditionOrder does not support extended parameters; output the accompanying information with Log let _ = exchange.CancelConditionOrder(&orders[i].Id); Log!("Canceled condition order:", orders[i]); Sleep(500); } }

Returns

TypeDescription

bool

Returns a truthy value (e.g. true) to indicate that the request to cancel the conditional order was sent successfully, and returns a falsy value (e.g. false) to indicate that the request to cancel the conditional order failed to send.

Arguments

NameTypeRequiredDescription

conditionOrderId

string

Yes

Conditional order to be canceled.

arg

string / number / bool / object / array / any

No

An extended parameter used to output additional information to the log of this canceled conditional order. Multiple arg parameters can be passed in.

See Also

Remarks

The return value of the exchange.CancelConditionOrder() function only indicates whether the cancellation request was sent successfully or failed. To determine whether the exchange has actually canceled the conditional order, you can call the exchange.GetConditionOrders() function for confirmation.

Only untriggered conditional orders can be canceled; conditional orders that have already been triggered and converted into regular orders cannot be canceled through this function.

Exchanges that do not support this function: Bithumb, Bitstamp, Coinw, DigiFinex, Futures_DigiFinex, Gemini, HashKey, Korbit, LBank, MEXC, Upbit, WEEX, Zaif, Hyperliquid, Pendle, Uniswap, PancakeSwap, Aerodrome, Velodrome, KyberSwap, OneInch, Jupiter, OKX_DEX, Futures_Polymarket, Futures_Futu, Futures_IB, Exchange, Web3. The call fails with an error and returns null; for all exchanges see Capability Matrix.