Skip to contents

Retrieves detailed information for a single stop order using its client order ID (clientOid) from the KuCoin Spot trading system asynchronously. This function constructs a GET request to the KuCoin API and returns a promise that resolves to a data.table with comprehensive stop order details, including additional UTC datetime columns derived from timestamps.

Usage

get_stop_order_by_client_oid_impl(
  keys = get_api_keys(),
  base_url = get_base_url(),
  clientOid,
  symbol = NULL,
  .__coro_env_parent__ = <environment>
)

Arguments

keys

List; API configuration parameters from get_api_keys(). Defaults to get_api_keys().

base_url

Character string; base URL for the KuCoin API. Defaults to get_base_url().

clientOid

Character string; the unique client order ID to retrieve (e.g., "2b700942b5db41cebe578cff48960e09"). Required.

symbol

Character string; the trading pair symbol (e.g., "KCS-USDT"). Optional.

Value

Promise resolving to a data.table with typically one row containing stop order details, with the following columns:

  • id (character): Unique order ID assigned by KuCoin.

  • symbol (character): Trading pair (e.g., "KCS-USDT").

  • userId (character): User ID associated with the order.

  • status (character): Order status (e.g., "NEW", "TRIGGERED").

  • type (character): Order type (e.g., "limit", "market").

  • side (character): Order side ("buy" or "sell").

  • price (character): Order price.

  • size (character): Order size.

  • funds (character or NA): Order funds (NULL for untriggered orders).

  • stp (character or NA): Self Trade Prevention strategy (e.g., "DC", "CO", "CN", "CB").

  • timeInForce (character): Time in force (e.g., "GTC", "GTT", "IOC", "FOK").

  • cancelAfter (integer): Seconds until cancellation for GTT (-1 if not applicable).

  • postOnly (logical): Whether the order is post-only.

  • hidden (logical): Whether the order is hidden.

  • iceberg (logical): Whether the order is an iceberg order.

  • visibleSize (character or NA): Visible size for iceberg orders.

  • channel (character): Order source (e.g., "API").

  • clientOid (character): Client-assigned order ID.

  • remark (character or NA): Order remarks.

  • tags (character or NA): Order tags.

  • orderTime (numeric): Order creation time in nanoseconds.

  • domainId (character): Domain ID (e.g., "kucoin").

  • tradeSource (character): Trade source (e.g., "USER").

  • tradeType (character): Trade type (e.g., "TRADE").

  • feeCurrency (character): Currency used for fees.

  • takerFeeRate (character): Taker fee rate.

  • makerFeeRate (character): Maker fee rate.

  • createdAt (integer): Creation timestamp in milliseconds.

  • stop (character): Stop order type (e.g., "loss", "entry").

  • stopTriggerTime (integer or NA): Trigger time in milliseconds (NULL if untriggered).

  • stopPrice (character): Stop price.

  • createdAtDatetime (POSIXct): Creation time in UTC (derived from createdAt).

  • orderTimeDatetime (POSIXct): Order placement time in UTC (derived from orderTime).

Details

Description

This endpoint fetches data for a specific stop order identified by its clientOid, a unique identifier assigned by the user when placing the order. The stop order can be in various states, such as "NEW" (untriggered) or "TRIGGERED" (activated).

Workflow

  1. Parameter Validation: Ensures clientOid is a non-empty string and symbol (if provided) is a valid trading pair.

  2. Request Construction: Builds the endpoint URL with query parameters clientOid and optionally symbol.

  3. Authentication: Generates private API headers using build_headers() with the GET method and endpoint.

  4. API Request: Sends a GET request to the KuCoin API with a 3-second timeout.

  5. Response Processing: Parses the response, converts the data array to a data.table, and adds createdAtDatetime and orderTimeDatetime columns.

