Create an Order

Places a new order for the given account. An order request may be rejected if the account is not authorized for trading, or if the tradable balance is insufficient to fill the order.

Body Params

Represents a request to create an order.

advanced_instructions
object

Advanced instructions for Elite Smart Router: https://docs.alpaca.markets/docs/alpaca-elite-smart-router

string
length ≤ 128

A unique identifier for the order. Automatically generated if not sent. (<= 128 characters)

string
enum

Which side of an event contract this order or position is for. Required when placing an event contract order and rejected for other asset classes. Omitted from orders and positions for other asset classes. Use it with side:

  • buy and yes buys Yes.
  • buy and no buys No.
  • sell and yes sells Yes contracts you hold.
  • sell and no sells No contracts you hold.
    Yes and No holdings are both returned as long positions. event_outcome is what tells them apart. You cannot hold Yes and No on the same contract at the same time: an order to buy one outcome is rejected while you hold the other or have an opening order for it, and an order to sell one outcome is rejected while you hold the other.
Allowed:
date-time

Required when time_in_force is gtd. Must be in the future. Rejected for every other time in force.

boolean

(default) false. If true, order will be eligible for execution in the pre-market, after-hours, and overnight sessions. Only works with type limit and time_in_force set to either day or gtc. Event contracts do not support extended hours.

legs
array of objects
length ≤ 4

list of order legs (<= 4)

legs
string

Required if type is limit or stop_limit.
In case of mleg, the limit_price parameter is expressed with the following notation:

  • A positive value indicates a debit, representing a cost or payment to be made.
  • A negative value signifies a credit, reflecting an amount to be received.
    Event contract limit prices must be from 0.01 to 0.99.
string

dollar amount to trade. Cannot work with qty. Can only work for market order types and day for time in force. Event contract orders do not accept notional.

string
enum

The order classes supported by Alpaca vary based on the order's security type. The following provides a comprehensive breakdown of the supported order classes for each category:

  • Equity trading: simple (or ""), oco, oto, bracket.
  • Options trading:
    • simple (or "")
    • mleg (required for multi-leg complex option strategies)
  • Crypto trading: simple (or "").
  • Event contract trading: simple (or "").
Allowed:
string
enum

Represents the desired position strategy.

Allowed:
string

number of shares to trade. Can be fractionable for only market and day order types. Required for mleg order class, represents the number of units to trade of this strategy. Event contract orders require a whole number of contracts.

string
enum

Represents which side this order was on:

  • buy
  • sell
    Required for all order classes except for mleg.
Allowed:
stop_loss
object

Takes in string/number values for stop_price and limit_price

string

required if type is stop or stop_limit

string

symbol, asset ID, or currency pair to identify the asset to trade, required for all order classes except for mleg.

take_profit
object

Takes in a string/number value for limit_price

string
enum
required

The Time-In-Force values supported by Alpaca vary based on the order's security type. Here is a breakdown of the supported TIFs for each specific security type:

  • Equity trading: day, gtc, opg, cls, ioc, fok.
  • Options trading: day, gtc.
  • Crypto trading: gtc, ioc.
  • Event contract trading: day, gtc, ioc, fok, gtd. An event contract day order stays open until 12:05 a.m. ET the next day, including weekends and holidays.

Below are the descriptions of each TIF:

  • day:
    A day order is eligible for execution only on the day it is live. By default, the order is only valid during Regular Trading Hours (9:30am - 4:00pm ET). If unfilled after the closing auction, it is automatically canceled. If submitted after the close, it is queued and submitted the following trading day. However, if marked as eligible for extended hours, the order can also execute during supported extended hours.

  • gtc:
    The order is good until canceled. Non-marketable GTC limit orders are subject to price adjustments to offset corporate actions affecting the issue. We do not currently support Do Not Reduce (DNR) orders to opt out of such price adjustments.

  • opg:
    Use this TIF with a market/limit order type to submit "market on open" (MOO) and "limit on open" (LOO) orders. This order is eligible to execute only in the market opening auction. Any unfilled orders after the open will be cancelled. OPG orders submitted after 9:28am but before 7:00pm ET will be rejected. OPG orders submitted after 7:00pm will be queued and routed to the following day's opening auction. On open/on close orders are routed to the primary exchange. Such orders do not necessarily execute exactly at 9:30am / 4:00pm ET but execute per the exchange's auction rules.

  • cls:
    Use this TIF with a market/limit order type to submit "market on close" (MOC) and "limit on close" (LOC) orders. This order is eligible to execute only in the market closing auction. Any unfilled orders after the close will be cancelled. CLS orders submitted after 3:50pm but before 7:00pm ET will be rejected. CLS orders submitted after 7:00pm will be queued and routed to the following day's closing auction. Only available with API v2.

  • ioc:
    An Immediate Or Cancel (IOC) order requires all or part of the order to be executed immediately. Any unfilled portion of the order is canceled. Only available with API v2. Most market makers who receive IOC orders will attempt to fill the order on a principal basis only, and cancel any unfilled balance. On occasion, this can result in the entire order being cancelled if the market maker does not have any existing inventory of the security in question.

  • fok:
    A Fill or Kill (FOK) order is only executed if the entire order quantity can be filled, otherwise the order is canceled. Only available with API v2.

  • gtd:
    A Good Till Date (GTD) order stays live until expires_at, then it is canceled. expires_at is required and must be in the future. Only available for event contracts, and only when placing the order. A replacement cannot set gtd or change expires_at. Cancel the order and submit a new one to use gtd or change its expiry.

Allowed:
string

this or trail_price is required if type is trailing_stop

string

this or trail_percent is required if type is trailing_stop

string
enum
required

The order types supported by Alpaca vary based on the order's security type. The following provides a comprehensive breakdown of the supported order types for each category:

  • Equity trading: market, limit, stop, stop_limit, trailing_stop.
  • Options trading: market, limit, stop, stop_limit.
  • Multileg Options trading: market, limit.
  • Crypto trading: market, limit, stop_limit.
  • Event contract trading: limit.
Allowed:
Responses

422

Unprocessable

Input parameters are not recognized.

Language
Credentials
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json