# Tracking Bracket Orders

**URL:** <https://forum.alpaca.markets/t/tracking-bracket-orders/7173>\
**Category:** Tutorials\
**Created:** [October 21, 2021, 5:15pm UTC](https://forum.alpaca.markets/t/tracking-bracket-orders/7173 "2021-10-21T17:15:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_McGuigan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/ryan_mcguigan/32/2882_2.png) [@Ryan\_McGuigan](https://forum.alpaca.markets/u/Ryan_McGuigan)\
**Post date:** [October 21, 2021, 5:15pm UTC](https://forum.alpaca.markets/t/tracking-bracket-orders/7173/1 "2021-10-21T17:15:51Z")

</div>

I’m working in Python and using the alpaca\_trade\_api.

I submit custom order ids that I use to track each trade individually on my side. When submitting a bracket order, how do you tie the profit\_taking and stop\_loss orders to your original order\_id that opened the position?

I suspect that it has to do with nesting and legs but I am unsure what it looks like or how it works.

---

<div class="post-metadata">

**Author:** ![Francisco\_Morales](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/francisco_morales/32/1103_2.png) [@Francisco\_Morales](https://forum.alpaca.markets/u/Francisco_Morales)\
**Post date:** [October 27, 2021, 8:19pm UTC](https://forum.alpaca.markets/t/tracking-bracket-orders/7173/2 "2021-10-27T20:19:07Z")

</div>

This is the body of a bracket order:

bracket  
{  
“side”: “buy”,  
“symbol”: “SPY”,  
“type”: “market”,  
“qty”: “100”,  
“time\_in\_force”: “gtc”,  
“order\_class”: “bracket”,  
“take\_profit”: { “limit\_price”: “120”},  
“stop\_loss”: {  
“stop\_price”: “299”,  
“limit\_price”: “298.5”  
}  
}

you specify the values of what you want to be the take profit and stop loss, obviously they must be higher and lower than the market price respectively

For example if you are placing a market buy bracket order for AAPL and its market price is around 100, then your take\_profit should be higher than that …say 101, and your stop loss should be less than 100, say …99

---

<div class="post-metadata">

**Author:** ![Ryan\_McGuigan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/ryan_mcguigan/32/2882_2.png) [@Ryan\_McGuigan](https://forum.alpaca.markets/u/Ryan_McGuigan)\
**Post date:** [October 27, 2021, 8:32pm UTC](https://forum.alpaca.markets/t/tracking-bracket-orders/7173/3 "2021-10-27T20:32:40Z")

</div>

Hey thanks, do you know if the order id’s for profit\_taking and stop\_loss are returned or if you can tie those order\_id tied to the original bracket order?
