> For the complete documentation index, see [llms.txt](https://tradewithonyx.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tradewithonyx.gitbook.io/docs/trading/twap.md).

# TWAP

## What is TWAP?

TWAP (Time-Weighted Average Price) is an order execution strategy that breaks a large order into smaller trades, executed at regular intervals over a set duration.

Instead of placing one large order that may impact price, TWAP helps smooth execution, reducing slippage and market impact.

<figure><img src="/files/15NMIAxy2PEZnq65Sw3P" alt="" width="354"><figcaption></figcaption></figure>

### How TWAP works

The TWAP order specifications can be split into 4 distinct components:

1. Order Size – The user specifies the total amount to buy/sell.
2. Duration – The time over which the order will be executed.
3. Intervals – The order is split into smaller chunks, executed evenly at each interval.
4. Execution – Orders are placed automatically until the total size is filled.

To understand: Buying **50 BTC** over **1 hour** with **12 intervals** intends that the system will execute **\~4.167 BTC** every **5 minutes**.

***

### Randomize mode

When Randomize mode is enabled:

* The system slightly varies the size and/or timing of each order.
* This makes execution less predictable and harder to track.
* Helps mitigate predatory algorithms or bots attempting to anticipate TWAP orders.

To understand: Instead of executing exactly **\~4.167 BTC** every **5 minutes**, the system may execute 3.5 BTC, then 5.1 BTC, with timing offsets of a few seconds.

***

### Reduce-Only Mode

When Reduce-Only mode is enabled:

* The TWAP will only reduce your current position.
* It prevents the strategy from flipping your position (e.g. closing a long and accidentally opening a short).

This ensures TWAP is used strictly for scaling out, not scaling in.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://tradewithonyx.gitbook.io/docs/trading/twap.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
