Skip to contents

Cancels a spot order by its client order ID (clientOid) on the KuCoin Spot trading system asynchronously. This function sends a cancellation request and returns the clientOid if the request is successfully sent. Note that the actual cancellation status must be checked via order status or Websocket subscription.

Usage

cancel_order_by_client_oid_impl(
  keys = get_api_keys(),
  base_url = get_base_url(),
  clientOid,
  symbol,
  .__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().

clientOid

Character string; the unique client order ID assigned by the user when placing the order. Required.

symbol

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

Value

Promise resolving to a data.table containing:

  • clientOid (character): The client order ID that was requested to be cancelled.

Details

Difference Between Cancel By OrderId and Cancel By ClientOid

  • Cancel By OrderId: Use this when you have the unique order ID generated by KuCoin. This is useful if you are tracking orders using KuCoin's identifiers.

  • Cancel By ClientOid: Use this when you have assigned a unique client order ID (clientOid) to your orders. This is convenient if you are tracking orders using your own identifiers and want to cancel them without mapping to KuCoin's order IDs.

Choose the method that aligns with how you manage and track your orders in your system.

Workflow Overview

  1. Parameter Validation: Ensures clientOid and symbol are provided and valid.

  2. Request Construction: Builds the API endpoint with clientOid and symbol as a query parameter.

  3. Authentication: Generates headers with API credentials using build_headers().

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

  5. Response Processing: Parses the response and returns the clientOid if successful.

API Endpoint

DELETE https://api.kucoin.com/api/v1/hf/orders/client-order/{clientOid}?symbol={symbol}

Usage

Used to cancel a specific spot trading order on KuCoin by its client order ID.

Official Documentation

KuCoin Cancel Order By ClientOid

Examples

if (FALSE) { # \dontrun{
main_async <- coro::async(function() {
  # Cancel an order by clientOid
  result <- await(cancel_order_by_client_oid_impl(
    clientOid = "5c52e11203aa677f33e493fb",
    symbol = "BTC-USDT"
  ))
  print(result)
})
main_async()
while (!later::loop_empty()) later::run_now()
} # }