بوابة المطوّرين
النمط

Orders & Trading#

Order Types (Market, Limit, Trigger, Take Profit & Stop Loss)#

Onchain supports limit and market orders for both spot and perpetual markets. A limit order specifies the maximum buy price or minimum sell price and follows the selected time in force. A market order executes immediately against the best available liquidity; any unfilled quantity is canceled. Market orders are protected by the configured maximum slippage and the market's price band.

Perpetual markets additionally support trigger orders and take-profit and stop-loss orders. These orders remain off the order book until the selected mark price or index price reaches the trigger condition. The system then submits the configured limit or market order.

Execution Instructions (GTC, IOC, FOK, Post-only)#

Limit orders support these time-in-force instructions:

  • Good till canceled (GTC): The unfilled quantity remains active until filled or canceled.
  • Post-only: The order is accepted only if it adds liquidity to the order book.
  • Fill or kill (FOK): The full quantity must execute immediately or the entire order is canceled.
  • Immediate or cancel (IOC): The order executes immediately to the available extent and cancels any remainder.

Reduce Only Order#

A reduce-only order can only decrease or close an existing position. It cannot increase exposure or reverse the position. If the requested quantity exceeds the open position, the executable quantity is reduced to the position size. Reduce-only is available in one-way mode.

Order States & Records#

Active States

  • Open: Accepted but not filled. Displayed in Open Orders.
  • Partially filled: Partially executed and still active. Not displayed in Open Orders.
  • Modified: Amended by the user or system. The order ID remains unchanged.
  • Amend and replace: A price change or size increase cancels and reopens the order. The order ID remains unchanged, but its queue position changes. Displayed in Open Orders.

Inactive States

  • Filled: Fully executed. Displayed.
  • Triggered: A trigger condition is met. Displayed in Trigger Orders.
  • Triggered and failed: The trigger fails before an execution order is created. One record is displayed.
  • Failed: The triggered execution order is created but fails to execute. It may appear with the original Triggered record.
  • Canceled: Accepted but canceled before completion. Displayed.
  • Partially filled and canceled: Partially executed, with the remaining quantity canceled. Displayed.

Trigger Orders & TPSL#

A trigger order defines a trigger direction, trigger price, and trigger-price type. The trigger can reference either the mark price or index price. Once the condition is met, the system submits the configured limit or market order.

Take-profit and stop-loss instructions can be attached to a new order, an existing order, or an open position. Each instruction uses a mark-price or index-price trigger and can submit either a limit or market order when activated.

Order Validation#

Onchain validates price and quantity precision, minimum trade amount, order-value limits, available margin, price bands, position limits, and open-interest limits before accepting an order. The same checks apply when an amendment increases exposure.

For spot buys, the system reserves limit price × quantity. For spot sells, it reserves the token quantity. Open spot and perpetual orders and positions share the same account balance, so funds already in use by another product are unavailable for new orders.