API Details

  • Endpoint: GET https://api.kucoin.com/api/v1/stop-order/queryOrderByClientOid

  • Domain: Spot

  • API Channel: Private

  • API Permission: General

  • Rate Limit Pool: Spot

  • Rate Limit Weight: 3

  • SDK Service: Spot

  • SDK Sub-Service: Order

  • SDK Method Name: getStopOrderByClientOid

  • Official Documentation: KuCoin Get Stop Order By ClientOid

Request

Query Parameters

  • clientOid: String (required) - The unique client order ID (e.g., "2b700942b5db41cebe578cff48960e09").

  • symbol: String (optional) - The trading pair symbol (e.g., "KCS-USDT").

Example Request

curl --location --request GET 'https://api.kucoin.com/api/v1/stop-order/queryOrderByClientOid?clientOid=404814a0fb4311eb9098acde48001122&symbol=KCS-USDT'

Response

HTTP Code: 200

  • Content Type: application/json

Data Schema

  • code: String (required) - Response code ("200000" indicates success).

  • data: Array of objects (required) - List of stop order details (typically one item), each with fields such as:

    • id: String - Order ID.

    • symbol: String - Trading pair.

    • userId: String - User ID.

    • status: String - Order status.

    • type: String - Order type.

    • side: String - Order side.

    • price: String - Order price.

    • size: String - Order size.

    • funds: String - Order funds.

    • stp: String - Self Trade Prevention.

    • timeInForce: String - Time in force.

    • cancelAfter: Integer - Cancel after n seconds.

    • postOnly: Boolean - Post-only flag.

    • hidden: Boolean - Hidden order flag.

    • iceberg: Boolean - Iceberg order flag.

    • visibleSize: String - Visible size for iceberg orders.

    • channel: String - Order channel.

    • clientOid: String - Client order ID.

    • remark: String - Order remarks.

    • tags: String - Order tags.

    • orderTime: Integer - Order time in nanoseconds.

    • domainId: String - Domain ID.

    • tradeSource: String - Trade source.

    • tradeType: String - Trade type.

    • feeCurrency: String - Fee currency.

    • takerFeeRate: String - Taker fee rate.

    • makerFeeRate: String - Maker fee rate.

    • createdAt: Integer - Creation timestamp in milliseconds.

    • stop: String - Stop order type.

    • stopTriggerTime: Integer - Stop trigger time.

    • stopPrice: String - Stop price.

JSON Response Example

{
  "code": "200000",
  "data": [
    {
      "id": "vs8hoo8os561f5np0032vngj",
      "symbol": "KCS-USDT",
      "userId": "60fe4956c43cbc0006562c2c",
      "status": "NEW",
      "type": "limit",
      "side": "buy",
      "price": "0.01000000000000000000",
      "size": "0.01000000000000000000",
      "funds": null,
      "stp": null,
      "timeInForce": "GTC",
      "cancelAfter": -1,
      "postOnly": false,
      "hidden": false,
      "iceberg": false,
      "visibleSize": null,
      "channel": "API",
      "clientOid": "2b700942b5db41cebe578cff48960e09",
      "remark": null,
      "tags": null,
      "orderTime": 1629020492834532600,
      "domainId": "kucoin",
      "tradeSource": "USER",
      "tradeType": "TRADE",
      "feeCurrency": "USDT",
      "takerFeeRate": "0.00200000000000000000",
      "makerFeeRate": "0.00200000000000000000",
      "createdAt": 1629020492837,
      "stop": "loss",
      "stopTriggerTime": null,
      "stopPrice": "1.00000000000000000000"
    }
  ]
}

Examples

if (FALSE) { # \dontrun{
library(coro)
library(data.table)

main_async <- coro::async(function() {
  # Retrieve stop order details by clientOid
  stop_order_details <- await(get_stop_order_by_client_oid_impl(
    clientOid = "2b700942b5db41cebe578cff48960e09",
    symbol = "KCS-USDT"
  ))
  print(stop_order_details)
})

# Run the async function
main_async()
while (!later::loop_empty()) later::run_now()
} # }