From 4a9d27fb520bea7d5c64bec20166d2696477c0f3 Mon Sep 17 00:00:00 2001 From: kingchenc Date: Fri, 22 May 2026 04:06:18 +0200 Subject: [PATCH] B7: give Python ROC and TRIX constructor defaults Every other Python momentum indicator (RSI, CCI, ...) carries a #[pyo3(signature)] default, but ROC and TRIX required an explicit period. Both now default to the TA-Lib convention (ROC period=10, TRIX period=30), and the .pyi stubs reflect the defaults. Node and WASM constructors deliberately stay explicit-only -- napi-rs and wasm-bindgen do not support default arguments, and every constructor in those bindings is uniformly explicit. --- bindings/python/python/wickra/__init__.pyi | 4 ++-- bindings/python/src/lib.rs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bindings/python/python/wickra/__init__.pyi b/bindings/python/python/wickra/__init__.pyi index 236b480f..87d8611a 100644 --- a/bindings/python/python/wickra/__init__.pyi +++ b/bindings/python/python/wickra/__init__.pyi @@ -190,7 +190,7 @@ class CCI: def period(self) -> int: ... class ROC: - def __init__(self, period: int) -> None: ... + def __init__(self, period: int = 10) -> None: ... def update(self, value: float) -> Optional[float]: ... def batch(self, prices: NDArray[np.float64]) -> NDArray[np.float64]: ... def reset(self) -> None: ... @@ -242,7 +242,7 @@ class MFI: def warmup_period(self) -> int: ... class TRIX: - def __init__(self, period: int) -> None: ... + def __init__(self, period: int = 30) -> None: ... def update(self, value: float) -> Optional[float]: ... def batch(self, prices: NDArray[np.float64]) -> NDArray[np.float64]: ... def reset(self) -> None: ... diff --git a/bindings/python/src/lib.rs b/bindings/python/src/lib.rs index 8bf108f4..4c306bd6 100644 --- a/bindings/python/src/lib.rs +++ b/bindings/python/src/lib.rs @@ -836,6 +836,7 @@ struct PyRoc { #[pymethods] impl PyRoc { #[new] + #[pyo3(signature = (period=10))] fn new(period: usize) -> PyResult { Ok(Self { inner: wc::Roc::new(period).map_err(map_err)?, @@ -1054,6 +1055,7 @@ struct PyTrix { #[pymethods] impl PyTrix { #[new] + #[pyo3(signature = (period=30))] fn new(period: usize) -> PyResult { Ok(Self { inner: wc::Trix::new(period).map_err(map_err)?,