HomeDocumentationAPI Reference
Log In
API Reference

TWAP Orders


TWAP Orders

TWAP (Time-Weighted Average Price) orders split a large order into smaller slices executed evenly over a time window. This helps reduce market impact by spreading execution rather than placing one large order at once.

How It Works

  1. You submit an order with algo_type: "twap", specifying the total amount, how long to execute over (algo_duration_sec), and how many slices (algo_num_slices).
  2. The system divides your order into equal slices and executes one market IOC order at each interval.
  3. If earlier slices don't fully fill (e.g. due to thin liquidity), later slices automatically increase in size to catch up — capped at 2x the base slice size to limit impact.
  4. Once the time window expires, the order finalizes. If fully filled, the status is filled. If only partially filled, the status is cancelled with reason algo_completed.

Parameters

ParameterDescriptionConstraints
algo_typeAlgorithm type"twap"
algo_duration_secTotal execution window in seconds60 – 86,400 (24 hours)
algo_num_slicesNumber of slices to split the order into2 – 1,000
order_typeMust be "market"
time_in_forceMust be "ioc"

The minimum interval between slices is 10 seconds (algo_duration_sec / algo_num_slices >= 10).

Limits

  • Up to 5 active TWAP orders per subaccount.
  • TWAP orders cannot be amended — only cancelled and re-submitted.
  • MMP is not supported for TWAP orders.

Cancellation

  • Cancel a single order with private/cancel_algo_order.
  • Cancel all active TWAP orders with private/cancel_all_algo_orders.

Tracking Progress

Order updates are streamed on the {subaccount_id}.orders WebSocket channel. Key fields to monitor:

  • algo_slices_completed — how many slices have executed so far
  • algo_num_slices — total slices
  • filled_amount — cumulative amount filled across all slices
  • statusalgo_active while running, filled or cancelled when done

Example

To sell 100 ETH-PERP over 10 minutes in 20 slices:

{
  "instrument_name": "ETH-PERP",
  "direction": "sell",
  "order_type": "market",
  "time_in_force": "ioc",
  "amount": "100",
  "algo_type": "twap",
  "algo_duration_sec": 600,
  "algo_num_slices": 20
}