Rolling Skewness Kurtosis
length = 50 | smooth_length = 3 Overview
Rolling Skewness Kurtosis tracks two higher-order distribution statistics over a moving window. Skewness shows whether recent values lean toward upside or downside asymmetry, while excess kurtosis shows whether the same window is more heavy-tailed or more flat than a normal distribution.
VectorTA computes the raw statistics over each fully populated window, then optionally smooths both series with a short simple moving average. The result is useful when you want to track changing distribution shape rather than just mean and standard deviation.
Defaults: `length = 50` and `smooth_length = 3`.
Implementation Examples
Run the indicator on candle closes or a direct numeric slice and inspect the two rolling statistics.
use vector_ta::indicators::rolling_skewness_kurtosis::{
rolling_skewness_kurtosis,
RollingSkewnessKurtosisInput,
RollingSkewnessKurtosisParams,
};
use vector_ta::utilities::data_loader::{Candles, read_candles_from_csv};
let output = rolling_skewness_kurtosis(&RollingSkewnessKurtosisInput::from_slice(
&close,
RollingSkewnessKurtosisParams {
length: Some(50),
smooth_length: Some(3),
},
))?;
let candles: Candles = read_candles_from_csv("data/sample.csv")?;
let candle_output =
rolling_skewness_kurtosis(&RollingSkewnessKurtosisInput::with_default_candles(&candles))?;
println!("skewness = {:?}", output.skewness.last());
println!("kurtosis = {:?}", candle_output.kurtosis.last()); API Reference
Input Methods ▼
RollingSkewnessKurtosisInput::from_candles(&Candles, &str, RollingSkewnessKurtosisParams)
-> RollingSkewnessKurtosisInput
RollingSkewnessKurtosisInput::from_slice(&[f64], RollingSkewnessKurtosisParams)
-> RollingSkewnessKurtosisInput
RollingSkewnessKurtosisInput::with_default_candles(&Candles)
-> RollingSkewnessKurtosisInput Parameters Structure ▼
pub struct RollingSkewnessKurtosisParams {
pub length: Option<usize>,
pub smooth_length: Option<usize>,
} Output Structure ▼
pub struct RollingSkewnessKurtosisOutput {
pub skewness: Vec<f64>,
pub kurtosis: Vec<f64>,
} Validation, Warmup & NaNs ▼
- The input series must be non-empty and must contain a sufficiently long run of finite values.
lengthmust be greater than zero and cannot exceed the available data length.smooth_lengthmust be greater than zero.- The raw statistics appear after the rolling window fills, and the published outputs appear after the smoothing window fills on top of that.
- Streaming resets cleanly when it encounters a non-finite input value.
- Batch mode validates all sweep axes and rejects unsupported kernels through
InvalidKernelForBatch.
Builder, Streaming & Batch APIs ▼
RollingSkewnessKurtosisBuilder::new()
.length(usize)
.smooth_length(usize)
.kernel(Kernel)
.apply(&Candles)
.apply_candles(&Candles, &str)
.apply_slice(&[f64])
.into_stream()
RollingSkewnessKurtosisStream::try_new(params)
stream.update(f64) -> Option<(f64, f64)>
stream.reset()
stream.get_warmup_period() -> usize
RollingSkewnessKurtosisBatchBuilder::new()
.length_range((usize, usize, usize))
.smooth_length_range((usize, usize, usize))
.kernel(Kernel)
.apply_slice(&[f64])
.apply_candles(&Candles, &str) Error Handling ▼
pub enum RollingSkewnessKurtosisError {
EmptyInputData,
AllValuesNaN,
InvalidLength { length: usize, data_len: usize },
InvalidSmoothLength { smooth_length: usize },
NotEnoughValidData { needed: usize, valid: usize },
OutputLengthMismatch { expected: usize, got: usize },
InvalidRange { start: usize, end: usize, step: usize },
InvalidKernelForBatch(Kernel),
MismatchedOutputLen { dst_len: usize, expected_len: usize },
InvalidInput { msg: String },
} Python Bindings
Python exposes a scalar function, a streaming class, and a batch helper. The scalar call returns skewness and
kurtosis arrays, the stream emits a two-value tuple or None, and the batch helper returns reshaped
matrices together with the tested window lengths.
from vector_ta import (
rolling_skewness_kurtosis,
rolling_skewness_kurtosis_batch,
RollingSkewnessKurtosisStream,
)
skewness, kurtosis = rolling_skewness_kurtosis(
close,
length=50,
smooth_length=3,
kernel="auto",
)
stream = RollingSkewnessKurtosisStream(length=50, smooth_length=3)
print(stream.update(close[-1]))
batch = rolling_skewness_kurtosis_batch(
close,
length_range=(30, 60, 15),
smooth_length_range=(2, 4, 1),
kernel="auto",
)
print(batch["rows"], batch["cols"]) JavaScript/WASM Bindings
The WASM layer exposes scalar, batch, allocation, and into-buffer helpers. The high-level calls return plain JS objects containing the skewness and kurtosis arrays, while the low-level APIs write those arrays into caller-managed memory.
import init, {
rolling_skewness_kurtosis_js,
rolling_skewness_kurtosis_batch_js,
rolling_skewness_kurtosis_alloc,
rolling_skewness_kurtosis_free,
rolling_skewness_kurtosis_into,
rolling_skewness_kurtosis_batch_into,
} from "vector-ta-wasm";
await init();
const out = rolling_skewness_kurtosis_js(close, 50, 3);
console.log(out.skewness, out.kurtosis);
const batch = rolling_skewness_kurtosis_batch_js(close, {
length_range: [30, 60, 15],
smooth_length_range: [2, 4, 1],
});
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)