דלגו לתוכן
פתיחת RaamTrade

VWAPDeviation — VWAP Deviation

תוכן זה אינו זמין עדיין בשפה שלך.

The close’s distance from the rolling VWAP, in standard deviations of that distance. A z-score against a volume-weighted reference rather than a plain average — the mean-reversion read for anyone who thinks the volume-weighted price is the fairer anchor.

Signature

VWAPDeviation(period, on=<source>)
Argument Type Required Notes
period int Param or literal Yes VWAP and deviation window. Default 20, bounds 2–400.
on= symbol No Source symbol. Defaults to the trade symbol. Reads high, low, close, volume.

Formula

$$ d_t = C_t - \text{RollingVWAP}_t, \quad \text{VWAPDev} = \frac{d_t}{\sigma(d, n)} $$

Warmup

period bars; 0 when the deviations have no spread.

Reading the value

vd.value
vd < -2
vd.crossed_above(0)

Example

class VwapReversion(Strategy):
"""Fade a two-sigma stretch from the volume-weighted price."""
trade = Symbol()
sizing = FixedCapital()
def execute(self):
vd = VWAPDeviation(20, on=self.trade)
if vd.value < -2 and self.trade.is_flat:
self.buy(self.trade, reason=f"VWAP dev {vd.value:.2f}")
if vd.value > 0 and self.trade.is_long:
self.sell(self.trade, self.trade.position, reason="Back at VWAP")

Notes

  • Built on RollingVWAP, so the same caveat applies: this is not session VWAP and never resets at the open.