Skip to contents

Cancels a stop order on the KuCoin Spot trading system using its client order ID (clientOid) 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_client_oid_impl(
  keys = get_api_keys(),
  base_url = get_base_url(),
  symbol = NULL,
  clientOid,
  .__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().

symbol

Character string; the trading pair symbol (e.g., "BTC-USDT"). Optional.

clientOid

Character string; the unique client order ID to cancel (e.g., "689ff597f4414061aa819cc414836abd"). Required.

Value

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

  • cancelledOrderId (character): Unique ID of the cancelled order.

  • clientOid (character): Client-assigned order ID.

Details

Description

This endpoint allows users to cancel a stop order identified by its clientOid, a user-assigned unique identifier. 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 clientOid is a non-empty string and, if provided, symbol is a valid trading pair.

  2. Request Construction: Builds the endpoint URL with query parameters symbol (optional) and clientOid (required).

  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 cancelledOrderId and clientOid.

API Details

  • Endpoint: DELETE https://api.kucoin.com/api/v1/stop-order/cancelOrderByClientOid

  • Domain: Spot

  • API Channel: Private

  • API Permission: Spot

  • Rate Limit Pool: Spot

  • Rate Limit Weight: 5

  • SDK Service: Spot

  • SDK Sub-Service: Order

  • SDK Method Name: cancelStopOrderByClientOid

  • Official Documentation: KuCoin Cancel Stop Order By ClientOid

Request

Query Parameters

  • symbol: String (optional) - The trading pair symbol (e.g., "BTC-USDT").

  • clientOid: String (required) - Unique client order ID created by the user (e.g., "689ff597f4414061aa819cc414836abd").

Example Request

curl --location --request DELETE 'https://api.kucoin.com/api/v1/stop-order/cancelOrderByClientOid?symbol=BTC-USDT&clientOid=689ff597f4414061aa819cc414836abd'

Response

HTTP Code: 200

  • Content Type: application/json

Data Schema

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

  • data: Object (required) - Contains:

    • clientOid: String (required) - Client-assigned order ID from the request.

    • cancelledOrderId: String (required) - Unique ID of the cancelled order assigned by the system.

JSON Response Example

{
  "code": "200000",
  "data": {
    "cancelledOrderId": "vs8hoo8ksc8mario0035a74n",
    "clientOid": "689ff597f4414061aa819cc414836abd"
  }
}

Examples

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

main_async <- coro::async(function() {
  # Cancel a stop order by clientOid
  cancellation <- await(cancel_stop_order_by_client_oid_impl(
    symbol = "BTC-USDT",
    clientOid = "689ff597f4414061aa819cc414836abd"
  ))
  print(cancellation)
})

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

# Expected Output:
#    cancelledOrderId         clientOid
# 1: vs8hoo8ksc8mario0035a74n 689ff597f4414061aa819cc414836abd
} # }