Skip to main content

Crate adaq_talib

Crate adaq_talib 

Source
Expand description

§adaq-talib

纯 Rust、Zero-FFI、零依赖的 TA-Lib 0.7.1 技术指标复刻库。

Pure-Rust, zero-FFI, dependency-free reimplementation of the TA-Lib 0.7.1 technical-analysis indicators.

§设计目标 / Design goals

  • 零偏差 (zero-deviation):每个函数的数值输出与原版 TA-Lib 0.7.1 逐项一致 (在浮点误差容限内,见 [crate::utils] 与 ADR 0005)。
  • Zero-FFI / No-Dependencies:发布的库不调用任何 C ABI,[dependencies] 为空, 全部算法原生手写。
  • 惯用 Rust API (模型 B):切片入参、Result<_, TaError> 出参、多输出用结构体返回 (见 ADR 0001)。前导不稳定期以 f64::NAN 填充、等长返回(见 ADR 0007)。
  • 性能优先:在内存布局、循环分支、数组运算层面做优化。

§覆盖范围 / Coverage

采用里程碑式发布(见 ADR 0002):0.1.0 覆盖重叠研究、动量、波动率、成交量、价格变换 与统计类;数学变换(Math Transform)、数学运算符(Math Operators)与剩余周期/模式识别 指标在后续里程碑补齐,最终全量且不删减任何原版能力(见 docs/0.1.0-scope.md 与 docs/NEXT-ACTIONS-perf.md 的 P4 进度)。

§快速开始 / Quick start

use adaq_talib::overlap::sma;

let prices = [1.0, 2.0, 3.0, 4.0, 5.0];
let out = sma(&prices, 3).unwrap();
// out 与 prices 等长;前导 2 个位置为 NaN,其余为窗口均值。
// `out` has the same length as `prices`; the first 2 positions are NaN, the rest are window means.
assert!(out[0].is_nan());
assert!((out[2] - 2.0).abs() < 1e-9);

§验证与基准 / Verification & benchmarks

  • 正确性:与入库黄金向量(由 TA-Lib 原版生成,tools/gen_fixtures)比对,普通 cargo test 无需 Python(见 ADR 0003)。
  • 性能:双轨基准 —— benches/ 可选 bench-c feature FFI 对照原生 C, tools/bench 提供 Python 便捷对照(如实标注为 TA-Lib Python 绑定层,见 ADR 0004)。

Re-exports§

pub use error::TaError;

Modules§

cycle
周期类指标(希尔伯特变换,Hilbert Transform / Cycle)。
error
错误类型定义 / Error type definitions.
math_ops
数学运算符函数(Math Operators)。
math_trans
数学变换函数(Math Transform)。
momentum
动量指标(Momentum Indicators)。
overlap
重叠研究类指标(Overlap Studies)。
pattern
形态识别(Pattern Recognition)
price_transform
价格变换(Price Transform)。
stat
统计函数(Statistic Functions)。
volatility
波动率指标(Volatility Indicators)。
volume
成交量指标(Volume Indicators)。