feat: TA-Lib parity — 19 standalone indicators (DM components, price transforms, ROC/LinReg/MACD/SAR variants, Hilbert outputs) (#148)
Closes the remaining TA-Lib function-name gap by shipping each missing or bundled-only function as a real, standalone, fully-covered indicator. 19 new indicators across 5 families; mod-count 295 -> 314. ### Trend & Directional — Directional Movement components - `PlusDm` (`PLUS_DM`), `MinusDm` (`MINUS_DM`) — Wilder-smoothed ±DM. - `PlusDi` (`PLUS_DI`), `MinusDi` (`MINUS_DI`) — `100·smoothed(±DM)/ATR`. - `Dx` (`DX`) — `100·|+DI−−DI|/(+DI+−DI)`. ### Price Statistics - `AvgPrice` (`AVGPRICE`) — `(O+H+L+C)/4`. - `MidPoint` (`MIDPOINT`) — `(max+min)/2` of a scalar series over N. - `MidPrice` (`MIDPRICE`) — `(highestHigh+lowestLow)/2` over N. - `LinRegIntercept` (`LINEARREG_INTERCEPT`) — OLS intercept. - `Tsf` (`TSF`) — time series forecast `a + b·period`. ### Momentum Oscillators - `Rocp` (`ROCP`), `Rocr` (`ROCR`), `Rocr100` (`ROCR100`) — ROC ratio forms. ### Trailing Stops - `SarExt` (`SAREXT`) — Parabolic SAR with start value, reversal offset, separate long/short acceleration, signed output. ### Trend & Directional — MACD variants - `MacdFix` (`MACDFIX`) — MACD fixed 12/26. - `MacdExt` (`MACDEXT`) — MACD with a selectable moving-average type per line (new public `MaType` enum: SMA/EMA/WMA/DEMA/TEMA/TRIMA). ### Ehlers / Cycle (DSP) — Hilbert transform outputs - `HtPhasor` (`HT_PHASOR`) — in-phase / quadrature components. - `HtDcPhase` (`HT_DCPHASE`) — dominant-cycle phase (degrees). - `HtTrendMode` (`HT_TRENDMODE`) — trend (1) vs cycle (0) classification. Each indicator ships the full chain: core + every-branch unit tests, Python / Node / WASM bindings, fuzz coverage, README counter + family rows, CHANGELOG. `cargo test`, doctests, `clippy -D warnings`, `npm test` and pytest all green locally; mod-count == lib-block == README counter (314), FAMILIES total 309.
This commit is contained in:
@@ -15,21 +15,7 @@
|
||||
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
use wickra_core::{
|
||||
AdaptiveCycle, Alma, AnchoredRsi, Apo, Autocorrelation, AverageDrawdown, BatchExt, Beta,
|
||||
BollingerBands,
|
||||
CalmarRatio, CenterOfGravity, Cfo, Cmo, CoefficientOfVariation, ConditionalValueAtRisk,
|
||||
ConnorsRsi, Coppock, CyberneticCycle, Decycler, DecyclerOscillator, Dema, DetrendedStdDev,
|
||||
DoubleBollinger, Dpo, DrawdownDuration, EhlersStochastic, ElderImpulse, Ema,
|
||||
EmpiricalModeDecomposition, Fama, FisherTransform, Frama, GainLossRatio, HilbertDominantCycle,
|
||||
HistoricalVolatility, Hma, HurstExponent, Indicator, InstantaneousTrendline,
|
||||
InverseFisherTransform, Jma, Kama, KellyCriterion, Kst, Kurtosis, LaguerreRsi, LinRegAngle,
|
||||
LinRegChannel, LinRegSlope, LinearRegression, MaEnvelope, MacdIndicator, Mama, MaxDrawdown,
|
||||
McGinleyDynamic, MedianAbsoluteDeviation, Mom, OmegaRatio, PainIndex, PearsonCorrelation,
|
||||
PercentageTrailingStop, Pmo, Ppo, ProfitFactor, RSquared, RecoveryFactor, RenkoTrailingStop,
|
||||
Roc, RoofingFilter, Rsi, RviVolatility, SharpeRatio, SineWave, Skewness, Sma, Smma,
|
||||
SortinoRatio, SpearmanCorrelation, StandardError, StandardErrorBands, Stc, StdDev,
|
||||
StepTrailingStop, StochRsi, SuperSmoother, Tema, Tii, Trima, Trix, Tsi, UlcerIndex,
|
||||
ValueAtRisk, Variance, VerticalHorizontalFilter, Vidya, Wma, ZScore, ZeroLagMacd, Zlema, T3,
|
||||
AdaptiveCycle, Alma, AnchoredRsi, Apo, Autocorrelation, AverageDrawdown, BatchExt, Beta, BollingerBands, CalmarRatio, CenterOfGravity, Cfo, Cmo, CoefficientOfVariation, ConditionalValueAtRisk, ConnorsRsi, Coppock, CyberneticCycle, Decycler, DecyclerOscillator, Dema, DetrendedStdDev, DoubleBollinger, Dpo, DrawdownDuration, EhlersStochastic, ElderImpulse, Ema, EmpiricalModeDecomposition, Fama, FisherTransform, Frama, GainLossRatio, HilbertDominantCycle, HistoricalVolatility, Hma, HtDcPhase, HtPhasor, HtTrendMode, HurstExponent, Indicator, InstantaneousTrendline, InverseFisherTransform, Jma, Kama, KellyCriterion, Kst, Kurtosis, LaguerreRsi, LinRegAngle, LinRegChannel, LinRegIntercept, LinRegSlope, LinearRegression, MaEnvelope, MaType, MacdExt, MacdFix, MacdIndicator, Mama, MaxDrawdown, McGinleyDynamic, MedianAbsoluteDeviation, MidPoint, Mom, OmegaRatio, PainIndex, PearsonCorrelation, PercentageTrailingStop, Pmo, Ppo, ProfitFactor, RSquared, RecoveryFactor, RenkoTrailingStop, Roc, Rocp, Rocr, Rocr100, RoofingFilter, Rsi, RviVolatility, SharpeRatio, SineWave, Skewness, Sma, Smma, SortinoRatio, SpearmanCorrelation, StandardError, StandardErrorBands, Stc, StdDev, StepTrailingStop, StochRsi, SuperSmoother, Tema, Tii, Trima, Trix, Tsf, Tsi, UlcerIndex, ValueAtRisk, Variance, VerticalHorizontalFilter, Vidya, Wma, ZScore, ZeroLagMacd, Zlema, T3
|
||||
};
|
||||
|
||||
/// Drive a single streaming + batch run through one scalar indicator. Marked
|
||||
@@ -60,6 +46,9 @@ fuzz_target!(|data: Vec<f64>| {
|
||||
drive(|| Tema::new(14).unwrap(), &data);
|
||||
drive(|| Hma::new(14).unwrap(), &data);
|
||||
drive(|| Roc::new(14).unwrap(), &data);
|
||||
drive(|| Rocp::new(14).unwrap(), &data);
|
||||
drive(|| Rocr::new(14).unwrap(), &data);
|
||||
drive(|| Rocr100::new(14).unwrap(), &data);
|
||||
drive(|| Trix::new(14).unwrap(), &data);
|
||||
drive(|| Smma::new(14).unwrap(), &data);
|
||||
drive(|| Trima::new(14).unwrap(), &data);
|
||||
@@ -88,7 +77,10 @@ fuzz_target!(|data: Vec<f64>| {
|
||||
drive(|| UlcerIndex::new(14).unwrap(), &data);
|
||||
drive(|| HistoricalVolatility::new(14, 252).unwrap(), &data);
|
||||
drive(|| LinearRegression::new(14).unwrap(), &data);
|
||||
drive(|| MidPoint::new(14).unwrap(), &data);
|
||||
drive(|| LinRegSlope::new(14).unwrap(), &data);
|
||||
drive(|| LinRegIntercept::new(14).unwrap(), &data);
|
||||
drive(|| Tsf::new(14).unwrap(), &data);
|
||||
drive(|| LinRegAngle::new(14).unwrap(), &data);
|
||||
drive(|| VerticalHorizontalFilter::new(14).unwrap(), &data);
|
||||
drive(|| ZScore::new(14).unwrap(), &data);
|
||||
@@ -146,6 +138,8 @@ fuzz_target!(|data: Vec<f64>| {
|
||||
drive(|| EhlersStochastic::new(20).unwrap(), &data);
|
||||
drive(|| EmpiricalModeDecomposition::new(20, 0.5).unwrap(), &data);
|
||||
drive(HilbertDominantCycle::new, &data);
|
||||
drive(HtDcPhase::new, &data);
|
||||
drive(HtTrendMode::new, &data);
|
||||
drive(AdaptiveCycle::new, &data);
|
||||
drive(SineWave::new, &data);
|
||||
drive(|| Fama::new(0.5, 0.05).unwrap(), &data);
|
||||
@@ -191,6 +185,36 @@ fuzz_target!(|data: Vec<f64>| {
|
||||
}
|
||||
let _ = MacdIndicator::new(12, 26, 9).unwrap().batch(&data);
|
||||
}
|
||||
|
||||
// MACDFIX wraps MacdIndicator(12, 26, signal); same multi-output topology.
|
||||
{
|
||||
let mut fix = MacdFix::new(9).unwrap();
|
||||
for &x in &data {
|
||||
let _ = fix.update(x);
|
||||
}
|
||||
let _ = MacdFix::new(9).unwrap().batch(&data);
|
||||
}
|
||||
|
||||
// MACDEXT: selectable MA types per line, multi-output topology.
|
||||
{
|
||||
let mut ext = MacdExt::new(12, MaType::Ema, 26, MaType::Ema, 9, MaType::Sma).unwrap();
|
||||
for &x in &data {
|
||||
let _ = ext.update(x);
|
||||
}
|
||||
let _ = MacdExt::new(12, MaType::Ema, 26, MaType::Ema, 9, MaType::Sma)
|
||||
.unwrap()
|
||||
.batch(&data);
|
||||
}
|
||||
|
||||
// HT_PHASOR is scalar-input but emits a {inphase, quadrature} struct, so it
|
||||
// bypasses the generic `drive` helper.
|
||||
{
|
||||
let mut ph = HtPhasor::new();
|
||||
for &x in &data {
|
||||
let _ = ph.update(x);
|
||||
}
|
||||
let _ = HtPhasor::new().batch(&data);
|
||||
}
|
||||
{
|
||||
let mut bb = BollingerBands::new(20, 2.0).unwrap();
|
||||
for &x in &data {
|
||||
|
||||
Reference in New Issue
Block a user