Get User's Positions
List all existing positions of a user
Overview
This GET endpoint enables you to list all existing positions of the user whose authorization token was used in the request's path.
There are eight 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).API version (path). Unless necessary, leave it at "1.0".
accountId (path). This is the numeric ID of the trading account whose positions must be listed.
pageNumber (query). This is the number of the page (all positions are split in pages).
pageSize (query). This is the preferable size of the page (maximum value is 99).
sortField (query). This is a position parameter by which all returned positions must be sorted.
desc (query). This boolean parameter indicates if the returned positions should be sorted in ascending (false) or descending (true) order.
There's also one optional parameter worth examining:
filter (query). This is an SQL query used to retrieve only those positions that satisfy the conditions of the query. The following table outlines the parameter's syntax.
Syntax | Description | Example |
---|---|---|
| This query enables you to retrieve positions that were created in the time period specified in the Range parameter or exactly at the time specified in the Date parameter. |
|
| This query enables you to retrieve positions that were modified in the time period specified in the Range parameter or exactly at the time specified in the Date parameter. |
|
| This query enables you to retrieve positions with the number of securities being in the range indicated in the Range parameter or equal to the number in the Number parameter. |
|
| This query enables you to retrieve positions whose securityId parameter is equal to the Id provided in the query. |
|
| This query enables you to retrieve positions whose ticker symbol is equal to the string provided in the query. |
|
Note that you can combine different queries to create more complex requests:
SecurityId = 4 and CreateDate >= #2019-03-13T18:31:42#
Here's the final template for this API request:
where:
Parameter | Description |
---|---|
Id | This is the internal ID of the position |
AccountID | This is the account ID that was provided in the request's header |
SecurityId | This is the internal ID of the security in the position |
Symbol | This is the ticker symbol |
Name | In most cases this field is identical to Symbol |
CompanyName | This is the full name of the listed company |
SecurityCurrency | This is the currency in which the security is denominated |
SecurityType | This is the type of the security. The range of possible values is listed in the following table. |
ContractSize | This is the minimum contract size for this financial instrument. |
CostBasis | This is the average execution price multiplied by the number of shares |
DailyCostBasis | This is the gross market value of all transactions in this order |
CreateDate | This is the date on which the order was created |
ModifyDate | This is the date on which the order was last modified |
Quantity | This is the number of shares in the order |
RealizedProfitLoss | This is the realized profit or loss of this position |
AverageOpenPrice | The average opening price of all positions. This variable is calculated for positions of the same type — either Long or Short (you can't simultaneously open a long and a short position on the same instrument) |
AverageClosePrice | The average closing price of all positions. This variable is calculated for positions of the same type — either Long or Short (you can't simultaneously open a long and a short position on the same instrument) |
StopLossPrice | This the price at which the position should be terminated (if this price point is reached) |
TakeProfitPrice | This is the price point at which the profit should be realized (if this price point is reached). |
DailyCloseProfitLoss | This is the gross profit or loss of all trades of this security made during the current trading session. |
Excess Changes | This indicates how much this position affects your account's excess. |
DayQuantity | This is the gross number of shares of this security that have been traded during the current trading session. |
MarketValueEOD | This is the market value of the position registered at the end of the previous trading session. |
Security Type
Common Mistakes
Here are some of the common mistakes that developers make when attempting to list the existing positions.
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 trading accounts can be used for listing current positions. Placing a new order on a trading account 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