Cancel Stop Order By OrderId (Implementation)
Source:R/impl_spottrading_orders_stop.R
cancel_stop_order_by_order_id_impl.Rd
Cancels a stop order on the KuCoin Spot trading system using its system-generated order ID (orderId
) 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_order_id_impl(
keys = get_api_keys(),
base_url = get_base_url(),
orderId,
.__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 cancel (e.g., "671124f9365ccb00073debd4"). Required.
Value
Promise resolving to a data.table
with one row containing:
cancelledOrderIds
(character): The ID of the cancelled order.
Details
Description
This endpoint allows users to cancel a previously placed stop order identified by its orderId
, which is the unique identifier assigned by the KuCoin system upon order creation. 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
orderId
is a non-empty string.Request Construction: Builds the endpoint URL with
orderId
as a path parameter.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
withcancelledOrderIds
.
API Details
Endpoint:
DELETE https://api.kucoin.com/api/v1/stop-order/{orderId}
Domain: Spot
API Channel: Private
API Permission: Spot
Rate Limit Pool: Spot
Rate Limit Weight: 3
SDK Service: Spot
SDK Sub-Service: Order
SDK Method Name: cancelStopOrderByOrderId
Official Documentation: KuCoin Cancel Stop Order By OrderId
Request
Examples
if (FALSE) { # \dontrun{
library(coro)
library(data.table)
main_async <- coro::async(function() {
# Cancel a stop order by orderId
cancellation <- await(cancel_stop_order_by_order_id_impl(
orderId = "671124f9365ccb00073debd4"
))
print(cancellation)
})
# Run the async function
main_async()
while (!later::loop_empty()) later::run_now()
# Expected Output:
# cancelledOrderIds
# 1: 671124f9365ccb00073debd4
} # }