Cancel Stop Order By ClientOid (Implementation)
Source:R/impl_spottrading_orders_stop.R
cancel_stop_order_by_client_oid_impl.Rd
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 toget_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
Parameter Validation: Ensures
clientOid
is a non-empty string and, if provided,symbol
is a valid trading pair.Request Construction: Builds the endpoint URL with query parameters
symbol
(optional) andclientOid
(required).Authentication: Generates private API headers using
build_headers()
with the DELETE method and endpoint.API Request: Sends a DELETE request to the KuCoin API with a 3-second timeout.
Response Processing: Parses the response, validates success, and returns a
data.table
withcancelledOrderId
andclientOid
.
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
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
} # }