/ordersGET /orders
Parameters
subaccountId
queryRequiredintegerRequest Example
cURL
curl --request GET \
--url '/orders?subaccountId=%3CsubaccountId%3E'The base URL for endpoints described in this page of live trading API is https://api.cube.exchange/os/v0.
Definitions for requests and responses can be found in the Trade OpenAPI Document.
Further specifics for field enums, reject codes, etc. can be found in the Trade API Websocket Documentation.
API Reference
Version 0.1.0
ApiKey
apiKeyThe API Key ID as specified in the API settings page.
Each API key has a corresponding access level that is set when the key is created.
- Read access only allows access to read HTTP methods (GET, HEAD, etc.).
- Write access allows access to all HTTP methods.
ApiSignature
apiKeyThe API signature string authenticating this request.
The payload to be signed is the concatenation of the byte string cube.xyz and the current unix epoch timestamp in seconds converted into an 8-byte little-endian array. The signature is the HMAC-SHA256 digest of the payload using the secret key associated with the specified API key.
Implementation notes:
- The signature is base-64 encoded with the 'standard' alphabet and
padding.
```
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
```
- The timestamp should be encoded as 8-byte little-endian (array of bytes)
- The secret key should be decoded from a hex string into a 32-byte array of
bytes
ApiTimestamp
apiKeyThe timestamp used for signature generation.
Endpoints in this section require Authentication headers. Note that only API keys with access-level WRITE are able to access any of these endpoints.
/orderssubaccountId
queryRequiredintegerRequest Example
cURL
curl --request GET \
--url '/orders?subaccountId=%3CsubaccountId%3E'/ordersCancel all resting orders, optionally limiting to a particular market and / or order book side.
subaccountId
integerRequireduint64The subaccount to cancel orders for.
requestId
integerRequireduint64A request ID that is echoed back on the MassCancelAck and individual CancelOrderAck's.
marketId
integeruint64NullableIf specified, only orders on the corresponding market will be canceled.
side
integerint32NullableIf specified, only orders with this side will be canceled.
Request Example
application/jsoncURL
curl --request DELETE \
--url '/orders' \
--header 'Content-Type: application/json'/orderPlace a new order. Execution details: - For market orders, exactly one of `quantity` or `quote_quantity` must be specified. - For MARKET_WITH_PROTECTION, if `price` is specified, it will override the default protection price. - Matching will stop upon reaching the protection price, or `quantity` (or `quote_quantity`) filled. - When specifying `quote_quantity`, the order is considered 'fully filled' when there is insufficient remaining quote quantity to fill 1 lot at the next trade price. In that case, there will _not_ be a `CancelOrderAck` published.
clientOrderId
integerRequireduint64A unique order ID assigned by the client for this order. The ID must be unique among open orders by this subaccount.
requestId
integerRequireduint64A request ID that is echoed back on the NewOrderAck or NewOrderReject
marketId
integerRequireduint64price
integeruint64Nullablequantity
integeruint64NullableRequired for LIMIT orders.
side
integerRequiredint32timeInForce
integerRequiredint32orderType
integerRequiredint32subaccountId
integerRequireduint64The subaccount to place this order on. This subaccount must be writable by the API key specified in the Credentials message.
selfTradePrevention
integerint32NullablepostOnly
integerRequiredint32cancelOnDisconnect
booleanRequiredIf true, this order will be automatically cancelled after the closure of the network connection between Cube's servers and the client that placed the order. If the client initiates the disconnect or network instability drops the connection, the order will be cancelled when Cube's servers recognize the disconnection. In the event of a server-side disconnect that causes a halt in trading, such as scheduled downtime, the order will be cancelled before trading resumes.
quoteQuantity
integeruint64NullableThe quantity of the quote asset that the user wants to spend (for a BID) or receive (for an ASK). For limit orders, this is immediately converted to a base quantity using the provided price. For market orders, this is the maximum quantity that will be executed. Note that lot size rules will be respected, and the actual quantity executed will be expressed in base quantity units.
Request Example
application/jsoncURL
curl --request POST \
--url '/order' \
--header 'Content-Type: application/json' \
--data '{
"cancelOnDisconnect": false,
"clientOrderId": 1721188848244274000,
"marketId": 100004,
"orderType": 0,
"postOnly": 0,
"price": 656000,
"quantity": 3300,
"quoteQuantity": null,
"requestId": 1721188848288393000,
"selfTradePrevention": 1,
"side": 0,
"subaccountId": 8,
"timeInForce": 1
}'/orderCancel a resting order. Note that this can be done before the order is acknowledged (an aggressive cancel) since the identifying field is the `client_order_id`.
marketId
integerRequireduint64clientOrderId
integerRequireduint64The order ID specified by the client on the NewOrder request.
requestId
integerRequireduint64A request ID that is echoed back on the CancelOrderAck or CancelOrderReject
subaccountId
integerRequireduint64The subaccount that the NewOrder was placed on.
Request Example
application/jsoncURL
curl --request DELETE \
--url '/order' \
--header 'Content-Type: application/json'/orderModify a resting order. - If the `newPrice` and the current resting order's price is the same, and `newQuantity` is not greater, then the modify is considered a modify down, and the FIFO queue priority is maintained. Otherwise, the modify-order request is treated as an atomic cancel-replace and the replacement order is placed at the end of the FIFO queue for the new price level. - If post-only is specified and the replacement order would trade, then the request is rejected and the current resting order remains resting. Currently, in-flight-mitigation (IFM) is always enabled. That is, the cumulative fill qty is subtracted from `newQuantity` to calculate the new resting quantity. For example: ```text | Resting | Filled ---------+---------+-------- New 5 | 5 | 0 Fill 2 | 3 | 2 Modify 4 | 2 | 2 ``` The post-modify quantity will be `newQuantity - filled = 4 - 2 = 2`. Regardless of IFM, the invariant for order quantity is that `quantity = remaining_quantity + cumulative_quantity`.
marketId
integerRequireduint64clientOrderId
integerRequireduint64The order ID specified by the client on the NewOrder request.
requestId
integerRequireduint64A request ID that is echoed back on the ModifyOrderAck or ModifyOrderReject
newPrice
integerRequireduint64newQuantity
integerRequireduint64subaccountId
integerRequireduint64The subaccount that the NewOrder was placed on.
selfTradePrevention
integerint32NullablepostOnly
integerRequiredint32Request Example
application/jsoncURL
curl --request PATCH \
--url '/order' \
--header 'Content-Type: application/json' \
--data '{
"clientOrderId": 1721212575078893000,
"marketId": 100004,
"newPrice": 656000,
"newQuantity": 3300,
"postOnly": 0,
"requestId": 1721212575263679000,
"selfTradePrevention": 1,
"subaccountId": 8
}'/positionssubaccountId
queryRequiredintegerRequest Example
cURL
curl --request GET \
--url '/positions?subaccountId=%3CsubaccountId%3E'