Place Order
Place a new order
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:
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 on which a new order must be placed.
API version (path). Unless necessary, leave it at "1.0".
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):
For orders that will be verified by the API and the execution venue too (slow):
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:
|
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:
|
Legs | These are the legs of a multi-leg order. |
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)
All legs of a multi-leg order should contain only three parameters:
Ticker symbol
Quantity
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.
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-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:
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:
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:
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:
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 placing new orders. 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.
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
.
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
.
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
.
Last updated