Cancel All Orders (Implementation)
Source:R/impl_spottrading_orders_cancel_order.R
cancel_all_orders_impl.Rd
Cancels all spot orders across all symbols on the KuCoin Spot trading system asynchronously. This endpoint sends a cancellation request for all open spot orders and returns a success indicator if the request is accepted. Note that this endpoint only initiates cancellation; the actual status of individual orders must be checked via order status endpoints or WebSocket subscription.
Usage
cancel_all_orders_impl(
keys = get_api_keys(),
base_url = get_base_url(),
.__coro_env_parent__ = <environment>
)
Arguments
- keys
List; API configuration parameters (e.g., from
get_api_keys()
). Contains API key, secret, passphrase, and key version. Defaults toget_api_keys()
.- base_url
Character string; base URL for the KuCoin API (e.g., "https://api.kucoin.com"). Defaults to
get_base_url()
.
Value
Promise resolving to a data.table
with:
succeedSymbols
(character): Vector of symbols for which orders were successfully canceled.failedSymbols
(list): List of objects withsymbol
(character) anderror
(character) for symbols where cancellation failed.
Description
This function interacts with the KuCoin API endpoint DELETE /api/v1/hf/orders/cancelAll
to cancel all spot orders for the authenticated account, regardless of symbol. It is useful
for quickly clearing all open orders, such as during portfolio rebalancing or emergency stops.
Differences from Other Cancellation Endpoints
Cancel Order By OrderId: Cancels a single order using its unique order ID.
Cancel Order By ClientOid: Cancels a single order using a client-assigned ID.
Cancel Partial Order: Cancels a portion of a single order.
Cancel All Orders By Symbol: Cancels all orders for a specific symbol.
Cancel All Orders: Cancels all spot orders across all symbols in one request, offering maximum efficiency for bulk cancellations.
Use this function when you need to terminate all spot trading activity instantly.
Workflow
Authentication: Generates private API headers using the provided
keys
.API Request: Sends a DELETE request to the KuCoin API with a 3-second timeout.
Response Processing: Parses the response and returns successful and failed symbols if the request is accepted.
API Details
Endpoint:
DELETE https://api.kucoin.com/api/v1/hf/orders/cancelAll
Domain: Spot
API Channel: Private
API Permission: Spot
Rate Limit Pool: Spot
Rate Limit Weight: 30
SDK Details: Service: Spot, Sub-service: Order, Method: cancelAllOrders
Official Documentation: KuCoin Cancel All Orders
Examples
library(coro)
library(data.table)
main_async <- coro::async(function() {
# Cancel all spot orders
result <- await(cancel_all_orders_impl())
print(result)
})
# Run the async function
main_async()
while (!later::loop_empty()) later::run_now()
Expected Output: