Overview
- Bracket (TP/SL): Attach Take Profit and/or Stop Loss to an entry or position. The legs form an OCO group (one-cancels-the-other).
- Modes:
- FULL: Bracket attaches at the position level for the full absolute position size; legs are reduce-only and typically execute IOC.
- PARTIAL: Bracket attaches per fill of an entry order. Each taker/maker fill creates its own OCO legs sized to that fill; any resting remainder can later create legs when filled as maker.
- Trigger: Each leg specifies a
trigger_priceand a direction is derived from the side and price relation. Activation occurs on boundary equality. - Reduce-only: Triggered legs never increase exposure. Size is clamped to the current position size; if no exposure to reduce, the leg is acknowledged and OCO is cancelled or re-armed.
- Slippage guard: MARKET-type legs are converted to LIMIT IOC with a guard band (
SLIPPAGE_GUARD_BPS, default 200 bps = 2%) anchored to the trigger or current mark.
Request shape (order_create)
Behavior details
- OCO lifecycle
- When one leg executes, its sibling is cancelled by the trigger service upon acknowledgement.
- Equality activates: Up-leg triggers when mark crosses up to
trigger_price; Down-leg triggers when mark crosses down totrigger_price.
- FULL mode
- Bracket legs resize as the position size changes; cancelling/closing the position cancels the OCO group.
- Legs are executed as reduce-only IOC. MARKET legs are converted to LIMIT IOC with guard:
guard_price = trigger_price ± (trigger_price * GUARD_BPS / 10_000).
- PARTIAL mode
- Each fill (taker or maker) creates a distinct OCO group sized to that fill. All trigger IDs are unique across fills.
- Reduce-only clamping
- If current position size is smaller than the leg size, execution clamps to the closable amount. If zero, the service cancels the group (or re-arms based on exposure).
Environment and guard configuration
- Env var:
SLIPPAGE_GUARD_BPS(default 200 = 2%).
Examples
- Attach FULL bracket to a BUY entry:
- Attach PARTIAL bracket to a BUY LIMIT entry:
Notes and constraints
- For LIMIT legs,
limit_priceis required; invalid legs are ignored. - Triggered orders use
time_in_force: IOC. - All prices and sizes are scaled integers; see market
base_decimalsandquote_decimals.
WebSocket examples
- When a TP/SL leg executes, you will receive standard
fillandorderevents on the private stream.