Cancel Order By OrderId (Implementation)
Source:R/impl_spottrading_orders_cancel_order.R
cancel_order_by_order_id_impl.Rd
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 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. 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
Parameter Validation: Ensures
orderId
andsymbol
are provided and valid.Request Construction: Builds the API endpoint with
orderId
andsymbol
as a query parameter.Authentication: Generates headers with API credentials using
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 order ID if successful.
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()
} # }