AutoShares API
  • What is AutoShares?
  • API Documentation
    • Quick Start Guide
    • API Overview
    • Authentication
      • Authenticate with AutoShares SSO/Auth0
      • Triggering authentication with /login
      • For logout scenario
    • Onboarding Users
      • Account Setup
        • Syntax
        • Add Account To User
        • Add Account To User By Username
        • Get All Accounts Of A User
        • Get All Users Of An Account
        • Get Account Info
        • Update Alias Account For Current User
        • Remove Account From User
        • Get User's Trading Settings
        • Get User's Exchanges
      • Access Agreements
    • Account Balances and Buying Power
      • Get Balance Information For A User
      • Get Account's Balance Info
      • Get Historical Account Value
    • Order Processing and Trading
      • Place Order
        • Syntax
      • Verify Order Placement
        • Syntax
      • Verify Order Replacement
        • Syntax
      • Replace Order
        • Syntax
      • Cancel an Order
        • Syntax
      • Get Order's Info
        • Syntax
      • Get Filtered Orders
        • Syntax
      • Validate Order by ID
      • Positions
        • Get User's Positions
          • Syntax
        • Get User's Positions in a Security
          • Syntax
        • Get Market Value of all Security Groups
      • Managing Transactions
        • Get Transactions
          • Syntax
    • Streaming Data and Quotes
      • Streaming API Endpoints
        • Get Streamers' Info
        • Recover a Streamer Session
      • Quotes
      • Orders
      • Positions
      • Watchlists
      • Account Balances
      • User Balance
      • 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
        • Get Company Logo By Symbol
    • Historical Chart Data
      • Get Comparison Chart Data
        • Syntax
      • Get Candles and Indicators for a Security
        • Syntax
      • Get Chart Data in the Excel Format
        • 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
    • 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
      • News
        • Get News for a Security
        • Get Corporate Actions for a Security
    • [Webhooks and SDKs]
    • Wires, ACH, and Account Transfers
      • ACH Setup
        • Create A New ACH Relationship
        • Get an ACH Relationship
        • Modify an ACH Relationship
      • Deposit / Withdraw Funds
        • Deposit / Withdraw Funds via ACH
      • Get a Transfer's Info
        • Get an ACH Transfer's Info
        • Get All Transfers
    • Terms and Definitions
      • Part I
      • Part II
      • Part III
Powered by GitBook
On this page
  • Overview
  • Request Body
  • Smallest Limit Order Sample
  • Smallest Stop Order Sample
  • Smallest Stop-Limit Order Sample
  • Smallest Limit Order Sample (Options)
  • Complex Order Sample (Options)
  • Multi-Leg Order Sample (Option + Option)
  • Comprehensive Limit Order Sample
  • Comprehensive Market Order Sample
  • Comprehensive Stop Order Sample
  • Comprehensive Stop Limit Order Sample
  • Comprehensive Trailing Stop Order Type
  • Comprehensive Trailing Stop Limit Order Type
  • One-Triggers-the-Other Order Type
  • One-Cancels-the-Other Order Type
  • Response
  • 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
  • Placing Orders Whose Value Exceeds the Account's Buying Power
  • Failing to Specify the Limit Price for Limit Orders
  • Failing to Specify the Stop Price for Stop-Loss Orders
  1. API Documentation
  2. Order Processing and Trading

Place Order

Place a new order

PreviousOrder Processing and TradingNextSyntax

Last updated 1 year ago

Overview

This POST endpoint enables you to place a new order in AutoShares. The order is sent in the JSON format to our service which turns it into a new outstanding order that should eventually be fulfilled.

There are the required parameters that must be provided in the request:

  1. Authorization (header). This is the authorization token from the very first . The value of this header must have the following format: Bearer BQ898r9fefi (Bearer + 1 space + the token).

  2. Trading Account ID (path). This is the numeric ID of the trading account on which a new order must be placed.

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

  4. body (body of the request). This is a JSON file that contains the order's characteristics.

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):

POST apiURL/v1.0/accounts/{accountID}/orders
  • For orders that will be verified by the API and the execution venue too (slow):

POST apiURL/v1.0/accounts/{accountID}/syncorders

Request Body

The body of this request represents the information about the to-be-created order. It must be sent in the JSON format with the parameters described in the following table:

Parameter
Description

Symbol

This is the ticker symbol of the underlying security in the new order.

ClientId

This is the order ID on the client's side.

ExpireDate

This is the expiration of the order. If the order isn't executed until the specified date, it'll automatically be cancelled.

Type

This is the type of the order. The range of possible values includes: Market, Limit, Stop, Stop Limit.

Side

This is the side of the trade. The range of possible values includes: Buy, Sell, SellShort, BuyToCover.

