Rogers-Satchell Volatility
lookback = 8 | signal_length = 8 Overview
Rogers-Satchell Volatility is a range-based volatility estimator built from open, high, low, and close data. It uses the Rogers-Satchell log-return formula to estimate variance inside each bar, then aggregates those bar terms over a rolling window and takes the square root to report volatility.
Unlike close-to-close estimators, this approach preserves intrabar information and remains useful when bars have directional drift. VectorTA also produces a signal line by averaging the volatility series over a second rolling window.
Defaults: `lookback = 8` and `signal_length = 8`.
Implementation Examples
Run the estimator on candles or direct OHLC slices and inspect the volatility series plus its signal line.
use vector_ta::indicators::rogers_satchell_volatility::{
rogers_satchell_volatility,
RogersSatchellVolatilityInput,
RogersSatchellVolatilityParams,
};
use vector_ta::utilities::data_loader::{Candles, read_candles_from_csv};
let output = rogers_satchell_volatility(&RogersSatchellVolatilityInput::from_slices(
&open,
&high,
&low,
&close,
RogersSatchellVolatilityParams {
lookback: Some(8),
signal_length: Some(8),
},
))?;
let candles: Candles = read_candles_from_csv("data/sample.csv")?;
let candle_output =
rogers_satchell_volatility(&RogersSatchellVolatilityInput::with_default_candles(&candles))?;
println!("rs = {:?}", output.rs.last());
println!("signal = {:?}", candle_output.signal.last()); API Reference
Input Methods ▼
RogersSatchellVolatilityInput::from_candles(&Candles, RogersSatchellVolatilityParams)
-> RogersSatchellVolatilityInput
RogersSatchellVolatilityInput::from_slices(&[f64], &[f64], &[f64], &[f64], RogersSatchellVolatilityParams)
-> RogersSatchellVolatilityInput
RogersSatchellVolatilityInput::with_default_candles(&Candles)
-> RogersSatchellVolatilityInput Parameters Structure ▼
pub struct RogersSatchellVolatilityParams {
pub lookback: Option<usize>,
pub signal_length: Option<usize>,
} Output Structure ▼
pub struct RogersSatchellVolatilityOutput {
pub rs: Vec<f64>,
pub signal: Vec<f64>,
} Validation, Warmup & NaNs ▼
- The open, high, low, and close slices must be non-empty, have matching lengths, and contain positive finite OHLC values.
lookbackmust be greater than zero and cannot exceed the available data length.signal_lengthmust be greater than zero.- The volatility output warms up after the lookback window fills, and the signal line warms up after an additional signal-length window.
- Streaming returns
Noneuntil both windows are warm. - Batch mode rejects unsupported kernels through
InvalidKernelForBatch.
Builder, Streaming & Batch APIs ▼
RogersSatchellVolatilityBuilder::new()
.lookback(usize)
.signal_length(usize)
.kernel(Kernel)
.apply(&Candles)
.apply_slices(&[f64], &[f64], &[f64], &[f64])
.into_stream()
RogersSatchellVolatilityStream::try_new(params)
stream.update(f64, f64, f64, f64) -> Option<(f64, f64)>
stream.get_warmup_period() -> usize
RogersSatchellVolatilityBatchBuilder::new()
.lookback_range(start, end, step)
.signal_length_range(start, end, step)
.lookback_static(usize)
.signal_length_static(usize)
.kernel(Kernel)
.apply_slices(&[f64], &[f64], &[f64], &[f64])
.apply_candles(&Candles) Error Handling ▼
pub enum RogersSatchellVolatilityError {
EmptyInputData,
NoValidInputData,
InvalidLookback { lookback: usize, data_len: usize },
InvalidSignalLength { signal_length: usize },
NotEnoughValidData { needed: usize, valid: usize },
InconsistentSliceLengths { open_len: usize, high_len: usize, low_len: usize, close_len: usize },
OutputLengthMismatch { expected: usize, got: usize },
InvalidRange { start: String, end: String, step: String },
InvalidKernelForBatch(Kernel),
} Python Bindings
Python exposes a scalar function, a streaming class, and a batch helper. The scalar call returns the volatility
array and the signal array, the stream emits a two-value tuple or None, and the batch helper
returns reshaped matrices together with the swept lookback and signal-length axes.
from vector_ta import (
rogers_satchell_volatility,
rogers_satchell_volatility_batch,
RogersSatchellVolatilityStream,
)
rs, signal = rogers_satchell_volatility(
open,
high,
low,
close,
lookback=8,
signal_length=8,
kernel="auto",
)
stream = RogersSatchellVolatilityStream(lookback=12, signal_length=5)
print(stream.update(open[-1], high[-1], low[-1], close[-1]))
batch = rogers_satchell_volatility_batch(
open,
high,
low,
close,
lookback_range=(8, 20, 4),
signal_length_range=(4, 8, 2),
kernel="auto",
)
print(batch["rows"], batch["cols"]) JavaScript/WASM Bindings
The WASM surface exposes scalar, batch, allocation, and into-buffer helpers. The high-level calls return plain JS objects containing the volatility and signal arrays, while the low-level APIs write those arrays into caller-managed memory.
import init, {
rogers_satchell_volatility_js,
rogers_satchell_volatility_batch_js,
rogers_satchell_volatility_alloc,
rogers_satchell_volatility_free,
rogers_satchell_volatility_into,
rogers_satchell_volatility_batch_into,
} from "vector-ta-wasm";
await init();
const out = rogers_satchell_volatility_js(open, high, low, close, 8, 8);
console.log(out.rs, out.signal);
const batch = rogers_satchell_volatility_batch_js(open, high, low, close, {
lookback_range: [8, 20, 4],
signal_length_range: [4, 8, 2],
});
console.log(batch.rows, batch.cols); 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)