What is VWAP? Volume-weighted average price, explained with code

VWAP — volume-weighted average price — is both an execution benchmark and a popular intraday indicator. As a benchmark it answers a simple question: did I trade better or worse than the average price the whole market paid today, weighted by where the volume actually happened? As an indicator, traders use the VWAP line as a moving fair-value level that price tends to revert to. This guide shows exactly how VWAP is calculated, how an execution algorithm uses it, how traders read it as support and resistance, and the Python to compute it.

On this page
  1. What VWAP is
  2. How it is calculated
  3. VWAP in code
  4. As an execution benchmark
  5. As an indicator
  6. VWAP vs TWAP
  7. FAQ

What VWAP is

VWAP is the volume-weighted average price: the average price at which an asset traded over a period, with each price weighted by the volume that traded there. Unlike a simple average, it reflects where the real activity happened — a price level that saw huge volume counts far more than a level that barely traded. It resets each session and is overwhelmingly an intraday tool.

How it is calculated

For each bar, take the typical price (high + low + close, divided by three), multiply by that bar’s volume, accumulate those products, and divide the running total by the running total volume. The result is a line that hugs price but lags toward the high-volume levels.

price VWAP
Intraday price oscillates around the VWAP line and frequently reverts to it — why traders treat it as fair value.

VWAP in code

python · vwap.pyimport pandas as pd

def vwap(df):
    tp = (df['high'] + df['low'] + df['close']) / 3
    cum_vol = df['volume'].cumsum()
    cum_pv = (tp * df['volume']).cumsum()
    df['vwap'] = cum_pv / cum_vol
    return df

# long bias when price > vwap, short bias when below
df = vwap(df)
df['above_vwap'] = df['close'] > df['vwap']

As an execution benchmark

Institutions judge a large order against VWAP: filling below the day’s VWAP on a buy is “good execution.” A VWAP execution algorithm front-loads trading into high-volume periods so its average fill tracks the benchmark, minimising slippage versus the market’s own activity.

As an intraday indicator

Many discretionary and bot strategies treat VWAP as dynamic fair value: price above VWAP signals intraday strength, price below signals weakness, and reversions to the line are common mean-reversion entries. Because it resets daily, VWAP is useless for multi-day swing systems — it is a day-trading instrument.

VWAP vs TWAP

VWAP weights by volume; TWAP weights by time. VWAP is the institutional default because it matches the market’s natural rhythm, but it needs reliable volume data, which crypto venues sometimes fudge. When volume data is dirty or thin, TWAP’s simple time schedule is the safer choice.

Not financial advice. This content is educational. Automated and algorithmic trading carries a real risk of financial loss. Never trade money you cannot afford to lose. Review the SEC investor.gov and CFTC resources before trading.

Frequently asked questions

What does VWAP mean?

VWAP stands for volume-weighted average price — the average price an asset traded at over a period, with each price weighted by the volume that traded there. Levels with large volume count far more than thinly traded levels, so VWAP reflects where the real market activity happened. It resets each session and is primarily an intraday tool.

How is VWAP calculated?

For each bar you take the typical price (high plus low plus close, divided by three), multiply it by that bar’s volume, accumulate those products through the session, and divide the running total by the running total volume. The result is a line that follows price but is pulled toward the high-volume levels.

How do traders use VWAP?

Traders use VWAP two ways. As an execution benchmark, institutions try to fill large orders better than the day’s VWAP. As an indicator, they treat the VWAP line as dynamic fair value — price above it signals intraday strength, below it weakness, and reversions back to the line are common mean-reversion entries.

What is the difference between VWAP and TWAP?

VWAP weights execution and averaging by volume, trading more during naturally busy periods, while TWAP weights everything by time on a fixed schedule. VWAP is the institutional default because it matches the market’s real rhythm, but it depends on reliable volume data; when volume is thin or unreliable, the simpler TWAP is safer.

MB

Mustafa Bilgic

Algorithmic trading practitioner · Founder, AITradingBot.us

Mustafa builds and backtests automated trading systems and writes about them without the hype. Every tool on this site is free and runs entirely in your browser.