ExecInst

Indicates if the order should be filled either entirely in one transaction or not at all. Possible value: 'AllOrNone'.

TimeInforce

Indicates the time frame in which the order will be active. Possible Values:

  1. Day. The order automatically expires at the end of the regular trading session if it weren't executed.

  2. GoodTillCancel (Good-till-Canceled). The order persists indefinitely until it is executed or manually cancelled.

  3. GoodTillDate. The order will be active until the date specified in the ExpireDate attribute (unless it is executed or cancelled).

Quantity

The number of shares in the order.

Price

The price at which the shares must be purchased.

StopPrice

When this price is reached, the order will automatically be converted into a market order.

Exchange

This is the exchange on which the order should be executed.

TrailingStopAmountType

This is the type of the trailing stop (Absolute or Persentage).

TrailingStopAmount

This is the trailing amount of the trailing stop (in percentage terms or in the currency units).

TrailingLimitAmountType

This is the type of the trailing limit (Absolute or Persentage).

TrailingLimitAmount

This is the trailing amount (in percentage terms or in the currency units).

ExtendedHours

Indicates if the order should be placed during the extended hours (pre-market session, post-market session).

ExecutionInstructions

Execution instructions of the order. May include the following data:

  • "PerTradeCommission": "1". Specified in dollars ($1 per trade).

  • "PerContractCommission":"1". Specified in cents (1 cent per contract).

Legs

These are the legs of a multi-leg order.

{
  "Symbol": "AAPL", //Buying 100 shares of the Apple stock
  "Type": "Market",
  "Side": "Buy",
  "Quantity": 100
}

Smallest Limit Order Sample

{
  "Symbol": "AAPL", //Buying 100 shares of the Apple stock
  "Type": "Limit",
  "Side": "Buy",
  "Quantity": 100,
  "Price" : 170 //The limit price of the order
}

Smallest Stop Order Sample

{
  "Symbol": "AAPL", //Buying 100 shares of the Apple stock
  "Type": "Stop",
  "Side": "Buy",
  "Quantity": 100,
  "StopPrice" : 150 //The stop price of the order
}

Smallest Stop-Limit Order Sample

{
  "Symbol": "AAPL", //Buying 100 shares of the Apple stock
  "Type": "StopLimit",
  "Side": "Buy",
  "Quantity": 100,
  "StopPrice" : 149, //The stop price of the order
  "Price": 150 //The limit price of the order
}

Smallest Limit Order Sample (Options)

{
  "Symbol": "STNE  190517P00055000", //the option's OSI Symbol
  "ExpireDate": "2019-03-24T17:32:28.824Z",
  "Type": "Limit",
  "Side": "Buy",
  "Price":170,
  "ExecInst": "AllOrNone",
  "TimeInforce": "Day",
  "Quantity": 1,
}

Complex Order Sample (Options)

{
  "Symbol": "AAPL  190503C00165000", //the option's OSI Symbol
  "ExpireDate": "2019-03-30T17:00:00.824Z",  
  "Type": "Limit",
  "Side": "Buy",
  "Price":170,
  "ExecInst": "AllOrNone",
  "TimeInforce": "Day",
  "Quantity": 1,
  "Legs": [{ //simultaneously buying the Apple stock
            "Symbol": "AAPL", 
            "Type": "Market",
            "Side": "Buy",
            "Quantity": 100
        }
    ]
}

Multi-Leg Order Sample (Option + Option)

All legs of a multi-leg order should contain only three parameters:

  1. Ticker symbol

  2. Quantity

  3. Side

All other parameters like the order's type and limit price must be specified outside the legs as the root parameters applicable to all legs.

The type of a multi-leg order must be either market or limit.

{
  "Legs": [
    {
      
      "Quantity": 2,
      "Side": "SellShort",
      "Symbol": "AAPL  200214C00327500",
      
    },
    {
      
      "Quantity": 2,
      "Side": "Buy",
      "Symbol": "AAPL  200214C00380000",
      
    }
  ],
  "ExecInst": "AllOrNone",
  "ExpireDate": "2020-11-04T08:44:17.738365+00:00",
  "Price": 0.5,
  "Quantity": 2,
  "Symbol": "",
  "TimeInForce": "Day",
  "Type": "Limit"
}

Comprehensive Limit Order Sample

{
  "Symbol": "AAPL",
  "ExpireDate": "2019-03-24T10:07:59.181Z",
  "Type": "Limit",
  "Side": "Buy",
  "ExecInst": "AllOrNone",
  "TimeInforce": "GoodTillCancel",
  "Quantity": 100,
  "Price": 190,
  "Exchange": "XNAS",
  "ExtendedHours": "REGPOST",
  "Comment": "Expecting a remarkable Q4 report",
  "ExecutionInstructions" : {"PerTradeCommission": "1", //Charging $1 for the entire transaction
                             "PerContractCommission":"1"}, //Charging 1 cent for each stock
}

