Bracket
A bracket order consists of an entry limit order, a take-profit order, and a stop-loss order. The take-profit and stop-loss orders are managed via a One-Cancels-Other (OCO) algo as a subalgo.
All orders are placed simultaneously when the algo starts.
Order Structure
Entry Order: A limit order that initiates the position
Take-Profit Order: A limit order placed at
take_profit_priceto exit at a profitStop-Loss Order: A stop-limit order with
stop_loss_trigger_priceandstop_loss_limit_priceto exit at a loss
Execution Behavior
The entry order is placed immediately when the algo starts
When the entry order receives fills, the exit orders (take-profit and stop-loss) are placed as an OCO pair
If
trigger_in_proportionis true, exit orders are sized proportionally to the filled quantity of the entry orderIf
trigger_in_proportionis false, exit orders are only placed after the entry order is fully filledWhen either exit order is filled, the other is immediately cancelled via the OCO subalgo
Price Validation
For BUY entries:
take_profit_pricemust be greater than entrylimit_pricestop_loss_trigger_pricemust be less than entrylimit_pricestop_loss_limit_pricemust be less than or equal tostop_loss_trigger_price
For SELL entries:
take_profit_pricemust be less than entrylimit_pricestop_loss_trigger_pricemust be greater than entrylimit_pricestop_loss_limit_pricemust be greater than or equal tostop_loss_trigger_price
Completion
The bracket algo completes when:
The entry order is outed/cancelled before any fills, OR
All exit orders are fully filled or cancelled after entry fills
You cannot modify the algo once it is sent, you must cancel and send a new one if you want different parameters.
You also cannot pause the algo, it will just cancel when you send a pause.
It is technically possible for both secondary orders to be filled if they execute simultaneously
Use Cases
Automating profit-taking and risk management for a position
Ensuring disciplined exits without manual intervention
Managing trades with predefined risk/reward ratios
BracketParams
entry (OrderInfo)
The entry order information
take_profit_price (Decimal)
Limit price for the take-profit exit order
stop_loss_trigger_price (Decimal)
Trigger price for the stop-loss order
stop_loss_limit_price (Decimal)
Limit price for the stop-loss order (after triggered)
trigger_in_proportion (bool)
If true, exit orders are sized proportionally to entry fills
Example
Last updated