Order TypesIntermediate

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.

  1. Choose the size and the window

    Binance Spot allows 5 minutes to 24 hours; Hyperliquid allows 5 minutes to 7 days.23

  2. Set price protection

    Binance lets you add a limit price, otherwise slices go at market; Hyperliquid caps each slice at 3% slippage.23

  3. Add trading conditions if offered

    Interactive Brokers lets the algo trade only when, for example, the order is marketable or the midpoint matches.1

  4. Let the algorithm slice

    Slices go out on a fixed schedule; Hyperliquid sends them no more often than every 30 seconds.3

  5. 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

  6. 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

Weighting

Hourly 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).

Example 1 — TWAP vs. VWAP on the same prices — calculation
Sum of the 5 prices$252.00
TWAP$252.00 ÷ 5 = $50.40
Price × volume, summed$404,400
Total volume8,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

Slicing

Hyperliquid’s docs describe a $10,000 TWAP over 1 hour with a 30-second interval, giving about 121 slices.3

Example 2 — How an exchange slices a TWAP order — calculation
Intervals in an hour3,600 ÷ 30 = 120
Slices (one at each end)120 + 1 = 121
Size of each slice$10,000 ÷ 121 ≈ $82.64
Largest catch-up slice3 × $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

Oracle

An 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).

Example 3 — Reading a TWAP oracle and the cost of a spike — calculation
Change in cumulative price9,380,000 − 2,000,000
Equals7,380,000
TWAP7,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

AspectTWAPVWAP
What is weightedTime: every interval counts the sameVolume: busy periods count more
Execution scheduleEven slices through the window2Follows market volume; may run faster or slower5
Data neededPrices onlyPrices and traded volume
Fill guaranteed?No12No; some deviation is likely5
Common usesThin markets, crypto, on-chain oracles4Equity 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

  • Simple: only prices and time are needed.
  • Spreads a large order to reduce market impact.2
  • Hard to manipulate as an oracle over a long window.4
  • Predictable schedule that is easy to monitor.

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

  1. Treating TWAP as a price guarantee

    A TWAP order aims for the average; it does not promise it or a full fill.12

  2. Leaving out price protection

    Without a limit price, Binance TWAP slices go at market.2

  3. Picking a window too short

    Short windows mean bigger slices and more impact, and cheaper oracle attacks.4

  4. Confusing TWAP with VWAP

    TWAP weights time; VWAP weights volume. On busy days the two can differ noticeably.

Check your understanding

Test yourself before moving on. Each answer comes with an explanation.

Q1Prices at four equal intervals are 10, 12, 11 and 13. What is the TWAP?
Q2Why do DeFi protocols prefer a TWAP oracle to the current pool price?

Key points to remember

  1. TWAP averages prices with every time interval weighted equally.
  2. TWAP orders slice a trade into even pieces over a window to limit impact.
  3. Neither the fill nor the average price is guaranteed.
  4. VWAP weights by volume; TWAP ignores it.
  5. TWAP oracles resist one-block manipulation but lag real price moves.

Frequently asked questions

Is TWAP better than VWAP?

Neither is better in general. VWAP follows market volume, which suits liquid stocks with a regular daily pattern; TWAP needs only time, which suits thin markets and on-chain use.54

Does a TWAP order guarantee the TWAP price?

No. Interactive Brokers says its TWAP order may not fill during its duration, and Binance says TWAP orders do not guarantee execution.12

What is a TWAP oracle?

A smart contract price feed that averages a pool’s price over a window. Uniswap v2 stores a cumulative price, and the average is the change in that value divided by the time elapsed.4

Further learning

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.

  1. Interactive Brokers. Order Types and Algos: TWAP (opens in a new tab) Checked .
  2. Binance. How to Use TWAP Algorithm on Binance Spot (updated January 2026) (opens in a new tab) Checked .
  3. Hyperliquid Docs. Order types (opens in a new tab) Checked .
  4. Uniswap Docs. Oracles (Uniswap v2 concepts) (opens in a new tab) Checked .
  5. Interactive Brokers. Order Types and Algos: VWAP (Best-Efforts) (opens in a new tab) Checked .
  6. 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.