Skip to main content

Cancel Order

Cancels an existing open order on Binance, removing it from the order book.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Client Id - The unique identifier from the Connect node (optional if using direct credentials).
  • Order ID - The unique identifier of the order to cancel (from the order creation response).
  • Currency Pair - The trading pair symbol of the order (e.g., BTCUSDT, ETHUSDT).

Options

  • Api Key - (Optional) Binance API key credential. Use if not providing Client Id.
  • Secret Key - (Optional) Binance API secret key credential. Use if not providing Client Id.

Output

  • Result - Returns true if the order was successfully canceled.

How It Works

The Cancel Order node removes an open order from the Binance order book.

When executed, the node:

  1. Retrieves the Binance client (from Client Id or creates one from credentials)
  2. Validates the Order ID and Currency Pair inputs
  3. Sends a cancel request to Binance for the specified order
  4. Returns true if cancellation is successful

Requirements

  • Either a Client Id from Connect node OR API credentials in options
  • Valid Order ID from a previously created order
  • Correct Currency Pair matching the order
  • Order must still be open (not already filled or canceled)
  • Appropriate API permissions (spot trading enabled)

Error Handling

The node will return specific errors in the following cases:

  • ErrInternal - Failed to retrieve input values
  • ErrInvalidArg - Empty Currency Pair or invalid Order ID (zero or negative)
  • ErrCancelOrder - Cancellation failed (e.g., order already filled, invalid order ID, wrong pair)

Usage Notes

  • You can only cancel orders that are still open (not filled or already canceled)
  • Provide the exact Order ID received when the order was created
  • The Currency Pair must match the original order
  • Partially filled orders can be canceled (unfilled portion is canceled)
  • You cannot cancel orders from other accounts
  • Cancellation is immediate when successful

Order States

Orders can only be canceled in these states:

  • NEW - Order is active and open
  • PARTIALLY_FILLED - Order is partially executed
  • PENDING_CANCEL - Cancellation is in progress

Orders cannot be canceled in these states:

  • FILLED - Order is completely executed
  • CANCELED - Order is already canceled
  • REJECTED - Order was rejected
  • EXPIRED - Order has expired

Example: Cancel a Specific Order

Scenario: Cancel a buy order that hasn't filled

Inputs:

  • Client Id: (from Connect node)
  • Order ID: 123456789 (from Buy Order node result)
  • Currency Pair: BTCUSDT

Output: Result: true (order successfully canceled)

Example: Cancel and Replace Strategy

[Get Order: order_id]
|
v
[If: order still open after 5 minutes]
|
v
[Cancel Order: order_id]
|
v
[Get Price: current market price]
|
v
[Buy Order: new order at better price]
|
v
[Store: new order_id]

Example: Cancel All Open Orders

[Connect]
|
v
[List My Orders]
|
v
[For Each: order in orders]
|
v
[Cancel Order]
| Order ID: order.orderId
| Currency Pair: order.symbol
v
[Log: "Canceled order " + order.orderId]
|
v
[Disconnect]

Example: Conditional Order Management

[Timer: Every minute]
|
v
[Connect]
|
v
[Get Order: stored_order_id]
|
v
[If: order.status == "NEW" AND time_elapsed > 10_minutes]
|
v
[Cancel Order: stored_order_id]
|
v
[Send Alert: "Order canceled due to timeout"]
|
v
[Disconnect]

When to Cancel Orders

Market Conditions Changed:

  • Price moved significantly
  • Volatility increased
  • News or events occurred

Order Management:

  • Order hasn't filled within expected timeframe
  • Want to update price
  • Strategy changed

Risk Management:

  • Reduce exposure
  • Exit position planning
  • Portfolio rebalancing

Technical Reasons:

  • Updating trailing stops
  • Replacing with better-priced orders
  • System shutdown/restart

Trading Tips

  • Store Order IDs: Always save order IDs when creating orders for later cancellation
  • Check Status First: Use Get Order to verify order status before canceling
  • Handle Errors: Order might fill between your check and cancel attempt
  • Batch Cancellations: Use List My Orders to get all open orders before canceling
  • Replace Orders: Cancel old order before placing new one to avoid double-fills
  • Time Limits: Set time limits for orders and auto-cancel if not filled
  • Market Moves: Cancel and replace orders when market moves significantly

Common Errors

  • Order not found - Order ID doesn't exist or wrong Currency Pair specified
  • Order already filled - Order executed before cancellation request
  • Order already canceled - Order was previously canceled
  • Invalid order ID - Incorrect or zero order ID provided
  • Symbol mismatch - Currency Pair doesn't match the order

Best Practices

  • Always save Order IDs when creating orders
  • Verify order status with Get Order before attempting cancellation
  • Handle cancellation errors gracefully (order might have already filled)
  • Use Continue On Error when canceling multiple orders to avoid stopping on filled orders
  • Cancel orders before disconnecting or stopping your automation
  • Don't assume cancellation succeeded - check the result
  • Consider partial fills - canceled orders may have partially executed
  • Keep track of which orders you've created to cancel them properly

Order Lifecycle Management

Create Order
|
v
Store Order ID
|
v
Monitor Order Status
|
+---> [If needs cancellation]
| |
| v
| Cancel Order
| |
| v
| Verify Cancellation
|
+---> [If filled]
|
v
Process Execution

Partial Fills

If an order is partially filled when you cancel it:

  • The filled portion remains executed
  • Only the unfilled portion is canceled
  • You keep the assets from the filled portion
  • The result still returns true

Rate Limiting

  • Binance has rate limits on order cancellations
  • Avoid canceling and recreating orders too frequently
  • Batch cancel operations when possible
  • Implement delays between multiple cancellations