VWAP (volume-weighted average price)
VWAP (volume-weighted average price) is an average price in which each price counts in proportion to its volume. A $10,000 trade at $2.02 moves VWAP more than a $100 trade at $2.00.
Two meanings of VWAP
| Where | Computed from | What it shows |
|---|---|---|
| Chart indicator | Trades over a period, e.g. since the start of the day | The average price the market traded at |
| Execution price | The book levels an order will consume | The average price of your trade before you send it |
The first VWAP describes past trades. The second is computed before entry: it shows the average price an order will fill at and how much of the spread slippage will eat.
Example: buying through three levels
Hypothetical example: a $5,000 market buy against three ask levels. Level sizes are in dollars, as in Genesis API responses.
| Ask price | Level size | Taken | Coins |
|---|---|---|---|
| $2.00 | $2,000 | $2,000 | 1,000 |
| $2.01 | $2,010 | $2,010 | 1,000 |
| $2.02 | $2,020 | $990 | 490.10 |
The third level gives 990 ÷ 2.02 ≈ 490.10 coins, for a total of 1,000 + 1,000 + 490.10 = 2,490.10. VWAP = 5,000 ÷ 2,490.10 ≈ $2.0080, 0.40% above the best ask of $2.00. A 0.5% cross-exchange spread shrinks to about 0.1% after this buy if the sell fills at the best price, and that is before fees.
The same calculation in code; asks are the levels from a /orderbooks/book response, which holds the top 10:
def vwap_buy(asks, usd):
"""Average buy price for usd dollars over [price, $] levels."""
coins, left = 0.0, usd
for price, size_usd in asks: # from the best price down
take = min(left, size_usd)
coins += take / price
left -= take
if left <= 0:
return usd / coins
return None # the book cannot fill the order
asks = [[2.00, 2000], [2.01, 2010], [2.02, 2020]]
print(round(vwap_buy(asks, 5000), 4)) # 2.008
VWAP in Genesis API
/orderbooks/exec returns VWAP from the books of every market: for a volume of $500, 1,000, 2,500, 5,000 or 10,000 you get a [buy price, sell price] pair, that is, the volume divided by the coins it buys or sells. null means the book is too thin for that volume (execution prices). The same prices sit in order_delta on arbitrage rows from /orderbooks/spreads/{dataset} (order-book Δ), and in /market/open-interest the total.avg_price field is the coin's volume-weighted average price across exchanges.
See also: market depth, order book, spread, order book API, order book endpoints.
Questions and answers
Why is the execution price above the best ask?
If an order does not fit into the best level, it takes the next, more expensive ones. The thinner the book, the further VWAP moves from the best price; if the book cannot fill the whole volume, the API returns null.