Skip to contents

Cancels a specified quantity of a spot order by its order ID on the KuCoin Spot trading system asynchronously. This function sends a cancellation request for the specified size and returns the order ID and canceled size if the request is successfully sent. Note that the actual cancellation status must be checked via order status or WebSocket subscription.

Usage

cancel_partial_order_impl(
  keys = get_api_keys(),
  base_url = get_base_url(),
  orderId,
  symbol,
  cancelSize,
  .__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 partially cancel. Required.

symbol

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

cancelSize

Character string; the quantity of the order to cancel (e.g., "0.00001"). Required.

Value

Promise resolving to a data.table containing:

  • orderId (character): The order ID that was partially canceled.

  • cancelSize (character): The quantity that was canceled.

Details

Description

This endpoint cancels a specified quantity of an existing order based on its orderId. Unlike full cancellation endpoints, it allows partial cancellation, leaving the remaining order quantity active. The order execution priority (price first, time first) is not affected by this operation.

Differences from Other Cancellation Functions

  • Cancel Order By OrderId: Cancels the entire order using the order ID.

  • Cancel Order By ClientOid: Cancels the entire order using the client-assigned ID.

  • Cancel Partial Order: Cancels only a specified quantity of the order, useful for reducing order size without full cancellation.

Workflow

  1. Parameter Validation: Ensures orderId, symbol, and cancelSize are non-empty strings, with symbol being a valid trading pair.

  2. Request Construction: Builds the API endpoint with orderId in the path and symbol and cancelSize as query parameters.

  3. Authentication: Generates headers using API credentials via 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 orderId and cancelSize if successful.

API Endpoint

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

Rate Limit

  • Weight: 2 (higher than full cancellation endpoints, which are typically 1).

Official Documentation

KuCoin Cancel Partial Order

Examples

if (FALSE) { # \dontrun{
main_async <- coro::async(function() {
  # Partially cancel an order
  result <- await(cancel_partial_order_impl(
    orderId = "6711f73c1ef16c000717bb31",
    symbol = "BTC-USDT",
    cancelSize = "0.00001"
  ))
  print(result)
})
main_async()
while (!later::loop_empty()) later::run_now()
} # }