Skip to contents

Cancels a stop order on the KuCoin Spot trading system using its system-generated order ID (orderId) asynchronously. This function sends a cancellation request and returns a data.table with the cancelled order's details. Note that this endpoint only initiates cancellation; the actual status must be verified via order status checks or WebSocket subscription.

Usage

cancel_stop_order_by_order_id_impl(
  keys = get_api_keys(),
  base_url = get_base_url(),
  orderId,
  .__coro_env_parent__ = <environment>
)

Arguments

keys

List; API configuration parameters from get_api_keys(). Defaults to get_api_keys().

base_url

Character string; base URL for the KuCoin API. Defaults to get_base_url().

orderId

Character string; the unique order ID to cancel (e.g., "671124f9365ccb00073debd4"). Required.

Value

Promise resolving to a data.table with one row containing:

  • cancelledOrderIds (character): The ID of the cancelled order.

Details

Description

This endpoint allows users to cancel a previously placed stop order identified by its orderId, which is the unique identifier assigned by the KuCoin system upon order creation. Stop orders are conditional orders that trigger when the market price reaches a specified stopPrice. The function sends a DELETE request to the KuCoin API and returns confirmation details upon successful initiation of the cancellation. The maximum number of untriggered stop orders per trading pair is 20, and this endpoint helps manage that limit by removing specific orders.

Workflow

  1. Parameter Validation: Ensures orderId is a non-empty string.

  2. Request Construction: Builds the endpoint URL with orderId as a path parameter.

  3. Authentication: Generates private API headers using build_headers() with the DELETE method and endpoint.

  4. API Request: Sends a DELETE request to the KuCoin API with a 3-second timeout.

  5. Response Processing: Parses the response, validates success, and returns a data.table with cancelledOrderIds.

API Details

  • Endpoint: DELETE https://api.kucoin.com/api/v1/stop-order/{orderId}

  • Domain: Spot

  • API Channel: Private

  • API Permission: Spot

  • Rate Limit Pool: Spot

  • Rate Limit Weight: 3

  • SDK Service: Spot

  • SDK Sub-Service: Order

  • SDK Method Name: cancelStopOrderByOrderId

  • Official Documentation: KuCoin Cancel Stop Order By OrderId

Request

Path Parameters

  • orderId: String (required) - The unique order ID generated by the trading system (e.g., "671124f9365ccb00073debd4").

Example Request

curl --location --request DELETE 'https://api.kucoin.com/api/v1/stop-order/671124f9365ccb00073debd4'

Response

HTTP Code: 200

  • Content Type: application/json

Data Schema

  • code: String (required) - Response code ("200000" indicates success).

  • data: Object (required) - Contains:

    • cancelledOrderIds: ArrayString (required) - Array of order IDs that were cancelled (typically a single ID for this endpoint).

JSON Response Example

{
  "code": "200000",
  "data": {
    "cancelledOrderIds": [
      "671124f9365ccb00073debd4"
    ]
  }
}

Examples

if (FALSE) { # \dontrun{
library(coro)
library(data.table)

main_async <- coro::async(function() {
  # Cancel a stop order by orderId
  cancellation <- await(cancel_stop_order_by_order_id_impl(
    orderId = "671124f9365ccb00073debd4"
  ))
  print(cancellation)
})

# Run the async function
main_async()
while (!later::loop_empty()) later::run_now()

# Expected Output:
#    cancelledOrderIds
# 1: 671124f9365ccb00073debd4
} # }