Get Filtered Orders
List a user's outstanding and executed orders
Overview
This GET endpoint enables to you list all outstanding and executed orders of the user whose authorization token was used in the request header. Optionally, you can filter the list by a set of criteria provided in the request's body.
There are six required parameters that must be provided in the request:
Authorization (header). This is the authorization token from the very first token request. The value of this header must have the following format:
Bearer BQ898r9fefi
(Bearer
+ 1 space + the token).Trading Account ID (path). This is the numeric ID of the trading account whose orders must be retrieved.
API version (path). Unless necessary, leave it at "1.0".
pageNumber (query). Because there can be dozens of outstanding orders, we split them into pages which you can individually retrieve by specifying this parameter.
pageSize (query). This parameter indicates the number of orders from a particular page that must be returned in the response. The maximum value for this parameter is 100.
There's also three optional parameters worth examining:
filter (query). This is a query used to retrieve only those orders that satisfy the conditions of the query. The following table outlines the parameter's syntax.
sortField (query).This is a parameter by which the returned orders must be sorted. For example, if you set this parameter to
Quantity
, all returned orders will be sorted by the number of purchased lots.desc (query). This parameter indicated if the returned orders should be sorted in ascending or descending order.
Sample queries below must be converted depending on the used encoding. For example, the #
sign must be converted to %23
and so on.
CreateDate (>, >=, <, <=) Date
CreateDate between Range
This query enables you to retrieve orders that were created in the time period specified in the Range parameter or exactly at the time specified in the Date parameter.
(This filter will be supported starting from version 2.70)
CreateDate between #2019-03-13T18:31:42# and #2019-03-17T18:31:42#
CreateDate >= #2019-03-13T18:31:42#
CreateDate < #2019-03-12T19:31:42#
SecurityId = Number
This query enables you to retrieve orders whose securityId parameter is equal to the Id provided in the query.
SecurityId = 4
Status in (value1, value2, etc.)
This query enables you to retrieve orders whose Status parameter is contained in the query set.
Status in (0,1,4,5,7)
Status in (0)
Note that you can combine different queries to create more complex requests:
SecurityId = 4 and Status in (0,1,2,3,4,5,6,7,8,9,20)
Here's the final template for this API request:
For orders that will only be verified by the API but not the execution venue (quick):
For orders that will be verified by the API and the execution venue too (slow):
Response
In response to this API request, you'll receive the following JSON file that lists the specified number of orders
where:
Id
This is the internal ID of the order.
SecurityId
This is the internal ID of the underlying security of the order.
Quantity
This is the number of shares in the order.
StopPrice
This is the stop price of the order (if there's no stop price — the value of this parameter will be 0).
ClientId
This is the order ID on the client's side.
ExecutedQuantity
This is the number of shares that have been purchased or sold.
LastPrice
This is the price of the last executed order for the underlying security.
LastQuantity
This is the number of shares that were traded in the last transaction.
LeavesQuantity
This is the number of shares in the order that are yet to be purchased.
AveragePrice
This is the average price at which the order was executed.
Side
This is the type of order (could be "Buy", "Sell", "SellShort", or "BuyToCover").
Date
This is the date on which the order was placed by the user.
TransactionDate
This is the date on which the transaction took place.
Status
This is the current status of the order. Possible values:
0 - New
1 - Partially Filled
2 - Filled
3 - Done For Day
4 - Canceled
5 - Replaced
6 - Pending Cancel
7 - Stopped
8 - Rejected
9 - Suspended
10 - Pending New
11 - Calculated
12 - Expired
13 - Accepted For Bidding
14 - Pending Replace
15 - Error
ExecutionStatus
The status of the current operation with the order. The value is usually identical to Status
except for cases in which the order's status was manually modified. For brokers developing their own UI, it's preferable to use the Status
parameter to display the current status of the order.
TimeInForce
Indicates the time frame in which the order will be active. Possible Values:
Day. The order automatically expires at the end of the regular trading session if it weren't executed.
GTC (Good-till-Canceled). The order persists indefinitely until it is executed or manually cancelled.
AtTheOpening. The order should be filled at the opening of the marketplace or cancelled.
ImmediateOrCancel. The order should be completely or partially filled immediately. If partially filled, the remaining part of the order should be cancelled.
FillOrKill. The order should be filled immediately and entirely or cancelled right away.
GoodTillCrossing. The order will be active until the market enters the auction phase.
GoodTillDate. The order will be active until the date specified in the ExpireDate attribute (unless it is executed or cancelled).
GoodTillTime. The order will be active until a certain time point.
Common Mistakes
Here are some of the common mistakes that developers make when requesting the list of all outstanding and executed orders.
Specifying the User ID Instead of the Trading Account ID
Another common mistake when making this request is specifying the user ID instead of the user's trading account ID. Doing so will result in the 500 status code and the following error message:
Specifying a Trading Account of a Different User
It's critical to understand that when you use the authorization token of a particular user in this request's header, only this user's orders can be listed. Listing orders of a different user will lead to the 401 error.
In the following article we provide in-depth coverage of the syntax for this API request.
Last updated