Tracking Bracket Orders

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.

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

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?