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.
This commit is contained in:
@@ -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: ...
|
||||
|
||||
@@ -836,6 +836,7 @@ struct PyRoc {
|
||||
#[pymethods]
|
||||
impl PyRoc {
|
||||
#[new]
|
||||
#[pyo3(signature = (period=10))]
|
||||
fn new(period: usize) -> PyResult<Self> {
|
||||
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<Self> {
|
||||
Ok(Self {
|
||||
inner: wc::Trix::new(period).map_err(map_err)?,
|
||||
|
||||
Reference in New Issue
Block a user