Cancel Partial Order (Implementation)
Source:R/impl_spottrading_orders_cancel_order.R
cancel_partial_order_impl.Rd
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 toget_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
Parameter Validation: Ensures
orderId
,symbol
, andcancelSize
are non-empty strings, withsymbol
being a valid trading pair.Request Construction: Builds the API endpoint with
orderId
in the path andsymbol
andcancelSize
as query parameters.Authentication: Generates headers using API credentials via
build_headers()
.API Request: Sends a DELETE request to the KuCoin API with a 3-second timeout.
Response Processing: Parses the response and returns the
orderId
andcancelSize
if successful.
API Endpoint
DELETE https://api.kucoin.com/api/v1/hf/orders/cancel/{orderId}?symbol={symbol}&cancelSize={cancelSize}
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()
} # }