Time-weighted average price (TWAP) is the average price of an asset over a chosen period, calculated so that every interval of time counts equally regardless of how much was traded in it. The term has two closely linked uses. As a measurement, TWAP is a benchmark that shows what the typical price was during a window, such as an hour or a day. As a trading strategy, a TWAP order splits a large trade into equal slices executed at regular intervals, so that the trader's average price ends up close to the market's TWAP.
TWAP is widely used by institutional traders, brokers and OTC desks in shares, currencies and crypto, and it has become a basic building block of decentralized finance, where TWAP calculations from on-chain trading are used to supply prices to lending and derivatives protocols. It is usually compared with the volume-weighted average price (VWAP), which gives more weight to periods with heavier trading.
TWAP in plain terms
Imagine you need to buy a large amount of petrol for a company's vehicles over a month. If you buy it all on one day, you might be unlucky and pay the highest price of the month, and your huge purchase might even push the local price up. If instead you buy the same small amount every day, your cost will end up close to the month's average price, neither the best nor the worst.
A TWAP strategy works the same way for trading. By spreading a big order evenly over time, a trader avoids moving the market with one large purchase and avoids the risk of choosing a bad moment. TWAP as a measurement simply asks: if you had sampled the price at equal intervals across the period, what would the average have been?
Formula and example
In its simplest form, TWAP is the average of prices observed at equal time intervals:
- to are the prices observed at each interval.
- is the number of intervals in the period.
Many traders use a representative price for each interval, such as the average of its open, high, low and close. For example, suppose a token's prices sampled every hour over four hours are 100, 104, 102 and 98 dollars. Their sum is 404, and dividing by 4 gives a TWAP of 101 dollars. A trader who bought an equal amount at each of those four points would also have paid an average of 101 dollars per token.
TWAP as an execution strategy
Large orders can move prices against the trader, a cost known as price impact, and can reveal the trader's intentions to others. A TWAP algorithm reduces both by slicing the order into smaller child orders sent at fixed intervals, often with small random variations in size and timing so that the pattern is harder to detect. Brokers offer TWAP among their standard algorithmic trading tools, and many crypto exchanges offer TWAP orders directly. The child orders may be market orders or limit orders, depending on whether the trader prioritizes completion or price.
TWAP suits markets where trading volume is fairly even through the day, or where the trader does not have a reliable volume forecast. Where volume follows a predictable pattern, such as heavy trading at the open and close of stock markets, VWAP strategies are often preferred. In DeFi, a related design, the time-weighted automated market maker, builds this kind of gradual execution into the exchange itself.
TWAP oracles in DeFi
DeFi protocols need reliable prices to value collateral and trigger liquidations. Reading the current price from a single automated market maker pool is risky, because an attacker can push that price far out of line for a moment, for example with a flash loan, and exploit protocols that rely on it. Uniswap's second version, released in 2020, introduced a way for contracts to calculate a TWAP from the pool's price history, by keeping a running total of prices weighted by the time each lasted. A protocol can then compare the totals at two points in time to obtain the average over that window.
Because manipulating a TWAP requires holding the pool price away from the market for many blocks rather than for a single transaction, it is much more expensive to attack than a spot reading. TWAP oracles are therefore one of the main defences against oracle manipulation, alongside external oracle networks.
Limitations
TWAP ignores volume, so a period of very light trading counts as much as a busy one, which can make it unrepresentative. As an execution method, spreading an order over time exposes the trader to the risk that prices trend away during the window, and a predictable schedule can be exploited by other traders who anticipate the remaining slices. As an oracle, TWAP lags behind fast-moving markets: a longer window is harder to manipulate but slower to reflect genuine price changes, which can delay liquidations during crashes. Pools with little liquidity can still be manipulated over time by a well-funded attacker, and several DeFi exploits have targeted protocols that used short TWAP windows on thin markets. Despite these trade-offs, TWAP remains one of the most widely used price measures in both traditional and crypto markets, closely related to the simple moving average.