Comprehensive Market Order Sample

{
  "Symbol": "AAPL",
  "ExpireDate": "2019-03-24T10:07:59.181Z",
  "Type": "Market",
  "Side": "Buy",
  "ExecInst": "AllOrNone",
  "TimeInforce": "GoodTillCancel",
  "Quantity": 445,
  "Exchange": "XNAS",
  "ExtendedHours": "PRE",
  "ExecutionInstructions" : {"PerTradeCommission": "1", //Charging $1 for the entire transaction
                             "PerContractCommission":"1"}, //Charging 1 cent for each stock
}

Comprehensive Stop Order Sample

{
  "Symbol": "AAPL",
  "ExpireDate": "2019-07-30T10:07:59.181Z",
  "Type": "Stop",
  "Side": "Buy",
  "ExecInst": "AllOrNone",
  "TimeInforce": "GoodTillCancel",
  "Quantity": 100,
  "StopPrice" : 200,
  "Exchange": "XNAS",
  "ExtendedHours": "REG",
  "ExecutionInstructions" : {"PerTradeCommission": "1", //Charging $1 for the entire transaction
                             "PerContractCommission":"1"}, //Charging 1 cent for each stock
}

Comprehensive Stop Limit Order Sample

{
  "Symbol": "AAPL",
  "ExpireDate": "2019-12-20T10:07:59.181Z",
  "Type": "StopLimit",
  "Side": "Buy",
  "ExecInst": "AllOrNone",
  "TimeInforce": "GoodTillCancel",
  "Quantity": 105,
  "Exchange": "XNAS",
  "ExtendedHours": "REGPOST",
  "Price" : 201,
  "StopPrice" : 200,
  "ExecutionInstructions" : {"PerTradeCommission": "1", //Charging $1 for the entire transaction
                             "PerContractCommission":"1"}, //Charging 1 cent for each stock
}

Comprehensive Trailing Stop Order Type

{
  "Symbol": "AAPL",
  "ExpireDate": "2019-12-20T10:07:59.181Z",
  "Type": "TrailingStop",
  "Side": "Buy",
  "ExecInst": "AllOrNone",
  "TimeInforce": "GoodTillCancel",
  "Quantity": 105,
  "Exchange": "XNAS",
  "ExtendedHours": "REGPOST",
  "TrailingStopAmountType" : "Persentage",
  "TrailingStopAmount" : 2,
  "ExecutionInstructions" : {"PerTradeCommission": "1", //Charging $1 for the entire transaction
                             "PerContractCommission":"1"}, //Charging 1 cent for each stock
}

Comprehensive Trailing Stop Limit Order Type

{
  "Symbol": "AAPL",
  "ExpireDate": "2019-12-20T10:07:59.181Z",
  "Type": "TrailingStopLimit",
  "Side": "Buy",
  "ExecInst": "AllOrNone",
  "TimeInforce": "GoodTillCancel",
  "Quantity": 1,
  "Exchange": "XNAS",
  "TrailingLimitAmountType" : "Absolute", //Limit offset
  "TrailingLimitAmount" : 4,
  "ExtendedHours": "REGPOST",
  "TrailingStopAmountType" : "Absolute", //Trailing Stop
  "TrailingStopAmount" : 10,
  "ExecutionInstructions" : {"PerTradeCommission": "1", //Charging $1 for the entire transaction
                             "PerContractCommission":"1"}, //Charging 1 cent for each stock
}

One-Triggers-the-Other Order Type

One-Triggers-the-Other is a type of conditional order in which execution of one order automatically triggers the other one. Each of the two orders has to be provided as a separate leg:

{
    "Type": "OneTriggerOther", //the type of the order
        "Symbol": "", //this parameter must be empty
        "Legs": [{ //the array of two legs
            "Symbol": "AAPL", //the first leg
            "Type": "Limit",
            "Price": 150,
            "Side": "Buy",
            "Quantity": 100
        },
        {
            "Symbol": "TSLA", //the second leg
            "Type": "Limit",
            "Price": 100,
            "Side": "Buy",
            "Quantity": 100
        }
    ]
}

In this case, if the limit order to purchase the Apple stock gets executed, the second limit order to purchase the Tesla stock will automatically be triggered.

In One-Triggers-the-Other orders, the first leg cannot be a market order.

One-Cancels-the-Other Order Type

One-Cancels-the-Other is a type of conditional order in which execution of one order automatically cancels the other one. Each of the two orders has to be provided as a separate leg:

