Get Stop Order By OrderId (Implementation)
Source:R/impl_spottrading_orders_stop.R
get_stop_order_by_order_id_impl.Rd
Retrieves detailed information for a single stop order using its order ID 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_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 retrieve (e.g., "vs8hoo8q2ceshiue003b67c0"). Required.
Value
Promise resolving to a data.table
with 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 fromcreatedAt
).orderTimeDatetime
(POSIXct): Order placement time in UTC (derived fromorderTime
).
Details
Description
This endpoint fetches data for a specific stop order identified by its orderId
, which is the unique identifier
assigned by the KuCoin system when the order is created. The stop order can be in various states, such as "NEW"
(untriggered) or "TRIGGERED" (activated).
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 GET method and endpoint.API Request: Sends a GET request to the KuCoin API with a 3-second timeout.
Response Processing: Parses the response, converts the
data
object to adata.table
, and addscreatedAtDatetime
andorderTimeDatetime
columns.
API Details
Endpoint:
GET https://api.kucoin.com/api/v1/stop-order/{orderId}
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: getStopOrderByOrderId
Official Documentation: KuCoin Get Stop Order By OrderId
Request
Response
Data Schema
code
: String (required) - Response code ("200000" indicates success).data
: Object (required) - Stop order details 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": "vs8hoo8q2ceshiue003b67c0",
"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": "40e0eb9efe6311eb8e58acde48001122",
"remark": null,
"tags": null,
"orderTime": 1629098781127530345,
"domainId": "kucoin",
"tradeSource": "USER",
"tradeType": "TRADE",
"feeCurrency": "USDT",
"takerFeeRate": "0.00200000000000000000",
"makerFeeRate": "0.00200000000000000000",
"createdAt": 1629098781128,
"stop": "loss",
"stopTriggerTime": null,
"stopPrice": "10.00000000000000000000"
}
}
Examples
if (FALSE) { # \dontrun{
library(coro)
library(data.table)
main_async <- coro::async(function() {
# Retrieve stop order details by orderId
stop_order_details <- await(get_stop_order_by_order_id_impl(
orderId = "vs8hoo8q2ceshiue003b67c0"
))
print(stop_order_details)
})
# Run the async function
main_async()
while (!later::loop_empty()) later::run_now()
} # }