Skip to contents

Cancels a spot order by its order ID on the KuCoin Spot trading system asynchronously. This function sends a cancellation request and returns the order ID 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_order_id_impl(
  keys = get_api_keys(),
  base_url = get_base_url(),
  orderId,
  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().

orderId

Character string; the unique order ID to cancel. Required.

symbol

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

Value

Promise resolving to a data.table containing:

  • orderId (character): The 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 orderId and symbol are provided and valid.

  2. Request Construction: Builds the API endpoint with orderId 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 order ID if successful.

API Endpoint

DELETE https://api.kucoin.com/api/v1/hf/orders/{orderId}?symbol={symbol}

Usage

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

Official Documentation

KuCoin Cancel Order By OrderId

Examples

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