{
    "Type": "OneCancelOther", //the type of the order
        "Symbol": "", //this parameter must be empty
        "Legs": [{ //the array of two legs
            "Symbol": "AAPL", //the first leg
            "Type": "Limit",
            "Price": 150,
            "Side": "Buy",
            "Quantity": 100
        },
        {
            "Symbol": "TSLA", //the second leg
            "Type": "Limit",
            "Price": 100,
            "Side": "Buy",
            "Quantity": 100
        }
    ]
}

In this case, if the limit order to purchase the Apple stock gets executed, the second limit order to purchase the Tesla stock will automatically be cancelled.

In One-Cancels-the-Other orders, both legs cannot be market orders.

Response

In response to this request, you'll receive a JSON file with comprehensive information about the newly created order:

{
    "Id": 80328,
    "SecurityId": 4,
    "Quantity": 100,
    "Price": 0,
    "StopPrice": 0,
    "ClientId": "2029837977",
    "ExecutedQuantity": 0,
    "LastPrice": 0,
    "LastQuantity": 0,
    "LeavesQuantity": 0,
    "AveragePrice": 0,
    "Side": "Buy",
    "Date": "2019-02-25T13:33:40.9022856Z",
    "TransactionDate": "2019-02-25T13:33:40.9022856Z",
    "SettDate": "0001-01-01T00:00:00Z",
    "Status": "PendingNew",
    "ExecutionStatus": "PendingNew",
    "Type": "Market",
    "RequestStatus": "RequireValidation",
    "Target": "New",
    "TimeInForce": "Day",
    "ExecInst": 0,
    "Comment": "Expecting a remarkable Q4 report",
    "ExpireDate": "2019-02-25T21:00:00Z",
    "AccountId": 6303,
    "UserId": 7125,
    "RequestId": 105467,
    "StateId": 0,
    "ParentId": -1,
    "Legs": [],
    "TrailingStopAmountType": "Absolute",
    "TrailingStopAmount": 0,
    "TrailingLimitAmountType": "Absolute",
    "TrailingLimitAmount": 0,
    "CreateDate": "2019-02-25T13:33:40.9022856Z",
    "InitialType": "Market",
    "IsExternal": false,
    "ExecutionInstructions": {
        "CorrelationId": "ade9537995f84dcc840eabc724107487",
        "CreateOrderRequestTimeUnix": "636866984209012879"
    },
    "TransType": "New",
    "ValidationsToBypass": 0,
    "ParentRequestId": 0,
    "SettlementDate": "0001-01-01T00:00:00Z"
}

Please note that you may receive the 200 status code even if the order was improperly configured. For example, if you attempt to create a limit order and specify the stop price instead of the limit price, the order will be registered in the system but will eventually be rejected. Please monitor the order's status (it's PendingNew by default) to determine if the order has been rejected or placed.

Common Mistakes

Here are some of the common mistakes that developers make when attempting to place a new order.

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 placing new orders. 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.

Placing Orders Whose Value Exceeds the Account's Buying Power

When attempting to place an order whose value exceeds the trading account's buying power, you'll receive a JSON file with the ErrorDescription parameter equaling DayTradingBuyingPowerExceeded.

{
  "IsSuccessful": false,
  "ErrorDescription": "DayTradingBuyingPowerExceeded",
  "ErrorDescriptionArgs": [],
  "Commission": 3.75,
  "Commissions": {
    "Per Trade Commission": 3.75
  },
  "Cost": 1766790,
  "NetCost": 1766786.25,
  "Quotes": [
    {
      "Ask": 196.31,
      "Bid": 196.28,
      "Last": 196.29,
      "Volume": 200,
      "OpenInterest": 0
    }
  ],
  "MarginChange": 0
}

Failing to Specify the Limit Price for Limit Orders

An attempt to place a limit order without specifying its price will result in an error; in response you'll receive a JSON file with the ErrorDescription parameter equaling QuotePriceIsInvalid.

{
  "IsSuccessful": false,
  "ErrorDescription": "QuotePriceIsInvalid",
  "Commission": 0,
  "Commissions": {},
  "Cost": 0,
  "NetCost": 0,
  "MarginChange": 0
}

Failing to Specify the Stop Price for Stop-Loss Orders

An attempt to place a stop-loss order without specifying its price will result in an error; in response you'll receive a JSON file with the ErrorDescription parameter equaling QuotePriceIsInvalid.

{
  "IsSuccessful": false,
  "ErrorDescription": "QuotePriceIsInvalid",
  "Commission": 0,
  "Commissions": {},
  "Cost": 0,
  "NetCost": 0,
  "MarginChange": 0
}
token request