TWAP Execution
What It Does
TWAP (Time-Weighted Average Price) splits a large order into smaller slices executed over time. Instead of placing one big order that moves the market, TWAP places many small orders at regular intervals.
How It Works
- You specify a total size and duration (e.g., $5,000 over 10 minutes)
- The engine calculates slice count dynamically — targeting 15-30 second intervals
- Each slice is placed as a post_only limit order (maker, 0% fee)
- Between slices, the engine checks if the current price is favorable
- If price is unfavorable, it waits (up to 10 minutes max) for a better entry
Dynamic Slicing
| Duration | Slices | Interval |
|---|---|---|
| 5 min | 20 | 15s |
| 10 min | 30 | 20s |
| 30 min | 60 | 30s |
| 60 min | 120 | 30s |
Shorter TWAPs use more frequent, smaller slices. Longer TWAPs cap at 30-second intervals.
Favorable Entry Detection
For buy TWAPs, the engine tracks a 2-minute rolling average and only executes slices when the current price is below average (buying dips). For sell TWAPs, it waits for price to be above average (selling rips).
If the price stays unfavorable for more than 10 minutes, the engine executes anyway to stay on schedule.
Stealth Randomization
Slice intervals are randomized by +/-30% to prevent detection. A 20-second base interval might execute at 14s or 26s.
Parameters
| Parameter | Default | Description |
|---|---|---|
| Duration | varies | Total time window for execution |
| Drawdown threshold | 0.1% | How much dip/rip counts as "favorable" |
| Randomization | 30% | Interval variation for stealth |
| Max wait per chunk | 10 min | Hard fallback if price stays unfavorable |
When to Use
- Entering or exiting large positions ($1K+) on thin DEX books
- Copy trade entries where you want to minimize impact
- Any time you want to avoid moving the price against yourself
When Not to Use
- Fast-moving markets where you need immediate execution
- Very small orders ($50 or less) where splitting adds no benefit
- When the spread is already tight and a single limit fills instantly