Time-Weighted Average Price (TWAP)TWAP
TWAP is the average price of an asset over a period with every moment weighted equally. A TWAP order splits a large trade into equal slices spread evenly over time, and a TWAP oracle uses the same average to give DeFi protocols a price that is hard to manipulate.
Buying a large position in one go moves the price against you. One of the oldest answers is to spread the order evenly through time and judge the result against the average price over that window: the time-weighted average price. The same idea now appears in three places: as a benchmark, as an execution algorithm at brokers and crypto exchanges, and as an on-chain price feed that lending and derivatives protocols rely on. This entry covers the formula, how TWAP orders slice a trade, how they differ from VWAP, and how TWAP oracles work and can be attacked.
- Category
- Order Types
- Reading time
- 7 min
- Also called
- Time-weighted average price, TWAP order, TWAP algo
- Updated
TWAP in plain words
Take the price at equal time intervals and average them. Each minute or hour counts the same, however much traded in it. That is what separates it from Volume-Weighted Average Price, which gives more weight to busy periods.
A TWAP order spreads a big trade evenly over a chosen window. Interactive Brokers’ TWAP algo aims to achieve the time-weighted average price from the moment you submit the order until it completes.1 Exchanges such as Binance and Hyperliquid split the order into smaller pieces sent at regular intervals.23
A TWAP oracle is an on-chain average. Uniswap v2 keeps a running sum of its price over time, so any contract can read a time-weighted average for a chosen window.4 See Blockchain Oracle.
How to use a TWAP order, step by step
Limits and parameters differ by platform; these are the common choices.
Add trading conditions if offered
Interactive Brokers lets the algo trade only when, for example, the order is marketable or the midpoint matches.1
Let the algorithm slice
Slices go out on a fixed schedule; Hyperliquid sends them no more often than every 30 seconds.3
Watch the fill against the target
If slices fail to fill, Hyperliquid’s TWAP tries to catch up with larger slices and may still finish short.3
Measure the result
Compare your average fill with the window’s TWAP to judge execution. See Implementation Shortfall.
Worked examples
Example 1 — TWAP vs. VWAP on the same prices
WeightingHourly prices: $50.00, $50.40, $50.80, $50.20, $50.60. Volume is 1,000 shares each hour except the third, with 4,000 (hypothetical).
| Sum of the 5 prices | $252.00 |
| TWAP | $252.00 ÷ 5 = $50.40 |
| Price × volume, summed | $404,400 |
| Total volume | 8,000 shares |
| VWAP | $404,400 ÷ 8,000 = $50.55 |
The busy third hour at $50.80 pulls VWAP up to $50.55, while TWAP ignores volume and stays at $50.40. The busy hour adds $50.80 × 4,000 = $203,200 of the $404,400 total.
Example 2 — How an exchange slices a TWAP order
SlicingHyperliquid’s docs describe a $10,000 TWAP over 1 hour with a 30-second interval, giving about 121 slices.3
| Intervals in an hour | 3,600 ÷ 30 = 120 |
| Slices (one at each end) | 120 + 1 = 121 |
| Size of each slice | $10,000 ÷ 121 ≈ $82.64 |
| Largest catch-up slice | 3 × $82.64 = $247.92 |
Each slice is small enough to barely move the Order Book. If slices go unfilled, later ones grow, but only to three times the normal size, so the order may finish short.3
Example 3 — Reading a TWAP oracle and the cost of a spike
OracleAn oracle’s cumulative price reads 2,000,000 at the start of a 3,600-second window and 9,380,000 at the end. An attacker pushes the price to 3,000 for one 12-second block (hypothetical numbers).
| Change in cumulative price | 9,380,000 − 2,000,000 |
| Equals | 7,380,000 |
| TWAP | 7,380,000 ÷ 3,600 = 2,050 |
| Spike effect | (3,000 − 2,050) × 12 ÷ 3,600 |
| Shift in the TWAP | ≈ +3.17 (about 0.15%) |
A one-block spike of 46% moves a one-hour TWAP by only about 0.15%, which is why protocols use it instead of the spot price. To move the average further, an attacker must hold the price off for much of the window.4
TWAP vs. VWAP
| Aspect | TWAP | VWAP |
|---|---|---|
| What is weighted | Time: every interval counts the same | Volume: busy periods count more |
| Execution schedule | Even slices through the window2 | Follows market volume; may run faster or slower5 |
| Data needed | Prices only | Prices and traded volume |
| Fill guaranteed? | No12 | No; some deviation is likely5 |
| Common uses | Thin markets, crypto, on-chain oracles4 | Equity benchmarks and institutional orders |
Where TWAP is used
Working large orders
Spreading a trade over time limits Market Impact; Binance describes its TWAP as splitting a large order to reduce price impact.2
Crypto exchanges and DEXs
Centralized exchanges and on-chain venues such as Hyperliquid (HYPE) offer TWAP orders directly.3 See Centralised and Decentralised Exchanges.
On-chain price feeds
Protocols read Uniswap (UNI)’s cumulative price to get an average that one trade cannot set.4
Execution benchmark
Your average fill vs. the window’s TWAP shows whether the order was worked well. See Best Execution.
Advantages and disadvantages
Advantages
Disadvantages
- Ignores volume, so it trades as much in quiet periods as busy ones.
- An even schedule is easy for others to spot and trade against. See Front Running.
- No guarantee of completion or of matching the TWAP.12
- Oracles lag fast real moves, and short windows are cheaper to attack.4
Going deeper
Read as far as you need. Each level builds on the one before it.
The formula
Beginner
With prices sampled at equal intervals, TWAP = sum of prices ÷ number of prices. Over five hourly readings of $50.00, $50.40, $50.80, $50.20 and $50.60, that is $252.00 ÷ 5 = $50.40.
The general form weights each price by how long it lasted: TWAP = (cumulative price at the end − cumulative price at the start) ÷ time elapsed. That is how Uniswap v2 computes it on-chain.4 Compare Time-Weighted and Money-Weighted Return, a different use of the word “time-weighted”.
TWAP orders at brokers and exchanges
Intermediate
At Interactive Brokers the TWAP algo covers stocks, ETFs, options, futures and currencies, can wait for conditions such as a matching midpoint, and can keep trading past its end time if you allow it; it is not guaranteed to fill.16 Its VWAP algo instead follows the day’s volume and may trade faster or slower than the market.5
Crypto venues add their own limits. Binance Spot runs TWAP for API users over 5 minutes to 24 hours, with up to 20 at once per account.2 Hyperliquid can randomize slice sizes by up to 20% and caps each slice’s slippage at 3%.3 Randomizing makes the pattern harder to spot. See Algorithmic Trading and Iceberg Order.
TWAP oracles and manipulation
Advanced
Uniswap v2 records the price at the start of each block, before any trades in it, and adds it to a cumulative total weighted by time.4 Moving the average means trading the price away at the end of a block and leaving it there, while arbitrageurs trade it back; the docs say the cost rises roughly in line with pool liquidity and window length.4
The trade-off is lag: a long window resists attacks but reacts slowly to real moves. Uniswap warns that measuring a single block is not enough when large value depends on it.4 Exploits of thin pools and short windows, often funded with a Flash Loan, are a known DeFi attack pattern. See Maximal Extractable Value and Chainlink (LINK).
Common mistakes
Check your understanding
Test yourself before moving on. Each answer comes with an explanation.
Key points to remember
- TWAP averages prices with every time interval weighted equally.
- TWAP orders slice a trade into even pieces over a window to limit impact.
- Neither the fill nor the average price is guaranteed.
- VWAP weights by volume; TWAP ignores it.
- TWAP oracles resist one-block manipulation but lag real price moves.
Frequently asked questions
Is TWAP better than VWAP?
Does a TWAP order guarantee the TWAP price?
What is a TWAP oracle?
Further learning
- Volume-Weighted Average Price
The volume-weighted cousin and the main alternative benchmark.
- Market Impact
The cost TWAP orders are designed to reduce.
- Implementation Shortfall
How execution quality is measured.
- Uniswap (UNI)
The DEX whose design made TWAP oracles common.
Sources
This article is written in our own words. The sources below support the specific facts, rules and figures marked with a number in the text. Links open the original publisher’s page.
- Interactive Brokers. Order Types and Algos: TWAP (opens in a new tab) Checked .
- Binance. How to Use TWAP Algorithm on Binance Spot (updated January 2026) (opens in a new tab) Checked .
- Hyperliquid Docs. Order types (opens in a new tab) Checked .
- Uniswap Docs. Oracles (Uniswap v2 concepts) (opens in a new tab) Checked .
- Interactive Brokers. Order Types and Algos: VWAP (Best-Efforts) (opens in a new tab) Checked .
- Interactive Brokers (IBKR Campus). Time-Weighted Average Price (TWAP) | IBKR Glossary (opens in a new tab) Checked .
Educational content, not financial advice. Examples use hypothetical prices and simplified costs; actual fees, margin rules and regulations vary by broker, market and country. We are not affiliated with any publisher linked above. Last reviewed . Report an error or request a source credit.