Implementing Stop Order Placement in a Mobile Exchange App
A stop order is a conditional request. Until the price crosses stopPrice, the order doesn't appear in the order book. When stopPrice is reached, the exchange automatically places a limit (STOP_LOSS_LIMIT) or market (STOP_LOSS) order. Users confuse stopPrice and limitPrice: half of crypto app support queries are about this. So UI must explain the mechanism, not just render two fields.
Types of Stop Orders and Their UX
STOP_LOSS_LIMIT (Binance) — three parameters:
-
stopPrice— trigger (activation price) -
price— limit execution price -
quantity— volume
STOP_LOSS (market) — only stopPrice and quantity. After trigger, executes at market — guarantees exit but not price.
TAKE_PROFIT_LIMIT — mirror structure, but activates when price rises above stopPrice (to lock profits).
UI solution: split into two sub-modes "Limit Loss" and "Lock Profit" with a visual price diagram. Show an arrow: "Activation Price → Limit Execution Price."
Price Logic Validation
Common error: stopPrice and limitPrice equal or limitPrice is worse than stopPrice. If for STOP_LOSS_LIMIT on sell limitPrice >= stopPrice — the order never executes (market crashes through both levels). Recommended gap: limitPrice 0.1–0.5% below stopPrice on sell.
// iOS — validating gap between stopPrice and limitPrice
func validateStopLimitPrices(stop: Decimal, limit: Decimal, side: OrderSide) -> ValidationResult {
switch side {
case .sell:
guard limit < stop else { return .error("Limit price must be below activation price") }
let gap = (stop - limit) / stop
if gap < 0.001 { return .warning("Small gap — execution risk if price moves sharply") }
case .buy:
guard limit > stop else { return .error("Limit price must be above activation price") }
}
return .valid
}
Display in Order List
Stop orders awaiting trigger (PENDING) should look different from active ones. Label "Stop" or "Conditional," activation price large, limit price smaller. Progress bar "distance to trigger" as % of current price is helpful but optional.
On WebSocket status change event (executionReport with X=PENDING_CANCEL → FILLED) — send push: "Stop order triggered: sold 0.5 BTC at 41,200 USDT."
Timeline: 2–3 days for three fields with price logic validation, mechanics tips, status display, push on trigger.







