Now You Can Place OCO & OTO Orders on Alpaca!

OCO & OTO Orders Are Now Available

After launching bracket orders last month, we listened to your feedback and made further improvements to our advanced order types.

Today, we are excited to announce OCO (One-Cancels-Other) and OTO (One-Triggers-Other) as new additions to the growing list of advanced order types offered by Alpaca Trading API.

You can jump right into the API doc here

Understand Orders - Documentation | Alpaca
Alpaca API lets you build and trade with real-time market data for free.

How OCO Works

OCO sample.png

In this example chart, let’s say you already have a position in this stock, and you are looking to take profit by selling when it hits the recent high (“take_profit” -> “limit_price” = “325”) or cut loss by selling when it goes lower than the recent low (“stop_loss” -> “stop_price” = “250”).

In this scenario, you can call API with parameters like this

In order to submit an OCO order, specify “oco” for the order_class parameter.

{
  "side": "sell",
  "symbol": "AAPL",
  "type": "limit",
  "qty": "10",
  "time_in_force": "gtc",
  "order_class": "oco",
  "take_profit": {
    "limit_price": "325"
  },
  "stop_loss": {
    "stop_price": "250",
    "limit_price": "249.5"
  }
}

*Please do note that this is for illustration only and is not a recommendation or suggestion of this trade or this stock*

For detail please see the docs here.

How OTO Works

Using the same example chart from above, let’s say you don’t have any position right now, but are looking to purchase this stock with the current price (“market”), and you want to automatically place stop loss order (“stop_loss” -> “stop_price” = “250”) to the position that you purchase with the market order.

In this scenario, you can call API with parameters like this

The order submission is done with the order_class parameter be “oto”.

{
  "side": "buy",
  "symbol": "AAPL",
  "type": "market",
  "qty": "10",
  "time_in_force": "gtc",
  "order_class": "oto",
  "stop_loss": {
    "stop_price": "250",
    "limit_price": "249.5"
  }
}

*Please do note that this is for illustration only and is not a recommendation or suggestion of this trade or this stock*

For detail please see the docs here.


Follow @AlpacaHQ on Twitter!

Conditional orders may have increased risk as a result of their reliance on trigger processing, market data, and other internal and external systems. Such orders are not sent to the market until specified conditions are met. During that time, issues such as system outages with downstream technologies or third parties may occur. Conditional orders triggering near the market close may fail to execute that day. Furthermore, our executing partner may impose controls on conditional orders to limit erroneous trades triggering downstream orders. Alpaca Securities may not always be made aware of such changes to external controls immediately, which may lead to some conditional orders not being executed. As such, it is important to monitor conditional orders for reasonability. Conditional orders are “Not Held” orders whose execution instructions are on a best efforts basis upon being triggered. Furthermore, conditional orders may be subject to the increased risks of stop orders and market orders outlined above. Given the increased potential risk of using conditional orders, the client agrees that Alpaca Securities cannot be held responsible for losses, damages, or missed opportunity costs associated with market data problems, systems issues, and user error, among other factors. By using conditional orders the client understands and accepts the risks outlined above. Alpaca Securities encourages leveraging the use of Paper accounts to become more comfortable with the intricacies associated with these orders.

Brokerage services are provided by Alpaca Securities LLC ("Alpaca"), member FINRA/SIPC, a wholly-owned subsidiary of AlpacaDB, Inc. Technology and services are offered by AlpacaDB, Inc.

Interested in learning more about Broker API?

Don't miss out on any updates about our Broker API suite of solutions! Share your details with us and be the first to know about our latest content.

Author image
Co-founder & CEO of Alpaca
You've successfully subscribed to Alpaca Blog | Developer-First API for Stocks and Crypto
Great! Next, complete checkout for full access to Alpaca Blog | Developer-First API for Stocks and Crypto
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.