🖥️
AutoShares
  • Deploy Apps with AutoShares API
  • User guide
    • Introduction
    • Web Trader
      • Getting Started
      • Platform Layout
      • User Widgets
        • Account Information
        • Account Opening
          • Account Funding
            • ACH Transfers
            • Check Transfers
            • Wire Transfers
        • Chart
        • News
        • Trade Ticket
          • Mutual Funds Trade Ticket
        • Watchlists
        • Orders
        • Positions
        • Market Depth
        • Options
        • Hotkeys
    • Digital Advisor
      • Getting Started
      • Selecting an Investment Model
      • Portfolio Tab
      • Trading Tab
      • Activity Tab
      • Funding Tab
    • WebTrader for iOS
      • Getting Started
      • App Layout
      • Watchlist & Quotes View
        • Trade View
          • Stock Trading
          • Options Trading
      • Positions View
      • Orders View
      • Price Alerts View
      • Account View
      • Apple Watch Extension
    • Web Trader for Android
      • Getting Started
      • App Layout
      • Watchlist & Quote View
        • Trade View
      • Price Alerts
      • Accounts & Settings
    • Knowledge Base
      • Troubleshooting
        • Performance
          • Tips for Enhancing Performance
      • How-To Guides
        • Trading Accounts
          • How to Create a New Trading Account
        • Security
          • How to Enable Two-Factor Authentication
  • REST API
    • Introduction
    • Trading API
      • Overview
      • Authentication
        • Single-Factor Authentication
          • Syntax
        • Two-Factor Authentication
          • Syntax
      • User Registration
        • Get Required Fields
        • Register a User
      • Managing Users
        • Get User's Info
          • Syntax
        • Get User's Trading Settings
        • Get Mobile App Settings
        • Get User's Exchanges
        • Modify User's Settings
        • Update User's Password
      • Trading Accounts
        • Get Account's Balance Info
          • Syntax
        • Get Account's History
          • Syntax
        • List User's Accounts
          • Syntax
      • Password Reset
        • 1. Reset Trader's Password
        • 2. Retrieve the Secret Question
        • 3. Generate a Token For a New Password
        • 4. Update the Password
      • Trading Accounts
        • Open a New Trading Account
      • Account Funding
        • Create an ACH Relationship
        • Get an ACH Relationship
        • Get All ACH Relationships
        • Get the Default ACH Relationship
        • Modify an ACH Relationship
        • Delete an ACH Relationship
        • Approve an ACH Relationship
        • Deposit / Withdraw Funds via ACH
        • Cancel an ACH Transfer
        • Get All Transfers
      • Orders
        • Verify Order Placement
          • Syntax
        • Place Order
          • Syntax
        • Verify Order Replacement
          • Syntax
        • Replace Order
          • Syntax
        • Cancel an Order
          • Syntax
        • Get Order's Info
          • Syntax
        • Get Filtered Orders
          • Syntax
      • Positions
        • Get User's Positions
          • Syntax
        • Get User's Positions in a Security
          • Syntax
        • Get Market Value of all Security Groups
      • Securities
        • Get Equity Info by Internal ID
          • Syntax
        • Get Equity Info by Ticker
          • Syntax
        • Get Equity Info by Mask
          • Syntax
        • Get Filtered Equities
          • Syntax
        • Get Option Info by Internal ID
          • Syntax
        • Get Option Info by Ticker
          • Syntax
        • Get Options Expiration Dates
          • Syntax
        • Get an Option Chain
        • Get Filtered Options
          • Syntax
      • Watchlists
        • Add Security to Watchlist by ID
          • Syntax
        • Add Security to Watchlist by Ticker
          • Syntax
        • Create New Watchlist
          • Syntax
        • Delete Watchlist
          • Syntax
        • Get Specific Watchlist
          • Syntax
        • Get User's Watchlists
          • Syntax
        • Remove Security From Watchlist by ID
          • Syntax
        • Remove Security from Watchlist by Ticker
          • Syntax
        • Rename Watchlist
          • Syntax
      • Price Alerts
        • Create Price Alert
          • Syntax
        • Delete Price Alert
          • Syntax
        • Get Specific Alert
          • Syntax
        • Get User's Price Alerts
          • Syntax
        • Modify Price Alert
          • Syntax
      • Historical Data
        • Get Comparison Chart Data
          • Syntax
        • Get Candles and Indicators for a Security
          • Syntax
        • Get Chart Data in the Excel Format
          • Syntax
      • News
        • Get News for a Security
        • Get Corporate Actions for a Security
      • User Feedback
        • Submit Feedback
          • Syntax
      • Managing Transactions
        • Get Transactions
          • Syntax
      • Streaming Data
        • Quotes
        • Orders
        • Positions
        • Watchlists
        • Account Balances
      • Code Samples
        • Basic Authentication
        • Two-Factor Autentication
        • Placing New Orders
        • Get User Information
        • List User Positions
        • Get Trading Data for Charts
      • Terms and Definitions
        • Part I
        • Part II
        • Part III
