# Partial take profit order?

**URL:** <https://forum.alpaca.markets/t/partial-take-profit-order/13578>\
**Category:** Alpaca Trading\
**Created:** [January 30, 2024, 1:08am UTC](https://forum.alpaca.markets/t/partial-take-profit-order/13578 "2024-01-30T01:08:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![thebarryman](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/thebarryman/32/5809_2.png) [@thebarryman](https://forum.alpaca.markets/u/thebarryman)\
**Post date:** [January 30, 2024, 1:08am UTC](https://forum.alpaca.markets/t/partial-take-profit-order/13578/1 "2024-01-30T01:08:02Z")

</div>

I would like to place a partial take profit order with a linked stop loss order to fully close the position, and am wondering if this is possible in Alpaca?

For example, let’s say I own 100 shares of security ABC currently trading at $10 per share. I would like to place the following orders -

> Limit sell 50 shares at $15 per share  
> Stop loss sell 100 shares at $7.50 per share

The issue is that if my limit sell executes, I now have an invalid stop sell for more shares than I own. If I set it up as a OCO order, the problem would be I would have no exit from the trade if the price were to fall below my exit point _after_ the take profit order was executed.

One way I can think of achieving this would be to set it up as three linked trades -

> Limit sell 50 shares at $15 per share  
> Stop sell for 100 shares at $7.50 (canceled by limit execution)  
> Stop sell for 50 shares at $7.50 (triggered by limit execution)

Or alternatively -

> Limit sell 50 shares at $15 per share  
> Stop sell for _up to_ 100 shares at $7.50

However, I’m not sure if either of these approaches are supported by the Alpaca API. Any ideas?

---

<div class="post-metadata">

**Author:** ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)\
**Post date:** [January 30, 2024, 7:54pm UTC](https://forum.alpaca.markets/t/partial-take-profit-order/13578/2 "2024-01-30T19:54:20Z")

</div>

@thebarryman There isn’t a ‘direct’ way to place an order to “partially take profit or fully close” a position. One-Cancels-Other (OCO) orders are required to have the same quantity. However, you accomplish this with a [OCO order](https://docs.alpaca.markets/docs/orders-at-alpaca#oco-orders) and a simple stop loss order.

Using your example, and you own 100 shares of security ABC currently trading at $10 per share. You would like to place the following orders -

> Limit sell 50 shares at $15 per share  
> Stop loss sell 100 shares at $7.50 per share

Submit two orders

> **Order A**  
> OCO order  
> Limit sell 50 shares at $15 per share  
> Stop loss sell 50 shares at $7.50 per share
> 
> **Order B**  
> Simple order  
> Stop loss sell 50 shares at $7.50 per share

There’s a stop loss in place for the entire 100 shares if the price drops below $7.50. You have a take profit for 50 shares if the prices goes up to $15, which if it executes, will cancel the stop loss order for those shares.

---

<div class="post-metadata">

**Author:** ![thebarryman](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/thebarryman/32/5809_2.png) [@thebarryman](https://forum.alpaca.markets/u/thebarryman)\
**Post date:** [January 30, 2024, 8:47pm UTC](https://forum.alpaca.markets/t/partial-take-profit-order/13578/3 "2024-01-30T20:47:04Z")

</div>

Now there’s a great solution! Thanks for your help.

---

<div class="post-metadata">

**Author:** ![thebarryman](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/thebarryman/32/5809_2.png) [@thebarryman](https://forum.alpaca.markets/u/thebarryman)\
**Post date:** [January 31, 2024, 9:40pm UTC](https://forum.alpaca.markets/t/partial-take-profit-order/13578/4 "2024-01-31T21:40:08Z")

</div>

Follow-up question for you - how should I handle buy orders to enter into these positions?

My plan is to submit the buy as a market order to be executed at open. Assuming the order is actually filled as soon as the market opens, then I think it would be safe to submit my sell orders at the same time as the buy order.

But I am worried about execution order, what would happen if the stop triggers on market open and the sell order is executed before the buy?

For now, I am planning on just submitting the sell orders after the buy executes, but it would be great to conditionally submit them on buy execution - or, if I could safely assume that the market buy would always execute first.

---

<div class="post-metadata">

**Author:** ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)\
**Post date:** [February 2, 2024, 8:12pm UTC](https://forum.alpaca.markets/t/partial-take-profit-order/13578/5 "2024-02-02T20:12:54Z")

</div>

@thebarryman I believe what you are looking for is a “bracket order”. There’s a bit of info in the docs [here](https://docs.alpaca.markets/docs/orders-at-alpaca#bracket-orders). Basically, it submits 3 orders at one time. 1) an initial market or limit order to open the position, 2) a take profit limit order and a 3) stop loss order. The take-profit and stop loss orders are submitted only after the initial order fills.

That should do what you want.

---

<div class="post-metadata">

**Author:** ![thebarryman](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/thebarryman/32/5809_2.png) [@thebarryman](https://forum.alpaca.markets/u/thebarryman)\
**Post date:** [February 2, 2024, 8:32pm UTC](https://forum.alpaca.markets/t/partial-take-profit-order/13578/6 "2024-02-02T20:32:00Z")

</div>

I have seen the bracket order but it doesn’t seem to be able to accommodate the setup you suggested above, where there are two sell trades in tandem that need to be submitted.

Maybe two bracket orders could be used? But only one of the trades should have a limit sell associated with it.

---

<div class="post-metadata">

**Author:** ![thebarryman](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/thebarryman/32/5809_2.png) [@thebarryman](https://forum.alpaca.markets/u/thebarryman)\
**Post date:** [February 4, 2024, 2:17am UTC](https://forum.alpaca.markets/t/partial-take-profit-order/13578/7 "2024-02-04T02:17:32Z")

</div>

One more question @Dan_Whitnable_Alpaca, I’m not seeing a way to actually create the OCO order from your C# API. Is this only available by posting a JSON request directly?

---

<div class="post-metadata">

**Author:** ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)\
**Post date:** [February 5, 2024, 1:44pm UTC](https://forum.alpaca.markets/t/partial-take-profit-order/13578/8 "2024-02-05T13:44:03Z")

</div>

@thebarryman You mentioned the bracket order “_doesn’t seem to be able to accommodate the setup you suggested above, where there are two sell trades in tandem that need to be submitted_”. If you want a b`uy+stop_loss+take_profit` then the bracket order will work. If, as you originally stated, you want some of the position to have a take profit and some not, then you could enter two bracket orders Or, you could enter a bracket order (for the portion you want to have a take profit) and a [One-Triggers-Other (OTO) order](https://docs.alpaca.markets/docs/orders-at-alpaca#oto-orders) (for the portion you don’t want a take profit order). However, there isn’t a real downside to including the take profit order and setting a very high limit price (hey you might get lucky and it fills). Submitting two bracket orders would keep all your orders the same.

Regarding the C# implementation, I’m not familiar with that SDK. Maybe someone else here could help?

---

<div class="post-metadata">

**Author:** ![oleg.rakhmatulin](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/oleg.rakhmatulin/32/559_2.png) [@oleg.rakhmatulin](https://forum.alpaca.markets/u/oleg.rakhmatulin)\
**Post date:** [February 12, 2024, 5:48am UTC](https://forum.alpaca.markets/t/partial-take-profit-order/13578/9 "2024-02-12T05:48:28Z")

</div>

.NET SDK has Wiki pages and most top-level questions are covered there. For instance, different helper methods for order creation are covered on [this](https://github.com/alpacahq/alpaca-trade-api-csharp/wiki/Order-Placement#advanced-oder-types) page.
