OpenQuant Docs banner
OpenQuant icon openquant-rs / documentation terminal

filters

Event-Driven Data and Labeling

CUSUM and z-score event filters for event-driven sampling.

Why This Module Exists

Extracts informative events from noisy high-frequency sequences.

Key Public APIs

  • cusum_filter_indices
  • cusum_filter_timestamps
  • z_score_filter_indices
  • Threshold

Core Math

CUSUM

\[S_t=\max(0, S_{t-1}+r_t),\; trigger\;if\;|S_t|>h\]

Z-score

\[z_t=\frac{x_t-\mu_t}{\sigma_t}\]

Code Examples

Run CUSUM over closes

use openquant::filters::{cusum_filter_indices, Threshold};

let close = vec![100.0, 100.1, 99.9, 100.2];
let idx = cusum_filter_indices(&close, Threshold::Scalar(0.02));

Implementation Notes

  • Calibrate thresholds to target event frequency, not just sensitivity.
  • Use identical filtering in train and live pipelines.