VWAP Deviation Oscillator
session_mode = rolling_bars | rolling_period = 20 | rolling_days = 30 | use_close = | deviation_mode = absolute | z_window = 50 | pct_vol_lookback = 100 | pct_min_sigma = 0.1 | abs_vol_lookback = 100 Overview
VWAP Deviation Oscillator measures how far price has moved away from VWAP and pairs that oscillator with multiple deviation-band outputs. It is useful when you want a VWAP-centric mean-reversion or extension study that can switch between absolute, percentage, and z-score style behavior.
In VectorTA the indicator accepts timestamped OHLCV input, supports several session and deviation modes, streams one bar at a time, and exposes batch sweeps over the rolling and volatility-window controls. That makes it one of the richer stateful deviation studies in the library.
Defaults: `session_mode = RollingBars`, `rolling_period = 20`, `rolling_days = 30`, `use_close = false`, `deviation_mode = Absolute`, `z_window = 50`, `pct_vol_lookback = 100`, `pct_min_sigma = 0.1`, and `abs_vol_lookback = 100`.
Implementation Examples
Run the oscillator on timestamped OHLCV slices or on candles with the default rolling-bar configuration.
use vector_ta::indicators::vwap_deviation_oscillator::{
vwap_deviation_oscillator,
VwapDeviationOscillatorInput,
VwapDeviationOscillatorParams,
};
let output = vwap_deviation_oscillator(&VwapDeviationOscillatorInput::from_slices(
×tamps,
&high,
&low,
&close,
&volume,
VwapDeviationOscillatorParams::default(),
))?;
println!("osc = {:?}", output.osc.last());
println!("std1 = {:?}", output.std1.last());API Reference
Input Methods ▼
VwapDeviationOscillatorInput::from_candles(&Candles, VwapDeviationOscillatorParams)
-> VwapDeviationOscillatorInput
VwapDeviationOscillatorInput::from_slices(&[i64], &[f64], &[f64], &[f64], &[f64], VwapDeviationOscillatorParams)
-> VwapDeviationOscillatorInput
VwapDeviationOscillatorInput::with_default_candles(&Candles)
-> VwapDeviationOscillatorInputParameters Structure ▼
pub struct VwapDeviationOscillatorParams {
pub session_mode: Option<VwapDeviationSessionMode>,
pub rolling_period: Option<usize>,
pub rolling_days: Option<usize>,
pub use_close: Option<bool>,
pub deviation_mode: Option<VwapDeviationMode>,
pub z_window: Option<usize>,
pub pct_vol_lookback: Option<usize>,
pub pct_min_sigma: Option<f64>,
pub abs_vol_lookback: Option<usize>,
}Output Structure ▼
pub struct VwapDeviationOscillatorOutput {
pub osc: Vec<f64>,
pub std1: Vec<f64>,
pub std2: Vec<f64>,
pub std3: Vec<f64>,
}Validation, Warmup & NaNs ▼
- Timestamps, high, low, close, and volume slices must share the same non-zero length and enough valid bars for the selected rolling windows.
- Session mode and deviation mode change the interpretation of the oscillator, but the input shape remains timestamped OHLCV.
- Streaming returns the current oscillator and three deviation-band values for each accepted bar.
- Batch mode validates every range axis before generating the output grid.
Builder, Streaming & Batch APIs ▼
VwapDeviationOscillatorBuilder::new()
.session_mode(VwapDeviationSessionMode)
.rolling_period(usize)
.rolling_days(usize)
.use_close(bool)
.deviation_mode(VwapDeviationMode)
.z_window(usize)
.pct_vol_lookback(usize)
.pct_min_sigma(f64)
.abs_vol_lookback(usize)
.kernel(Kernel)
.apply(&Candles)
.apply_slices(&[i64], &[f64], &[f64], &[f64], &[f64])
VwapDeviationOscillatorStream::try_new(params)
stream.update(timestamp, high, low, close, volume) -> (f64, f64, f64, f64)
VwapDeviationOscillatorBatchBuilder::new()
.rolling_period_range((start, end, step))
.rolling_days_range((start, end, step))
.z_window_range((start, end, step))
.pct_vol_lookback_range((start, end, step))
.pct_min_sigma_range((start, end, step))
.abs_vol_lookback_range((start, end, step))
.apply_slices(&[i64], &[f64], &[f64], &[f64], &[f64])Python Bindings
Python exposes direct, stream, and batch helpers for the VWAP deviation oscillator plus its three deviation bands.
from vector_ta import vwap_deviation_oscillator, vwap_deviation_oscillator_batch, VwapDeviationOscillatorStream
single = vwap_deviation_oscillator(timestamps, high, low, close, volume)
stream = VwapDeviationOscillatorStream()
point = stream.update(timestamps[-1], high[-1], low[-1], close[-1], volume[-1])
batch = vwap_deviation_oscillator_batch(
timestamps,
high,
low,
close,
volume,
rolling_period_range=(20, 40, 10),
z_window_range=(30, 70, 20),
abs_vol_lookback_range=(50, 150, 50),
)JavaScript/WASM Bindings
The WASM layer exposes direct, batch, allocation, and into-buffer helpers for timestamped VWAP-deviation workflows.
import init, { vwap_deviation_oscillator_js, vwap_deviation_oscillator_batch_js } from "vector-ta-wasm";
await init();
const single = vwap_deviation_oscillator_js(timestamps, high, low, close, volume);
const batch = vwap_deviation_oscillator_batch_js(timestamps, high, low, close, volume, {
rolling_period_range: [20, 40, 10],
z_window_range: [30, 70, 20],
abs_vol_lookback_range: [50, 150, 50],
});CUDA Bindings (Rust)
Additional details for the CUDA bindings can be found inside the VectorTA repository.
Performance Analysis
Across sizes, Rust CPU runs about 1.14× faster than Tulip C in this benchmark.
AMD Ryzen 9 9950X (CPU) | NVIDIA RTX 4090 (GPU)