Skip to main content
A TWAP order splits amount into smaller market orders, called sub-orders, and sends them over duration_in_seconds. Each sub-order uses slippage_percent as its maximum slippage. This endpoint creates a TWAP order that the matching engine runs. It has no price limit and no randomized slices. For those settings, create a TWAP order strategy instead.

How a TWAP order runs

  • Pacifica plans one sub-order for every 30 seconds of duration_in_seconds, plus one. It plans fewer if amount holds fewer lots than that, so each sub-order is at least one lot.
  • Pacifica sends one sub-order about every 30 seconds.
  • Each sub-order is the remaining amount divided by the remaining sub-order count, rounded down to the lot size. It is at most 3 times the planned sub-order amount.
  • The order ends as completed when the full amount fills.
  • The order ends as expired if part of the amount is still unfilled after the last planned sub-order, or when its time runs out. Its expiration is 30 seconds after the end of duration_in_seconds.
  • If the engine rejects a sub-order, the order stops and ends as rejected_due_to_sub_order.
  • You can have up to 4 open TWAP orders per account in each market.

Operation Type (for Signing)

Request Body

FieldTypeNeedDescriptionExample
”account”stringrequiredUser’s wallet address42trU9A5…
“signature”stringrequiredCryptographic signature5j1Vy9Uq…
“timestamp”integerrequiredCurrent timestamp in milliseconds1716200000000
”symbol”stringrequiredTrading pair symbolBTC
”amount”stringrequiredTotal amount to execute, in token units0.121
”side”stringrequiredOrder side (bid/ask)bid
”reduce_only”booleanrequiredWhether each sub-order is reduce-onlyfalse
”slippage_percent”stringrequiredMaximum slippage for each sub-order, in percent. For example, “0.5” means 0.5%. At most 2 decimal places0.5
”duration_in_seconds”integerrequiredTime to spread the sub-orders over, in seconds. Minimum 303600
”client_order_id”Full UUID stringoptionalClient-defined order ID. Must not match another open TWAP order of yours in the same marketf47ac10b-58cc-4372-a567-0e02b2c3d479
”agent_wallet”stringoptionalAgent wallet address69trU9A5…
“expiry_window”integeroptionalSignature expiry in milliseconds30000
”builder_code”stringoptionalBuilder program code (3-16 alphanumeric characters). Not supported on spot marketsMYCODE
For this request, Pacifica plans 121 sub-orders of 0.001 BTC, about 30 seconds apart, if the BTC lot size is 0.001 or smaller.

Response

  • Status 200: TWAP order created successfully
order_id is the TWAP order ID. Use it to cancel the order or to get its history.
  • Status 400: Invalid request body, for example an unknown side or a slippage_percent with more than 2 decimal places
  • Status 422: The engine rejected the order
  • Status 500: Internal server error

Code Example (Python)