Orders
Create Order
- POST
https://api.poloniex.com/orders
Create an order for an account.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
symbol | String | true | The symbol to trade, like BTC_USDT |
side | String | true | BUY, SELL |
timeInForce | String | false | GTC, IOC, FOK (Default: GTC) |
type | String | false | MARKET, LIMIT, LIMIT_MAKER (for placing post only orders). Default type is MARKET. |
accountType | String | false | SPOT is the default and only supported one. |
price | String | false | Price is required for non-market orders |
quantity | String | false | Base units for the order. Quantity is required for MARKET SELL or any LIMIT orders |
amount | String | false | Quote units for the order. Amount is required for MARKET BUY order |
clientOrderId | String | false | Maximum 64-character length.* |
allowBorrow | Boolean | false | allow order to be placed by borrowing funds (Default: false) |
stpMode | String | false | self-trade prevention. Defaults to EXPIRE_TAKER. None: enable self-trade; EXPIRE_TAKER: Taker order will be canceled when self-trade happens |
slippageTolerance | String | false | Used to control the maximum slippage ratio, the value range is greater than 0 and less than 1 |
*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 |
clientOrderId | String | clientOrderId user specifies in request or an empty string. |
Example request 1 (Limit Buy 100 BTC_USDT at 40,000.50):
Request:
{
"symbol": "BTC_USDT",
"type": "LIMIT",
"quantity": "100",
"side": "BUY",
"price": "40000.50000",
"timeInForce": "IOC",
"clientOrderId": "1234Abc"
}
Response:
{
"id": "29772698821328896",
"clientOrderId": "1234Abc"
}
Example request 2 (Market Buy 100 BTC_USDT):
Request:
{
"symbol": "BTC_USDT",
"amount": "100",
"side": "BUY"
}
Response:
{
"id": "2977269882132774",
"clientOrderId": ""
}
Create Multiple Orders
- POST
https://api.poloniex.com/orders/batch
Create multiple orders via a single request. Max limit of 20 orders. Request parameter is an array of json objects with order details.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
symbol | String | true | The symbol to trade, like BTC_USDT |
side | String | true | BUY, SELL |
timeInForce | String | false | GTC, IOC, FOK (Default: GTC) |
type | String | false | MARKET, LIMIT, LIMIT_MAKER (for placing post only orders). Default type is MARKET. |
accountType | String | false | SPOT is the default and only supported one. |
price | String | false | Price is required for non-market orders |
quantity | String | false | Base units for the order. Quantity is required for MARKET SELL or any LIMIT orders |
amount | String | false | Quote units for the order. Amount is required for MARKET BUY order |
clientOrderId | String | false | Maximum 64-character length.* |
allowBorrow | Boolean | false | allow order to be placed by borrowing funds (Default: false) |
stpMode | String | false | self-trade prevention. Defaults to EXPIRE_TAKER. None: enable self-trade; EXPIRE_TAKER: Taker order will be canceled when self-trade happens |
slippageTolerance | String | false | Used to control the maximum slippage ratio, the value range is greater than 0 and less than 1 |
*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(-)
Array of json objects with results for each order details.
Response Field | Data Type | Description |
---|---|---|
id | String | order id |
clientOrderId | String | clientOrderId user specifies in request or an empty string. |
Example:
Request:
[
{
"symbol": "BTC_USDT",
"amount": "100",
"side": "BUY"
},
{
"symbol": "BTC_USDT",
"type": "LIMIT",
"quantity": "100",
"side": "BUY",
"price": "40000.50000",
"timeInForce": "IOC",
"clientOrderId": "1234Abc"
},
{
"symbol": "ETH_USDT",
"amount": "1000",
"side": "BUY"
},
{
"symbol": "TRX_USDT",
"type": "LIMIT",
"quantity": "15000",
"side": "SELL",
"price": "0.0623423423",
"timeInForce": "IOC",
"clientOrderId": "456Xyz"
}
]
Response:
[
{
"id": "2977269882132774",
"clientOrderId": ""
},
{
"id": "29772698821328896",
"clientOrderId": "1234Abc"
},
{
"code": 21709,
"message": "Low available balance",
"clientOrderId": ""
},
{
"code": 21312,
"message": "Client order id repeat",
"clientOrderId": "456Xyz"
}
]
Cancel Replace Order
- PUT
https://api.poloniex.com/orders/{id}
- PUT
https://api.poloniex.com/orders/cid:{clientOrderId}
Cancel an existing active order, new or partially filled, and place a new order on the same symbol with details from existing order unless amended by new parameters. The replacement order can amend price, quantity, amount, type, timeInForce, and allowBorrow fields. Specify the existing 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 order placement in case cancelation of the existing order fails. Please note that since the new order placement does not wait for funds to clear from the existing order cancelation, it is possible that the new order will fail due to low available balance.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
clientOrderId | String | false | clientOrderId of the new order* |
price | String | false | amended price |
quantity | String | false | amended quantity |
amount | String | false | amended amount (needed for MARKET buy) |
type | String | false | amended type; MARKET, LIMIT, LIMIT_MAKER (for placing post only orders) |
timeInForce | String | false | amended timeInForce; GTC, IOC, FOK (Default: GTC) |
allowBorrow | Boolean | false | allow order to be placed by borrowing funds (Default: false) |
proceedOnFailure | String | false | if set to true then new order will be placed even if cancelation of the existing order fails; if set to false (DEFAULT value) then new order will not be placed if the cancelation of the existing order fails |
slippageTolerance | String | false | Used to control the maximum slippage ratio, the value range is greater than 0 and less than 1 |
*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 order |
clientOrderId | String | clientOrderId of the new order if specified or an empty string |
Example request 1 (cancel and replace an order's price):
Request:
{
"clientOrderId": "1234Abc"
"price": "18000"
}
Response:
{
"id": "29772698821328896",
"clientOrderId": "1234Abc"
}
Example request 2 (cancel and replace an order that is already filled):
Request:
{
"clientOrderId": "1234Abc"
"price": "18000",
"quantity": "20"
}
Response:
{
"code": 21359,
"message": "Order was already canceled or filled."
}
Open Orders
- GET
https://api.poloniex.com/orders
Get a list of active orders for an account.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
symbol | String | false | The symbol to trade,like BTC_USDT. Default is for all symbols if not specified. |
side | String | false | BUY, SELL |
from | Long | false | it is 'orderId'. The query begin at ‘from', and it is 0 when you first query. |
direction | String | false | PRE, NEXT |
limit | Integer | false | Max number of records to return. Default is 500. Max value is 2000. |
Response Field | Data Type | Description |
---|---|---|
id | String | order id |
clientOrderId | String | user specified id |
symbol | String | The symbol to trade,like BTC_USDT |
state | String | order state: NEW,PARTIALLY_FILLED |
accountType | String | SPOT |
side | String | BUY, SELL |
type | String | MARKET, LIMIT, LIMIT_MAKER |
timeInForce | String | GTC, IOC, FOK |
quantity | String | base units for the order |
price | String | |
avgPrice | String | avgPrice = filledAmount/filledQuantity |
amount | String | quote units for the order |
filledQuantity | String | |
filledAmount | String | |
createTime | Long | |
updateTime | Long | |
orderSource | String | source of the order e.g API, APP, WEB |
loan | Boolean | true if borrowed funds, false otherwise |
Example output:
[
{
"id": "24993088082542592",
"clientOrderId": "",
"symbol": "ELON_USDC",
"state": "NEW",
"accountType": "SPOT",
"side": "SELL",
"type": "MARKET",
"timeInForce": "GTC",
"quantity": "1.00",
"price": "0.00",
"avgPrice": "0.00",
"amount": "0.00",
"filledQuantity": "0.00",
"filledAmount": "0.00",
"createTime": 1646925216548,
"updateTime": 1646925216548,
"orderSource": "API",
"loan": false,
},
{
"id": "21934611974062080",
"clientOrderId": "123",
"symbol": "TRX_USDC",
"state": "NEW",
"accountType": "SPOT",
"side": "SELL",
"type": "LIMIT",
"timeInForce": "GTC",
"quantity": "1.00",
"price": "10.00",
"avgPrice": "0.00",
"amount": "0.00",
"filledQuantity": "0.00",
"filledAmount": "0.00",
"createTime": 1646196019020,
"updateTime": 1646196019020,
"orderSource": "API",
"loan": true
}
]
Order Details
- GET
https://api.poloniex.com/orders/{id}
- GET
https://api.poloniex.com/orders/cid:{clientOrderId}
Get an order’s status. Either by specifying orderId or clientOrderId. If id is a clientOrderId, prefix with cid: e.g. cid:myId-1
Request Parameter | Data Type | Required | Description |
---|---|---|---|
id | String | true | Either orderId or clientOrderId (prefix with cid: ) |
Response Field | Data Type | Description |
---|---|---|
id | String | order id |
clientOrderId | String | user specified id |
symbol | String | The symbol to trade, like BTC_USDT |
state | String | NEW, PARTIALLY_FILLED, FILLED, PENDING_CANCEL, PARTIALLY_CANCELED, CANCELED, FAILED |
accountType | String | SPOT |
side | String | BUY, SELL |
type | String | MARKET, LIMIT, LIMIT_MAKER |
timeInForce | String | GTC, IOC, FOK |
quantity | String | base units for the order |
price | String | |
avgPrice | String | avgPrice = filledAmount/filledQuantity |
amount | String | quote units for the order |
filledQuantity | String | |
filledAmount | String | |
createTime | Long | |
updateTime | Long | |
orderSource | String | source of the order e.g API, APP, WEB |
loan | Boolean | true if borrowed funds, false otherwise |
cancelReason | Integer | code specified to provide reason for cancelation if applicable; 0: "Not applicable"; 1: "As requested by user"; 1000-1999: "Due to breach of controls in matching engine; 1004: "Due to self-trade"; 1012: "exceed slippage tolerance"; 2000: "Due to margin liquidation"; 2001: "Due to margin threshold breach"; 2002: "Due to symbol marked as offline" |
Example output:
{
"id": "21934611974062080",
"clientOrderId": "123",
"symbol": "TRX_USDC",
"state": "NEW",
"accountType": "SPOT",
"side": "SELL",
"type": "LIMIT",
"timeInForce": "GTC",
"quantity": "1.00",
"price": "10.00",
"avgPrice": "0.00",
"amount": "0.00",
"filledQuantity": "0.00",
"filledAmount": "0.00",
"createTime": 1646196019020,
"updateTime": 1646196019020,
"orderSource": "API",
"loan": false,
"cancelReason": 0,
}
Cancel Order by Id
- DELETE
https://api.poloniex.com/orders/{id}
- DELETE
https://api.poloniex.com/orders/cid:{clientOrderId}
Cancel an active order.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
id | String | true | order's id or its clientOrderId (prefix with cid: ) |
Response Field | Data Type | Description |
---|---|---|
orderId | String | the order id |
clientOrderId | String | clientOrderId of the order. |
state | String | order's state (PENDING_CANCEL) |
code | Integer | response code. |
message | String | response message. |
Example output:
{
"orderId": "32487004629499904",
"clientOrderId": "54321",
"state": "PENDING_CANCEL",
"code": 200,
"message": ""
}
Cancel Multiple Orders by Ids
- DELETE
https://api.poloniex.com/orders/cancelByIds
Batch cancel one or many active orders in an account by IDs.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
orderIds | String | No, except clientOrderIds is null or empty | List of order id |
clientOrderIds | String | No, except orderIds is null or empty | List of clientOrderId |
Response Field | Data Type | Description |
---|---|---|
orderId | String | the order id |
clientOrderId | String | clientOrderId of the order. |
state | String | order's state (PENDING_CANCEL) |
code | Integer | response code. |
message | String | response message. |
Example request (body is required, parameters could be optional):
Request:
{
"orderIds": ["12345", "67890"],
"clientOrderIds": ["33344", "myId-1"]
}
Response:
[
{
"orderId": "12345",
"clientOrderId": "33344",
"state": "PENDING_CANCEL",
"code": 200,
"message":""
},
{
"orderId": "67890",
"clientOrderId": "myId-1",
"state": "PENDING_CANCEL",
"code": 200,
"message":""
}
]
Cancel All Orders
- DELETE
https://api.poloniex.com/orders
Batch cancel all orders in an account.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
symbols | String array | false | If symbols are specified then all orders with those symbols will be canceled. If symbols are not specified or array is empty, it will cancel user's all orders for all symbols. |
accountTypes | String array | false | SPOT is the default and only supported one. |
Response Field | Data Type | Description |
---|---|---|
orderId | String | the order id |
clientOrderId | String | clientOrderId of the order. |
state | String | order's state (PENDING_CANCEL) |
code | Integer | response code. |
message | String | response message. |
Example request (body is required, but parameters are optional; an empty body implies cancelling all orders):
Request:
{
"symbols": ["BTC_USDT", "ETH_USDT"],
"accountTypes": ["SPOT"]
}
Response:
[{
"orderId": "111222333444",
"clientOrderId": "666666",
"state": "PENDING_CANCEL",
"code": 200,
"message": "SUCCESS"
},
{
"orderId": "333444555666",
"clientOrderId": "777777",
"state": "PENDING_CANCEL",
"code": 200,
"message": "SUCCESS"
}]
Kill Switch
- POST
https://api.poloniex.com/orders/killSwitch
Set a timer that cancels all regular and smartorders after the timeout has expired. Timeout can be reset by calling this command again with a new timeout value. A timeout value of -1 disables the timer. Timeout is defined in seconds.
Request Parameter | Data Type | Required | Description |
---|---|---|---|
timeout | String | true | timer value in seconds; range is -1 and 10 to 600 |
Response Field | Data Type | Description |
---|---|---|
startTime | Long | time when timer is started (milliseconds since UNIX epoch) |
cancellationTime | Long | time when timer is set to expire which will trigger cancellation (milliseconds since UNIX epoch) |
Enable kill switch with a timeout of 60 seconds:
{
"timeout": "60"
}
> Example output:
```json
{
"startTime": "1665456130",
"cancellationTime": "1665456190"
}
Disable kill switch:
{
"timeout": "-1"
}
Example output:
{
"startTime": "1665456160",
"cancellationTime": "0"
}
Kill Switch Status
- GET
https://api.poloniex.com/orders/killSwitchStatus
Get status of kill switch. If there is an active kill switch then the start and cancellation time is returned. If no active kill switch then an error message with code is returned
Response Field | Data Type | Description |
---|---|---|
startTime | Long | time when timer is started (milliseconds since UNIX epoch) |
cancellationTime | Long | time when timer is set to expire which will trigger cancellation (milliseconds since UNIX epoch) |
No active kill switch example output:
Request:
{
"startTime": "1665456130",
"cancellationTime": "1665456190"
}
Response:
{
"code": 25020,
"message": "No active kill switch"
}