Skip to main content
Attach trigger orders to any order, or place standalone TP/SL on existing positions. The registered provider plugin authorizes both flows with its SDK-managed credential; the user’s wallet is not prompted.
The examples on this page use Hyperliquid (provider: 'hyperliquid'). Replace the provider value with any supported provider from getProviders().

Take Profit & Stop Loss

Attach trigger orders to any order using the takeProfit and stopLoss fields on placeOrder:
This produces multiple actions: Trigger wires are bundled into the placeOrder action. The placeTriggerOrder action type only appears for standalone trigger orders (via placeTriggerOrder()).
If limitPrice is omitted, the trigger executes as a market order.
Bundled legs always cover the whole order; size is rejected on Hyperliquid, Lighter and Ondo. Ondo legs accept triggerPrice only. Spot markets reject TP/SL on Hyperliquid and Lighter. For a partial-size trigger, use placeTriggerOrder.

Trigger order types

Trigger orders are read back as Orders (see getOrders) whose type is one of four OrderType members, with a triggerPrice, a triggerCondition and an optional limitPrice: The lifecycle is OrderStatus: an armed trigger is OPEN, TRIGGERED means the trigger price was hit and the order went live, and CANCELLED is terminal. See Order Status. Narrow the Order union with isTriggerOrder, isTakeProfitOrder, isStopLossOrder and isTpSlOrder. triggerConditionFor(type, side) derives the condition from the trigger type and execution side.

Standalone Trigger Orders

Place standalone TP/SL orders on existing positions, separate from a main order, via placeTriggerOrder:
size is optional per leg: omit it to track the full position, or set a base-asset decimal string for a fixed partial-position trigger.
placeTriggerOrder() sends a placeTriggerOrder action type, which creates standalone trigger orders on existing positions. A venue rejection does not throw; check success on each entry of result.results. See Error Handling.
API Reference: POST /createAction · /executeAction