v1

latestOpenAPI 3.0.32026-07-267278168.1 KB
TWAP Orders

Create TWAP Order

Creates a new TWAP (Time-Weighted Average Price) order. The order is split into child orders placed at regular intervals over the specified running time. Running time must be between 5 minutes and 24 hours and a multiple of the frequency. The number of child orders (runningTime / frequency) must be between 2 and 200. For how TWAP execution works, see TWAP orders.

post/v1/perps/twap/order

Request body

marketstring required

Perps trading market

side'buy' | 'sell' required

Order side

sizestring required

Total order size in base currency to execute over the TWAP duration

runningTimeinteger required

Total duration of the TWAP order in seconds. Must be between 300 (5 minutes) and 86400 (24 hours) and a multiple of frequency.

frequencyinteger required

Interval between child orders in seconds. runningTime / frequency gives the number of child orders, which must be between 2 and 200.

reduceOnlyboolean

If true, child orders are reduce-only

maxPricestring

Maximum allowed price for child orders. Child orders will not be placed above this price.

minPricestring

Minimum allowed price for child orders. Child orders will not be placed below this price.

Example request

{
  "market": "AAPL-USD.P",
  "side": "buy",
  "size": "20.30",
  "runningTime": 3600,
  "frequency": 60,
  "maxPrice": "160.00",
  "minPrice": "140.00"
}

Response

Created TWAP order

successboolean required

Whether the request was successful

errorstring

Error message, present only on failure

error_codestring

Semantic error code. See each endpoint's error responses for the specific codes it can return.

deprecatedstring

Deprecation notice, if applicable

Example response

{
  "success": true,
  "result": {
    "twapId": "twap_70a37d8f972f2494837f9dba8364cbb4",
    "market": "AAPL-USD.P",
    "side": "buy",
    "startTime": "2024-01-04T16:00:00Z",
    "finishTime": "2024-01-04T17:00:00Z",
    "runningTime": 3600,
    "frequency": 60,
    "avgFilledPrice": "150.25",
    "filledSize": "10.00",
    "totalSize": "20.30",
    "totalFees": "0.152",
    "orderStatus": "running",
    "maxPrice": "160.00",
    "minPrice": "140.00",
    "successfulOrders": 30,
    "twapCancelReason": 1,
    "lastChildOrderError": "twap_child_order_not_fully_filled"
  }
}