Understand Orders

Using Alpaca Trade API, a user can monitor, place and cancel their orders with Alpaca. Each order has a unique identifier provided by the client. This client-side unique order ID will be automatically generated by the system if not provided by the client, and will be returned as part of the order object along with the rest of the fields described below. Once an order is placed, it can be queried using the client-side order ID or system-assigned unique ID to check the status. Updates on open orders at Alpaca will also be sent over the streaming interface, which is the recommended method of maintaining order state.

Orders Submitted Outside of Regular Trading Hours

Orders submitted outside of market hours will be routed and made available for execution at the time of the next market open. Pre-market and extended-hours trading are not yet supported at Alpaca, but orders can be placed around the clock to be handled as soon as the market is open.

Extended Trading Hours

Pre-market and after-hours trading are not yet available. We are currently working on supporting extended hours trading. This feature and more will initially be available only as part of a new account plan designed specifically for high-volume algorithmic traders. This new account plan is not for everyone and may require certain conditions of your trading activity. Currently this program is only open to eligible U.S. residents. If you think this may be for you, please complete this form and we’ll contact you.

Order Types

When you submit an order, you can choose one of supported order types. Currently, Alpaca supports four different types of orders.

Market Order

A market order is a request to buy or sell a security at the currently available market price. It provides the most likely method of filling an order. Market orders fill nearly instantaneously.

As a trade-off, your fill price may slip depending on the available liquidity at each price level as well as any price moves that may occur while your order is being routed to its execution venue. There is also the risk with market orders that they may get filled at unexpected prices due to short-term price spikes.

To protect against excessive price impact, Alpaca converts buy market orders into marketable limit orders with a price limit that is 5% higher than the current market price. In most cases, this will have the same exact outcome as using a true market order. However, if the stock price moves more than 5% above the market price in the time that it takes to route your order to the execution venue, then your order would not execute until the price came back within the 5% collar. Sell market orders are not converted into limit orders.

If you submit a buy market order during pre-market or extended-hours trading, we use the last traded price to determine the limit price. This means that if the stock opens more than 5% above the last traded price that existed at the time you submitted your order, your order won’t be executed until the price came back within the 5% price collar.

Limit Order

A limit order is an order to buy or sell at a specified price or better. A buy limit order (a limit order to buy) is executed at the specified limit price or lower (i.e., better). Conversely, a sell limit order (a limit order to sell) is executed at the specified limit price or higher (better). Unlike a market order, you have to specify the limit price parameter when submitting your order.

While a limit order can prevent slippage, it may not be filled for a quite a bit of time, if at all. For a buy limit order, if the market price is within your specified limit price, you can expect the order to be filled. If the market price is equivalent to your limit price, your order may or may not be filled; if the order cannot immediately execute against resting liquidity, then it is deemed non-marketable and will only be filled once a marketable order interacts with it. You could miss a trading opportunity if price moves away from the limit price before your order can be filled.

Stop Order

A stop (market) order is an order to buy or sell a security when its price moves past a particular point, ensuring a higher probability of achieving a predetermined entry or exit price. Once the market price crosses the specified stop price, the stop order becomes a market order. Alpaca converts buy stop orders into stop limit orders with a limit price that is 5% higher than the stop price. Sell stop orders are not converted into stop limit orders.

A stop order does not guarantee the order will be filled at a certain price after it is converted to a market order.

In order to submit a stop order, you will need to specify the stop price parameter in the API.

Stop Limit Order

A stop-limit order is a conditional trade over a set time frame that combines the features of a stop order with those of a limit order and is used to mitigate risk. The stop-limit order will be executed at a specified limit price, or better, after a given stop price has been reached. Once the stop price is reached, the stop-limit order becomes a limit order to buy or sell at the limit price or better.

In order to submit a stop limit order, you will need to specify both the limit and stop price parameters in the API.

Advanced Order Types

We are currently working on supporting advanced order types such as OCO (one-cancels-the-other) bracket orders. This feature and more will initially be available only as part of a new account plan designed specifically for high-volume algorithmic traders. This new account plan is not for everyone and may require certain conditions of your trading activity. Currently this program is only open to eligible U.S. residents. If you think this may be for you, please complete this form and we’ll contact you.

Time in Force

The following are the types of time-in-force Alpaca supports.

  • day
    The order is good for the day, and it will be canceled automatically at the end of Regular Trading Hours if unfilled.
  • gtc
    The order is good until canceled.
  • opg
    The order is placed at the time the market opens. The order will be accepted if it is received before 9:15AM (ET). The order can be cancelled after 9:15AM, but it cannot be edited. After 9:28AM, OPG orders cannot be edited or cancelled. Any unfilled orders after opening of the market will be cancelled. If you submit OPG orders during the market hours, it will appear as “rejected” in your dashboard.

Order Lifecycle

An order executed through Alpaca can experience several status changes during its lifecycle. The most common statuses are described in detail below:

  • new
    The order has been received by Alpaca, and routed to exchanges for execution. This is the usual initial state of an order.
  • partially_filled
    The order has been partially filled.
  • filled
    The order has been filled, and no further updates will occur for the order.
  • done_for_day
    The order is done executing for the day, and will not receive further updates until the next trading day.
  • canceled
    The order has been canceled, and no further updates will occur for the order. This can be either due to a cancel request by the user, or the order has been canceled by the exchanges due to its time-in-force.
  • expired
    The order has expired, and no further updates will occur for the order.

Less common states are described below. Note that these states only occur on very rare occasions, and most users will likely never see their orders reach these states:

  • accepted
    The order has been received by Alpaca, but hasn’t yet been routed to the execution venue. This state only occurs on rare occasions.
  • pending_new
    The order has been received by Alpaca, and routed to the exchanges, but has not yet been accepted for execution. This state only occurs on rare occasions.
  • accepted_for_bidding
    The order has been received by exchanges, and is evaluated for pricing. This state only occurs on rare occasions.
  • pending_cancel
    The order is waiting to be canceled. This state only occurs on rare occasions.
  • stopped
    The order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurred. This state only occurs on rare occasions.
  • rejected
    The order has been rejected, and no further updates will occur for the order. This state occurs on rare occasions and may occur based on various conditions decided by the exchanges.
  • suspended
    The order has been suspended, and is not eligible for trading. This state only occurs on rare occasions.
  • calculated
    The order has been completed for the day (either filled or done for day), but remaining settlement calculations are still pending. This state only occurs on rare occasions.

An order may be canceled through the API up until the point it reaches a state of either filled, canceled, or expired.

Buying Power

In order to submit a buy order and have it accepted, your account must have sufficient buying power. Alpaca calculates the value of a buy order as the order’s limit price (in the case of market orders, the limit price is 5% above the current market price as noted above) multiplied by the order’s quantity. The value of the order is then checked against your available cash balance to determine if it can be accepted. Please note that your available cash balance is reduced by other open (pending) buy orders, while sell orders do not add to your available cash balance until they have executed.

For example, if your cash balance is $10,000 and you submit a limit buy order with an order value of $3,000, your order will be accepted and your remaining available cash balance will be $7,000. Even if this order is unfilled, as long as it is open and has not been cancelled, it will count against your available buying power. If you then submitted another order with an order value of $8,000, it would be rejected.


Suggestions or questions?
We're always happy to hear from you. You can contribute to these docs on GitHub, or you can join our Community Slack to get help from other community members and the Alpaca team.