Execution behavior
Stop orders execute as market orders against the live order book. Before executing, the system calculates the maximum quantity it can safely fill without pushing the account into liquidation. This check accounts for the fact that a stop-loss closes a position at realized prices that may be worse than the mark price used to estimate available margin: as the order eats through price levels beyond the mark price, realized losses can exceed the margin cushion and trigger liquidation.
If the calculated maximum is zero because the account is already under liquidation or the available margin is fully consumed by unrealized losses, the order does not execute and is cancelled.
When liquidity is limited or the spread is wide, the maximum safe size may be less than the full position size. In that case the order executes for a reduced quantity. The position is partially closed and the remaining stop order is cancelled; there is no retry or re-queue.
A stop order is also cancelled without executing if:
- The account enters liquidation between the trigger and execution.
- The position is neutral at trigger time.
- The position direction has flipped since the order was placed.
- Triggered as market orders only, stop-limit variants are not currently supported.
- Risk Management Module TP/SL covers the full position only. Cancel and replace to update.
- Once visible in Open Orders, TP/SL orders are cancel-only and cannot be edited.
- Partial legs set at order placement are fixed at creation size and do not auto-resize as the position changes.
builderCode attribution is set independently for each of the two ways to place TP/SL, it is never inherited across them. There is no centrally configured default fee rate for a builder code — builderCode.feeRateBpsFractional must be set explicitly for a fill to earn commission; omitting it earns nothing, regardless of which path below is used.
- At Order Placement: a
builderCodeon the order request is inherited by that order’stakeProfit/stopLosslegs. When one of those legs later triggers and closes the position, the closing fill carries the same builder code (and fee rate) as the order that created it. - Via Risk Management Module:
POST /v1/perps/stop_orderaccepts its own optionalbuilderCode. It must be set explicitly on this request for the resulting close to earn builder commission — it does not inherit thebuilderCodefrom the order(s) that originally opened the position.