Volume Weighted Average Price Wikipedia.
This is the rolling VWAP: over each lookback window it is
sum(TP * volume) / sum(volume) with the typical price
TP = (high + low + close) / 3 — not the session-anchored variant that
resets every trading day.
Bars are maps with at least :high, :low, :close and :volume. See
TAlib for the remaining conventions: chronological order, oldest
first, series aligned with the input, nil when there is not enough
data.
Summary
Functions
Calculate the latest rolling VWAP.
Calculate the full rolling VWAP series in a single pass (sliding price-volume and volume sums).
Functions
@spec vwap([map()], pos_integer()) :: float() | nil
Calculate the latest rolling VWAP.
Parameters
- bars: list of bars, oldest first.
- period: lookback window, a positive integer (default 14).
Examples
iex> bars = [
...> %{high: 11, low: 9, close: 10, volume: 100},
...> %{high: 12, low: 8, close: 11, volume: 300}
...> ]
iex> TAlib.Indicators.VWAP.vwap(bars, 2)
10.25
@spec vwap_list([map()], pos_integer()) :: [float() | nil]
Calculate the full rolling VWAP series in a single pass (sliding price-volume and volume sums).
Returns a list aligned with bars: the first period - 1 entries are
nil, and every later entry is the volume-weighted average price of
the window ending at that point.
Parameters
- bars: list of bars, oldest first.
- period: lookback window, a positive integer (default 14).
Examples
iex> bars = [
...> %{high: 11, low: 9, close: 10, volume: 100},
...> %{high: 12, low: 8, close: 11, volume: 300}
...> ]
iex> TAlib.Indicators.VWAP.vwap_list(bars, 2)
[nil, 10.25]