> For the complete documentation index, see [llms.txt](https://docs.pearprotocol.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pearprotocol.io/api-integration/executing-trade/order-type/time-weighted-average-price.md).

# Time-Weighted Average Price

A TWAP (Time-Weighted Average Price) order splits a large order into smaller chunks executed over a duration. Each chunk is a market order — individual chunks and timing are not exposed on-chain (CEX-style shielded execution).

Use `executionType: "TWAP"`. Also works for closing positions via the close API with `executionType: "TWAP"`.

```json
{
  "executionType": "TWAP",
  "leverage": 5,
  "usdValue": 5000,
  "slippage": 0.01,
  "twapDuration": 30,
  "twapIntervalSeconds": 60,
  "randomizeExecution": true,
  "longAssets": [{ "asset": "BTC", "weight": 0.5 }],
  "shortAssets": [{ "asset": "ETH", "weight": 0.5 }]
}
```

**How it works:**

* `twapDuration`: total duration in minutes (required)
* `twapIntervalSeconds`: seconds between chunks (default: 30)
* Number of chunks = `duration / interval`, capped by minimum $11 per asset per chunk
* USD value split equally across chunks
* `randomizeExecution`: adds ±10% jitter to chunk timing to reduce predictability
* Chunks queued via BullMQ and executed as individual market orders
* TP/SL intents are cached and applied after the first chunk creates a position; subsequent chunks merge into it

**Example**: $5,000 over 30 minutes at 60s intervals → 30 chunks of \~$166 each, one every \~60s (±6s with randomization).
