Take profit (TP) and stop loss (SL) orders are conditional orders that activate when the mark price crosses a trigger. They can be attached to a position or to a parent order.
Position TP/SL
A position TP/SL is a pair of reduce-only orders attached to an open position. When one leg executes, the other is canceled automatically (OCO). This prevents the classic mistake of closing a position twice and opening the opposite side by accident.
| Field | Meaning |
|---|---|
triggerPx | Price that activates the order |
isMarket | Whether the triggered order is market or limit |
limitPx | Limit price when isMarket is false |
reduceOnly | Must be true for position TP/SL |
size | Defaults to the full position |
Trigger direction
For a long position, a take-profit trigger is above the mark and a stop trigger is below it. For a short, the directions are reversed. The API rejects a trigger on the wrong side with Invalid trigger price.
Parent-order TP/SL
You can attach TP/SL to a limit order before it fills. The conditional orders are created only when the parent fills. This is useful for bracket orders: entry, target, and stop are submitted as one intent.
{
"type": "order",
"orders": [{
"asset": 0,
"isBuy": true,
"limitPx": "103900",
"sz": "0.01",
"reduceOnly": false,
"tif": "Gtc",
"takeProfit": { "triggerPx": "110000", "isMarket": true },
"stopLoss": { "triggerPx": "98000", "isMarket": true }
}],
"grouping": "normalTpsl"
}Market vs limit triggers
- Market trigger sends a market order when activated. It prioritizes exit certainty.
- Limit trigger sends a limit order. It may not fill if the market gaps through the limit.
For stops in fast markets, a market trigger is usually safer. For take-profit orders, a limit trigger can capture a better price at the cost of a missed exit.
Partial TP/SL
You can attach multiple TP/SL orders to one position as long as the total reduce-only size does not exceed the position. This is how scale-out plans are expressed. Each order is independent; canceling one does not cancel the others unless they are part of the same OCO group.
Common failures
| Symptom | Cause | Fix |
|---|---|---|
| TP executed at a loss | Trigger used mark price, fill used book price | Use a limit trigger or widen the target |
| SL did not execute | Trigger was on the wrong side | Check the trigger direction |
| Order rejected as reduce-only | Position was already closed | Cancel the stale order |
| Both legs executed | Orders were not submitted as OCO | Use position TP/SL grouping |