Powered by GitBook
On this page
  • Overview
  • Security Type
  • Common Mistakes
  • Failing to Specify the Et-App-Key Parameter
  • Specifying the User ID Instead of the Trading Account ID
  • Specifying a Trading Account of a Different User
  1. REST API
  2. Trading API
  3. Positions

Get User's Positions

List all existing positions of a user

PreviousPositionsNextSyntax

Last updated 4 years ago

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:

  1. Et-App-Key (header). This is the unique key of your app that identifies your app when communicating with our service. Contact your administrator to get this key.

  2. Authorization (header). This is the authorization token from the very first .

  3. API version (path). Unless necessary, leave it at "1.0".

  4. accountId (path). This is the numeric ID of the trading account whose positions must be listed.

  5. pageNumber (query). This is the number of the page (all positions are split in pages).

  6. pageSize (query). This is the preferable size of the page (maximum value is 99).

  7. sortField (query). This is a position parameter by which all returned positions must be sorted.

  8. 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

  • CreateDate (>, >=, <, <=) Date

  • CreateDate between Range

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.

  • 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#

  • ModifyDate (>, >=, <, <=) Date

  • ModifyDate between Range

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.

  • ModifyDate between #2019-03-13T18:31:42# and #2019-03-17T18:31:42#

  • ModifyDate >= #2019-03-13T18:31:42#

  • ModifyDate < #2019-03-12T19:31:42#

  • Quantity (>, >=, <, <=) Number

  • Quantity between Range

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.

  • Quantity = 100

  • Quantity >= 100

  • Quantity between 100 and 1000

  • SecurityId = Number

This query enables you to retrieve positions whose securityId parameter is equal to the Id provided in the query.

  • SecurityId = 4

  • Symbol = String

This query enables you to retrieve positions whose underlying security's ticker symbol is equal to the string provided in the query.

  • Symbol = 'AAPL'

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:

GET apiURL/v1.0/accounts/{accountId}/positions?pageNumber=0&pageSize=10&sortField=Id&desc=true
[
    {
        "Id": 21483,
        "AccountId": 6303,
        "SecurityId": 4,
        "Symbol": "AAPL",
        "Name": "AAPL",
        "CompanyName": "Apple Inc.",
        "SecurityCurrency": "USD",
        "SecurityType": "CommonStock",
        "ContractSize": 1,
        "CostBasis": 23485.5,
        "DailyCostBasis": 25414.5,
        "CreateDate": "2019-01-22T14:30:03.7328576Z",
        "ModifyDate": "2019-01-22T14:30:03.7328576Z",
        "Quantity": 150,
        "RealizedProfitLoss": 0,
        "AverageOpenPrice": 156.57,
        "AverageClosePrice": 0,
        "StopLossPrice": 0,
        "TakeProfitPrice": 0,
        "DailyCloseProfitLoss": 0,
        "ExcessChanges": 0,
        "DayQuantity": 0,
        "MarketValueEOD": 645.19
    }
]

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 underlying 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 underlying 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

BankersAcceptance                     = 0,
CertificateOfDeposit                  = 1,
CollateralizeMortgageObligation       = 2,
CorporateBond                         = 3,
CommercialPaper                       = 4,
CorporatePrivatePlacement             = 5,
CommonStock                           = 6,
FederalHousingAuthority               = 7,
FederalHomeLoan                       = 8,
FederalNationalMortgageAssociation    = 9,
ForeignExchangeContract               = 10,
Future                                = 11,
GovernmentNationalMortgageAssociation = 12,
TreasuriesPlusAgencyDebenture         = 13,
MutualFund                            = 14,
MortgageInterestOnly                  = 15,
MortgagePrincipleOnly                 = 16,
MortgagePrivatePlacement              = 17,
MiscellaneousPassThru                 = 18,
MunicipalBond                         = 19,
NoIsitcSecurityType                   = 20,
Option                                = 21,      
PreferredStock                        = 22,
RepurchaseAgreement                   = 23,
ReverseRepurchaseAgreement            = 24,
StudentLoanMarketingAssociation       = 25,
TimeDeposit                           = 26,
UsTreasuryBill                        = 27,
Warrant                               = 28,
CatsTigersLions                       = 29,
WildcardEntry                         = 30,
ConvertibleBond                       = 31,
MortgageIoette                        = 32,
Index                                 = 33,
FakeStockForNonStandartOption         = 34,
Right                                 = 35,
Cryptocurrency                        = 36,
ETF                                   = 37,
DepositoryReceipt                     = 38,
CoveredWarrant                        = 39,
Unit                                  = 40

Common Mistakes

Here are some of the common mistakes that developers make when attempting to list the existing positions.

Failing to Specify the Et-App-Key Parameter

If you specify the wrong Et-App-Key parameter or fail to include it in the header altogether, you'll get the following error:

{
    "error": "Application key is not defined or does not exist"
}

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:

{
    "message": "An error occurred while processing your request",
    "error": "Unexpected server error"
}

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.

{
    "Message": "Authorization has been denied for this request."
}

In the following article we provide in-depth coverage of the syntax for this API request.

token request