7a18a26daf
Implements Family 10 (Ehlers / Cycle) end-to-end across Rust core,
Python / Node / WASM bindings, fuzz, tests, benches and docs. This
is an entirely new family covering John Ehlers' digital-signal-
processing school of cycle analytics — a strong differentiator
versus TA-Lib and pandas-ta, which ship only fragments.
Indicators:
- MAMA (Mesa Adaptive MA) — multi-output { mama, fama }
- FAMA (Following Adaptive MA) — scalar wrapper around MAMA's slow line
- Fisher Transform — Gaussian-normalising price transform
- Inverse Fisher Transform — bounded oscillator (tanh-based)
- SuperSmoother — 2-pole Butterworth lowpass
- Roofing Filter — high-pass + SuperSmoother bandpass
- Decycler — price minus 2-pole high-pass (lag-free trend)
- Decycler Oscillator — fast / slow Decycler difference (MACD-like)
- Hilbert Dominant Cycle — phase-derived period estimator [6, 50]
- Sine Wave Indicator — sin(phase) with 45° lead companion
- Adaptive Cycle Indicator — half-period driver for adaptive oscillators
- Center of Gravity Oscillator — weighted-mass momentum
- Cybernetic Cycle Component — EasyLanguage classic
- Empirical Mode Decomposition — bandpass + envelope mean
- Ehlers Stochastic — Stochastic on Roofing Filter input, [-1, +1]
- Instantaneous Trendline — Ehlers 2-pole lag-free trend
Indicator count rises 71 -> 87 across nine families (was eight).
All sixteen pass batch == streaming equivalence, expose the standard
Indicator surface (update / batch / reset / is_ready / warmup_period
/ name), are fuzz-tested, benchmarked against the checked-in BTCUSDT
1-minute dataset and reach across all four bindings.
Wiki deep-dive drafts for every indicator + Sidebar / Overview /
Home / Warmup updates are staged under indicator-ideas/families/
wiki/family-10-ehlers-cycle/ in the main repo (ghost-ignored) for
the maintainer to publish to the wiki repo manually.
59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
"""Input-validation tests: malformed NumPy inputs raise ValueError, not panics."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
import wickra as ta
|
|
|
|
|
|
def test_non_contiguous_array_raises_value_error():
|
|
# A strided view is not C-contiguous; batch() must reject it cleanly.
|
|
base = np.linspace(1.0, 100.0, 60)
|
|
non_contiguous = base[::2]
|
|
assert not non_contiguous.flags["C_CONTIGUOUS"]
|
|
with pytest.raises(ValueError):
|
|
ta.SMA(5).batch(non_contiguous)
|
|
|
|
|
|
def test_ascontiguousarray_recovers():
|
|
base = np.linspace(1.0, 100.0, 60)
|
|
fixed = np.ascontiguousarray(base[::2])
|
|
out = ta.SMA(5).batch(fixed)
|
|
assert out.shape == fixed.shape
|
|
|
|
|
|
def test_unequal_length_candle_batch_raises(ohlc_series):
|
|
high, low, close = ohlc_series
|
|
short = low[:-1]
|
|
with pytest.raises(ValueError):
|
|
ta.ATR(14).batch(high, short, close)
|
|
with pytest.raises(ValueError):
|
|
ta.WilliamsR(14).batch(high, short, close)
|
|
with pytest.raises(ValueError):
|
|
ta.Aroon(14).batch(high, short)
|
|
|
|
|
|
def test_roc_and_trix_have_default_periods():
|
|
# ROC/TRIX gained constructor defaults matching the TA-Lib convention.
|
|
assert ta.ROC().period == 10
|
|
assert ta.TRIX() is not None
|
|
|
|
|
|
def test_family_10_ehlers_rejects_invalid_parameters():
|
|
with pytest.raises(ValueError):
|
|
ta.SuperSmoother(0)
|
|
with pytest.raises(ValueError):
|
|
ta.FisherTransform(0)
|
|
with pytest.raises(ValueError):
|
|
ta.InverseFisherTransform(0.0)
|
|
with pytest.raises(ValueError):
|
|
ta.DecyclerOscillator(30, 10)
|
|
with pytest.raises(ValueError):
|
|
ta.RoofingFilter(48, 10)
|
|
with pytest.raises(ValueError):
|
|
ta.MAMA(0.05, 0.5)
|
|
with pytest.raises(ValueError):
|
|
ta.EmpiricalModeDecomposition(20, 0.0)
|