Squeeze Index
conv = 50 | length = 20 Overview
Squeeze Index estimates how tight or loose price action has become. It keeps adaptive maximum and minimum states, measures the log spread between them, and then scores that spread over a rolling window to produce a normalized squeeze-style oscillator.
Lower values represent stronger compression while higher values represent expansion. The stream implementation mirrors the batch logic, exposes its warmup period directly, and resets itself when it receives an invalid value.
Defaults: `conv = 50` and `length = 20`.
Implementation Examples
Run Squeeze Index on candle closes or on any direct slice.
use vector_ta::indicators::squeeze_index::{squeeze_index, SqueezeIndexInput, SqueezeIndexParams};
let out = squeeze_index(&SqueezeIndexInput::from_slice(
&close,
SqueezeIndexParams { conv: Some(50.0), length: Some(20) },
))?;
println!("{:?}", out.values.last());API Reference
Input Methods▼
SqueezeIndexInput::from_candles(&Candles, "close", SqueezeIndexParams) -> SqueezeIndexInput
SqueezeIndexInput::from_slice(&[f64], SqueezeIndexParams) -> SqueezeIndexInput
SqueezeIndexInput::with_default_candles(&Candles) -> SqueezeIndexInputParameters Structure▼
pub struct SqueezeIndexParams {
pub conv: Option<f64>, // default 50.0
pub length: Option<usize>, // default 20
}Output Structure▼
pub struct SqueezeIndexOutput {
pub values: Vec<f64>,
}Validation, Warmup & NaNs▼
- The source slice must be non-empty and contain enough finite values to satisfy
length. convmust be finite and strictly greater than1.0.lengthmust be positive and no larger than the data length on the direct path.- The stream warmup is
length - 1. - Invalid streaming values reset the internal state and return
None. - Batch mode validates both range axes and rejects non-batch kernels.
Builder, Streaming & Batch APIs▼
SqueezeIndexBuilder::new()
.conv(f64)
.length(usize)
.kernel(Kernel)
.apply(&Candles, "close")
.apply_slice(&[f64])
.into_stream()
SqueezeIndexStream::try_new(params)
stream.get_warmup_period() -> usize
stream.update(f64) -> Option<f64>
SqueezeIndexBatchBuilder::new()
.kernel(Kernel)
.conv_range(start, end, step)
.conv_static(value)
.length_range(start, end, step)
.length_static(value)
.apply_slice(&[f64])
.apply_candles(&Candles, "close")
.with_default_candles(&Candles)Python Bindings
Python exposes one scalar function returning a NumPy array, one stream class returning one value or None, and one batch helper returning the matrix plus expanded convergence and length axes.
from vector_ta import squeeze_index, squeeze_index_batch, SqueezeIndexStream
values = squeeze_index(close, conv=50.0, length=20)
stream = SqueezeIndexStream()
point = stream.update(close[-1])
batch = squeeze_index_batch(
close,
conv_range=(30.0, 50.0, 10.0),
length_range=(15, 25, 5),
)JavaScript/WASM Bindings
The WASM layer exposes scalar and batch helpers plus allocation and into-buffer APIs for the flattened output matrix.
import init, {
squeeze_index_js,
squeeze_index_batch_js,
squeeze_index_alloc,
squeeze_index_free,
squeeze_index_into,
squeeze_index_batch_into,
} from "vector-ta-wasm";
await init();
const values = squeeze_index_js(close, 50.0, 20);
const batch = squeeze_index_batch_js(close, {
conv_range: [30.0, 50.0, 10.0],
length_range: [15, 25, 5],
});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)