Smart Orders
Create Order
- POST
https://api.poloniex.com/smartorders
Create a smart order for an account. Funds will only be frozen when the smart order triggers, not upon smart order creation.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
symbol | String | true | Only supported one. |
side | String | true | BUY, SELL |
timeInForce | String | false | FOK, IOC, GTC (Default: GTC) |
type | String | false | STOP, STOP_LIMIT, TRAILING_STOP, TRAILING_STOP_LIMIT (Default: STOP if price not specified or STOP_LIMIT if price is specified) |
accountType | string | false | SPOT is the default and only supported one. |
price | String | false | Required for STOP_LIMIT |
stopPrice | String | false | Price at which order is triggered for STOP or STOP_LIMIT order; Activation price for TRAING_STOP or TRAING_STOP_LIMIT order |
quantity | String | true | base units for the order |
amount | String | false | quote units for the order |
clientOrderId | String | false | Maximum 64-character length* |
trailingOffset | String | false | trailing stop price offset (Suffix with%, to trailing the proportion, without%, to trailing the price distance) Required for type TRAILING_STOP or TRAILING_STOP_LIMIT |
limitOffset | String | false | When the order is triggered, the order is issued with a limit order based on the offset of the market price. ( Suffix with%, to limit the proportion, without%, to limit the price distance) Required for TRAILING_STOP_LIMIT |
operator | String | false | Activation the price operator when orderType is TRAILING_STOP or TRAILING_STOP_LIMIT. GTE-greater than and equal (> =). LTE-less than and equal (< =) |
*Only the following characters are allowed as part of clientOrderId:[A-Za-z0-9_-] , Unique order id created by users to identify their orders, e.g. UUID, Only allows numbers, characters, underline(_), and separator(-)
Example request:
{
"quantity": "100",
"side": "BUY",
"type": "STOP_LIMIT",
"price": "60100.00"
"stopPrice": "60000.00",
"timeInForce": "FOK",
"clientOrderId": "999999910",
"symbol": "BTC_USDT"
}
Response Field | Data Type | Description |
---|---|---|
id | String | smart order id |
clientOrderId | String | clientOrderId user specifies in request or an empty string. |
Example output:
{
"id": "10000009",
"clientOrderId": "999999910"
}
Cancel Replace Order
- PUT
https://api.poloniex.com/smartorders/{id}
- PUT
https://api.poloniex.com/smartorders/cid:{clientOrderId}
Cancel an existing untriggered smart order and place a new smart order on the same symbol with details from existing smart order unless amended by new parameters. The replacement smart order can amend price, stopPrice, quantity, amount, type, and timeInForce fields. Specify the existing smart order id in the path; if id is a clientOrderId, prefix with cid: e.g. cid:myId-1. The proceedOnFailure flag is intended to specify whether to continue with new smart order placement in case cancelation of the existing smart order fails.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
clientOrderId | String | false | clientOrderId of the new order* |
price | String | false | amended price |
stopPrice | String | false | amended stop price at which order is triggered |
quantity | String | false | amended quantity |
amount | String | false | amended amount |
type | String | false | amended type; STOP, STOP_LIMIT |
timeInForce | String | false | amended timeInForce; GTC, IOC, FOK (Default: GTC) |
proceedOnFailure | String | false | if set to true then new smart order will be placed even if cancelation of the existing smart order fails; if set to false (DEFAULT value) then new smart order will not be placed if the cancelation of the existing smart order fails |
*Only the following characters are allowed as part of clientOrderId:[A-Za-z0-9_-] , Unique order id created by users to identify their orders, e.g. UUID, Only allows numbers, characters, underline(_), and separator(-)
Response Field | Data Type | Description |
---|---|---|
id | String | order id of the new smart order |
clientOrderId | String | clientOrderId of the new smart order if specified or an empty string |
Example request 1 (cancel and replace a smart order's stop price):
Request:
{
"clientOrderId": "1234Abc"
"stopPrice": "18000"
}
Response:
{
"id": "29772698821328896",
"clientOrderId": "1234Abc"
}
Example request 2 (cancel and replace an order that is already triggered):
Request:
{
"clientOrderId": "1234Abc"
"stopPrice": "18000",
"price": "18005",
"quantity": "20"
}
Response:
{
"code": 21301,
"message": "Couldn't locate smart order"
}
Open Orders
- GET
https://api.poloniex.com/smartorders
Get a list of (pending) smart orders for an account.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
limit | Integer | false | Max number of records to return. Range: 1 - 2000. Default is 500. |
types | string | false | eg:TRAILING_STOP,TRAILING_STOP_LIMIT,STOP_LIMIT,STOP; Default is STOP_LIMIT,STOP |
Response Field | Data Type | Description |
---|---|---|
id | String | smart order id |
clientOrderId | String | user specified id |
symbol | String | The symbol to trade,like BTC_USDT |
state | String | order state: PENDING_NEW |
accountType | String | SPOT |
side | String | BUY, SELL |
type | String | STOP, STOP_LIMIT, TRAILING_STOP, TRAILING_STOP_LIMIT |
timeInForce | String | GTC, IOC, FOK |
quantity | String | base units for the order |
price | String | |
amount | String | quote units for the order |
stopPrice | String | |
createTime | Long | |
updateTime | Long | |
trailingOffset | string | |
limitOffset | string | |
activationPrice | string | Market price at the time of actual activation of TRAILING_STOP, TRAILING_STOP_LIMIT order |
operator | string | GTE,LTE |
Example output:
[
{
"id": "999991586827571200",
"clientOrderId": "",
"symbol": "ETH_USDT",
"state": "PENDING_NEW",
"accountType": "SPOT",
"side": "BUY",
"type": "STOP_LIMIT",
"timeInForce": "GTC",
"quantity": "0.036",
"price": "1",
"amount": "0.00",
"stopPrice": "3750.00",
"createTime": 1630832295888,
"updateTime": 1630832295888
},
{
"id": "999991586827571288",
"clientOrderId": "100832",
"symbol": "BTC_USDT",
"state": "PENDING_NEW",
"accountType": "SPOT",
"side": "SELL",
"type": "STOP_LIMIT",
"timeInForce": "GTC",
"quantity": "0.015",
"price": "11",
"amount": "0.00",
"stopPrice": "55500.00",
"createTime": 1630832298765,
"updateTime": 1630832298765
}
]
Order Details
- GET
https://api.poloniex.com/smartorders/{id}
- GET
https://api.poloniex.com/smartorders/cid:{clientOrderId}
Get a smart order’s status. {id}
can be smart order’s id or its clientOrderId (prefix with cid: ). If smart order’s state is TRIGGERED, the response will include the triggered order’s data
Request Parameter | Data Type | Required | Description |
---|---|---|---|
id | String | true | smart order's id or its clientOrderId (prefix with cid: ) |
Response Field | Data Type | Description |
---|---|---|
id | String | smart order id |
clientOrderId | String | user specified id |
symbol | String | The symbol to trade,like BTC_USDT |
state | String | order state: PENDING_NEW, PENDING_CANCEL, CANCELED, TRIGGERED, FAILED |
accountType | String | SPOT |
side | String | BUY, SELL |
type | String | STOP, STOP_LIMIT, TRAILING_STOP, TRAILING_STOP_LIMIT |
timeInForce | String | GTC, IOC, FOK |
quantity | String | base units for the order |
price | String | |
amount | String | quote units for the order |
stopPrice | String | |
createTime | Long | |
updateTime | Long | |
triggeredOrder | Json | The triggered order's data. This will only be displayed when the smart order's state is TRIGGERED. |
trailingOffset | string | |
limitOffset | string | |
activationPrice | string | Market price at the time of actual activation of TRAILING_STOP, TRAILING_STOP_LIMIT order |
operator | string | GTE,LTE |
triggeredOrder has same fields as /orders/{id}
.
Example output:
[{
"id": "14368195657859072",
"clientOrderId": "18113",
"symbol": "BTC_USDT",
"state": "TRIGGERED",
"accountType": "SPOT",
"side": "BUY",
"type": "STOP",
"timeInForce": "GTC",
"quantity": "0.2",
"price": "41920",
"amount": "10",
"stopPrice": "41946",
"createTime": 1644392044793,
"updateTime": 0,
"triggeredOrder": {
"id": "24106600339865600",
"clientOrderId": "18113",
"symbol": "BTC_USDT",
"state": "PARTIALLY_FILLED",
"accountType": "SPOT",
"side": "BUY",
"type": "MARKET",
"timeInForce": "GTC",
"quantity": "0.00",
"price": "0.00",
"avgPrice": "39991.10",
"amount": "10.00",
"filledQuantity": "0.00025005",
"filledAmount": "9.999774555",
"createTime": 1646713861400,
"updateTime": 1646713861400
}
}]
Cancel Order by Id
- DELETE
https://api.poloniex.com/smartorders/{id}
- DELETE
https://api.poloniex.com/smartorders/cid:{clientOrderId}
Cancel a smart order by its id.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
id | String | true | smart order's id or its clientOrderId (prefix with cid: ) |
Response Field | Data Type | Description |
---|---|---|
orderId | String | the smart order id |
clientOrderId | String | clientOrderId of the smart order. |
state | String | smart order's state (CANCELED) |
code | Integer | response code. |
message | String | response message. |
Example output:
{
"orderId": "9876543",
"clientOrderId": "88888",
"state": "CANCELED",
"code": 200,
"message":""
}
Cancel Multiple Orders by Id
- DELETE
https://api.poloniex.com/smartorders/cancelByIds
Batch cancel one or many smart orders in an account by IDs.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
orderIds | String | No, except clientOrderIds is null or empty | List of smart order id, size should be equal to that of clientOrderIds if it is specified |
clientOrderIds | String | No, except orderIds is null or empty | List of clientOrderId, size should be equal to that of orderIds if it is specified |
Response Field | Data Type | Description |
---|---|---|
orderId | String | the smart order id |
clientOrderId | String | clientOrderId of the smart order. |
state | String | smart order's state (CANCELED) |
code | Integer | response code. |
message | String | response message. |
Example request (body is required, parameters could be optional):
Request:
{
"orderIds": ["9876543", "111222333"],
"clientOrderIds": ["88888", "myId-2"]
}
Response:
[
{
"orderId": "9876543",
"clientOrderId": "88888",
"state": "CANCELED",
"code": 200,
"message":""
},
{
"orderId": "111222333",
"clientOrderId": "myId-2",
"state": "CANCELED",
"code": 200,
"message":""
}
]
Cancel All Orders
- DELETE
https://api.poloniex.com/smartorders
Batch cancel all smart orders in an account
Request Parameter | Data Type | Required | Description |
---|---|---|---|
symbols | String array | false | If symbols are specified then all smart orders with those symbols will be canceled. If symbols are not specified or array is empty, it will cancel user's all smart orders for all symbols. |
accountTypes | String array | false | SPOT is the default and only supported one. |
orderTypes | string | false | eg:TRAILING_STOP,TRAILING_STOP_LIMIT,STOP_LIMIT,STOP; Default is STOP_LIMIT,STOP |
Response Field | Data Type | Description |
---|---|---|
orderId | String | the smart order id |
clientOrderId | String | clientOrderId of the smart order. |
state | String | order's state (CANCELED) |
code | Integer | response code. |
message | String | response message. |
Example request (body is required, but parameters are optional; an empty body implies cancelling all smart orders):
Request:
{
"symbols": ["BTC_USDT", "ETH_USDT"],
"accountTypes": ["SPOT"]
}
Response:
[
{
"orderId": "1111111111",
"clientOrderId": "aaaaa",
"state": "CANCELED",
"code": 200,
"message": "SUCCESS"
},
{
"orderId": "222222222",
"clientOrderId": "",
"state": "CANCELED",
"code": 200,
"message": "SUCCESS"
}
]