From 50a9d45d5709f5fac1f9147be190e9317d215774 Mon Sep 17 00:00:00 2001 From: seankoval Date: Sun, 30 Aug 2026 17:19:59 -0700 Subject: [PATCH] fix: correct the get_parkinson_vol spelling in the public API The Rust fn and the Python binding both spelled Parkinson as 'parksinson'. The pyfunction name IS the public Python API, so this is a deliberate breaking rename, made on the owner's instruction. Renamed: openquant::util::volatility::get_parksinson_vol -> get_parkinson_vol, the pyopenquant wrapper, its #[pyfunction(name = ...)], its module registration, and the volatility_features test. The doc comment still names mlfinlab's 'get_parksinson_vol' because that misspelling is upstream's and is where ours came from; the comment now says so rather than propagating it silently. --- crates/openquant/src/util/volatility.rs | 5 +++-- crates/openquant/tests/volatility_features.rs | 4 ++-- crates/pyopenquant/src/volatility.rs | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/openquant/src/util/volatility.rs b/crates/openquant/src/util/volatility.rs index 67dd737..af9c235 100644 --- a/crates/openquant/src/util/volatility.rs +++ b/crates/openquant/src/util/volatility.rs @@ -48,8 +48,9 @@ pub fn get_daily_vol(close: &[(NaiveDateTime, f64)], lookback: usize) -> Vec<(Na } /// Parkinson volatility estimator. -/// Mirrors mlfinlab.util.volatility.get_parksinson_vol. -pub fn get_parksinson_vol(high: &[f64], low: &[f64], window: usize) -> Vec { +/// Mirrors mlfinlab's `get_parksinson_vol` — note that upstream misspells +/// "Parkinson"; this crate spells it correctly. +pub fn get_parkinson_vol(high: &[f64], low: &[f64], window: usize) -> Vec { assert_eq!(high.len(), low.len(), "high/low length mismatch"); let estimator: Vec = high .iter() diff --git a/crates/openquant/tests/volatility_features.rs b/crates/openquant/tests/volatility_features.rs index 1825f41..834e9ea 100644 --- a/crates/openquant/tests/volatility_features.rs +++ b/crates/openquant/tests/volatility_features.rs @@ -1,5 +1,5 @@ use csv::ReaderBuilder; -use openquant::util::volatility::{get_garman_class_vol, get_parksinson_vol, get_yang_zhang_vol}; +use openquant::util::volatility::{get_garman_class_vol, get_parkinson_vol, get_yang_zhang_vol}; use serde::Deserialize; #[derive(Debug, Deserialize)] @@ -47,7 +47,7 @@ fn test_volatility_estimators_match_mlfinlab_baseline() { let (open, high, low, close) = load_ohlc(); let gm_vol = get_garman_class_vol(&open, &high, &low, &close, 20); let yz_vol = get_yang_zhang_vol(&open, &high, &low, &close, 20); - let park_vol = get_parksinson_vol(&high, &low, 20); + let park_vol = get_parkinson_vol(&high, &low, 20); assert_eq!(close.len(), gm_vol.len()); assert_eq!(close.len(), yz_vol.len()); diff --git a/crates/pyopenquant/src/volatility.rs b/crates/pyopenquant/src/volatility.rs index 09c8231..b2a0933 100644 --- a/crates/pyopenquant/src/volatility.rs +++ b/crates/pyopenquant/src/volatility.rs @@ -14,9 +14,9 @@ fn volatility_get_daily_vol( Ok(result.into_iter().map(|(ts, v)| (ts.format("%Y-%m-%d %H:%M:%S").to_string(), v)).collect()) } -#[pyfunction(name = "get_parksinson_vol")] -fn volatility_get_parksinson_vol(high: Vec, low: Vec, window: usize) -> Vec { - openquant::util::volatility::get_parksinson_vol(&high, &low, window) +#[pyfunction(name = "get_parkinson_vol")] +fn volatility_get_parkinson_vol(high: Vec, low: Vec, window: usize) -> Vec { + openquant::util::volatility::get_parkinson_vol(&high, &low, window) } #[pyfunction(name = "get_garman_class_vol")] @@ -44,7 +44,7 @@ fn volatility_get_yang_zhang_vol( pub fn register(py: Python<'_>, parent: &Bound<'_, PyModule>) -> PyResult<()> { let m = PyModule::new(py, "volatility")?; m.add_function(wrap_pyfunction!(volatility_get_daily_vol, &m)?)?; - m.add_function(wrap_pyfunction!(volatility_get_parksinson_vol, &m)?)?; + m.add_function(wrap_pyfunction!(volatility_get_parkinson_vol, &m)?)?; m.add_function(wrap_pyfunction!(volatility_get_garman_class_vol, &m)?)?; m.add_function(wrap_pyfunction!(volatility_get_yang_zhang_vol, &m)?)?; parent.add_submodule(&m)?;