23次发布
0.7.0 | 2024年3月7日 |
---|---|
0.6.2 | 2023年10月8日 |
0.6.1 | 2022年4月8日 |
0.6.0 | 2022年2月13日 |
0.2.1 | 2020年11月5日 |
#31 在 数学
5,367 每月下载量
450KB
10K SLoC
YATA
又一个技术分析库
它还提供了一个接口,让您创建自己的指标。
[dependencies]
yata = "0.6"
可用的 移动平均
- 简单移动平均(SMA);
- 加权移动平均(WMA);
- 指数移动平均系列:EMA、DMA、TMA、DEMA、TEMA;
- 简单移动中位数(SMM);
- 线性回归移动平均(LSMA);
- 成交量加权移动平均(VWMA);
- 对称加权移动平均(SWMA);
- 赫尔移动平均(HMA);
- 运行移动平均(RMA);
- 三角形移动平均(TRIMA);
- 怀特利平滑平均(WSMA);
- 考夫曼自适应移动平均(KAMA);
- 卷积移动平均;
- 可变指数动态平均(Vidya);
时间序列转换
一些常用的 方法
- 累积分布指数;
- 商品通道指数;
- 交叉 / 交叉以上 / 交叉以下;
- 导数(微分);
- 最高 / 最低 / 最高-最低差;
- 最高索引 / 最低索引;
- 积分(总和);
- 平均绝对偏差;
- 中位数绝对偏差;
- 动量;
- 过去;
- 变化率(ROC);
- 反转点;
- 标准差;
- 真实范围;
- 真实强度指数;
- 波动性;
一些常用指标
- 平均方向性指数;
- 神奇振荡器;
- 布林带;
- 商品通道指数;
- 去趋势价格振荡器;
- 移动性;
- 埃尔德斯力量指数;
- 价格通道;
- 费希尔转换;
- Ichimoku云图;
- Keltner通道;
- 移动平均收敛发散(MACD);
- 资金流量指数;
- 价格通道策略;
- 相对强弱指数(RSI);
- 随机振荡器;
- Trix;
- Woodies CCI;
还有很多其他指标。查看所有
方法使用示例
use yata::prelude::*;
use yata::methods::EMA;
// EMA of length=3
let mut ema = EMA::new(3, &3.0).unwrap();
ema.next(&3.0);
ema.next(&6.0);
assert_eq!(ema.next(&9.0), 6.75);
assert_eq!(ema.next(&12.0), 9.375);
指标使用示例
use yata::helpers::{RandomCandles, MA};
use yata::indicators::MACD;
use yata::prelude::*;
let mut candles = RandomCandles::new();
let mut macd = MACD::default();
macd.method1 = "sma-4".parse().unwrap(); // one way of defining methods inside indicators
macd.signal = MA::TEMA(5); // another way of defining methods inside indicators
let mut macd = macd.init(&candles.first()).unwrap();
for candle in candles.take(10) {
let result = macd.next(&candle);
println!("{:?}", result);
}
基准
方法
- _w10 - 窗口长度为
length
=10 的方法 - _w100 - 窗口长度为
length
=100 的方法
test bench_adi_w10 ... bench: 7 ns/iter (+/- 0)
test bench_adi_w100 ... bench: 7 ns/iter (+/- 0)
test bench_cci_w10 ... bench: 16 ns/iter (+/- 0)
test bench_cci_w100 ... bench: 133 ns/iter (+/- 8)
test bench_conv_w10 ... bench: 23 ns/iter (+/- 2)
test bench_conv_w100 ... bench: 197 ns/iter (+/- 0)
test bench_cross ... bench: 5 ns/iter (+/- 0)
test bench_cross_above ... bench: 3 ns/iter (+/- 0)
test bench_cross_under ... bench: 3 ns/iter (+/- 0)
test bench_dema_w10 ... bench: 7 ns/iter (+/- 0)
test bench_dema_w100 ... bench: 6 ns/iter (+/- 0)
test bench_derivative_w10 ... bench: 4 ns/iter (+/- 0)
test bench_derivative_w100 ... bench: 3 ns/iter (+/- 0)
test bench_dma_w10 ... bench: 5 ns/iter (+/- 0)
test bench_dma_w100 ... bench: 5 ns/iter (+/- 0)
test bench_ema_w10 ... bench: 5 ns/iter (+/- 0)
test bench_ema_w100 ... bench: 5 ns/iter (+/- 0)
test bench_heikin_ashi ... bench: 4 ns/iter (+/- 0)
test bench_highest_index_w10 ... bench: 6 ns/iter (+/- 0)
test bench_highest_index_w100 ... bench: 6 ns/iter (+/- 0)
test bench_highest_lowest_delta_w10 ... bench: 10 ns/iter (+/- 0)
test bench_highest_lowest_delta_w100 ... bench: 10 ns/iter (+/- 0)
test bench_highest_w10 ... bench: 6 ns/iter (+/- 0)
test bench_highest_w100 ... bench: 7 ns/iter (+/- 0)
test bench_hma_w10 ... bench: 14 ns/iter (+/- 0)
test bench_hma_w100 ... bench: 15 ns/iter (+/- 0)
test bench_integral_w10 ... bench: 7 ns/iter (+/- 0)
test bench_integral_w100 ... bench: 7 ns/iter (+/- 0)
test bench_lin_reg_w10 ... bench: 8 ns/iter (+/- 1)
test bench_lin_reg_w100 ... bench: 8 ns/iter (+/- 0)
test bench_linear_volatility_w10 ... bench: 4 ns/iter (+/- 0)
test bench_linear_volatility_w100 ... bench: 4 ns/iter (+/- 0)
test bench_lowest_index_w10 ... bench: 6 ns/iter (+/- 0)
test bench_lowest_index_w100 ... bench: 7 ns/iter (+/- 0)
test bench_lowest_w10 ... bench: 6 ns/iter (+/- 0)
test bench_lowest_w100 ... bench: 6 ns/iter (+/- 0)
test bench_mean_abs_dev_w10 ... bench: 11 ns/iter (+/- 0)
test bench_mean_abs_dev_w100 ... bench: 123 ns/iter (+/- 4)
test bench_median_abs_dev_w10 ... bench: 31 ns/iter (+/- 7)
test bench_median_abs_dev_w100 ... bench: 190 ns/iter (+/- 8)
test bench_momentum_w10 ... bench: 3 ns/iter (+/- 0)
test bench_momentum_w100 ... bench: 3 ns/iter (+/- 0)
test bench_past_w10 ... bench: 3 ns/iter (+/- 0)
test bench_past_w100 ... bench: 3 ns/iter (+/- 0)
test bench_rate_of_change_w10 ... bench: 3 ns/iter (+/- 0)
test bench_rate_of_change_w100 ... bench: 3 ns/iter (+/- 0)
test bench_reverse_high_w10 ... bench: 5 ns/iter (+/- 0)
test bench_reverse_high_w100 ... bench: 5 ns/iter (+/- 0)
test bench_reverse_low_w10 ... bench: 5 ns/iter (+/- 0)
test bench_reverse_low_w100 ... bench: 5 ns/iter (+/- 0)
test bench_reverse_signal_w10 ... bench: 9 ns/iter (+/- 0)
test bench_reverse_signal_w100 ... bench: 9 ns/iter (+/- 0)
test bench_rma_w10 ... bench: 4 ns/iter (+/- 0)
test bench_rma_w100 ... bench: 4 ns/iter (+/- 0)
test bench_sma_w10 ... bench: 3 ns/iter (+/- 0)
test bench_sma_w100 ... bench: 3 ns/iter (+/- 0)
test bench_smm_w10 ... bench: 17 ns/iter (+/- 1)
test bench_smm_w100 ... bench: 35 ns/iter (+/- 2)
test bench_st_dev_w10 ... bench: 7 ns/iter (+/- 0)
test bench_st_dev_w100 ... bench: 7 ns/iter (+/- 0)
test bench_swma_w10 ... bench: 8 ns/iter (+/- 0)
test bench_swma_w100 ... bench: 8 ns/iter (+/- 0)
test bench_tema_w10 ... bench: 8 ns/iter (+/- 0)
test bench_tema_w100 ... bench: 7 ns/iter (+/- 0)
test bench_tma_w10 ... bench: 5 ns/iter (+/- 0)
test bench_tma_w100 ... bench: 5 ns/iter (+/- 1)
test bench_trima_w10 ... bench: 5 ns/iter (+/- 0)
test bench_trima_w100 ... bench: 5 ns/iter (+/- 1)
test bench_tsi_w10 ... bench: 9 ns/iter (+/- 0)
test bench_tsi_w100 ... bench: 10 ns/iter (+/- 0)
test bench_vidya_w10 ... bench: 8 ns/iter (+/- 1)
test bench_vidya_w100 ... bench: 8 ns/iter (+/- 0)
test bench_vwma_w10 ... bench: 5 ns/iter (+/- 0)
test bench_vwma_w100 ... bench: 5 ns/iter (+/- 0)
test bench_wma_w10 ... bench: 6 ns/iter (+/- 1)
test bench_wma_w100 ... bench: 6 ns/iter (+/- 0)
指标
test bench_awesome_oscillator ... bench: 36 ns/iter (+/- 0)
test bench_bollinger_bands ... bench: 53 ns/iter (+/- 2)
test bench_chaikin_money_flow ... bench: 22 ns/iter (+/- 0)
test bench_chaikin_oscillator ... bench: 23 ns/iter (+/- 0)
test bench_chande_kroll_stop ... bench: 58 ns/iter (+/- 0)
test bench_chande_momentum_oscillator ... bench: 25 ns/iter (+/- 0)
test bench_commodity_channel_index ... bench: 38 ns/iter (+/- 0)
test bench_coppock_curve ... bench: 38 ns/iter (+/- 2)
test bench_detrended_price_oscillator ... bench: 10 ns/iter (+/- 0)
test bench_ease_of_movement ... bench: 20 ns/iter (+/- 0)
test bench_elders_force_index ... bench: 17 ns/iter (+/- 1)
test bench_envelopes ... bench: 14 ns/iter (+/- 0)
test bench_fisher_transform ... bench: 125 ns/iter (+/- 13)
test bench_hull_moving_average ... bench: 28 ns/iter (+/- 0)
test bench_ichimoku_cloud ... bench: 65 ns/iter (+/- 7)
test bench_indicator_aroon ... bench: 46 ns/iter (+/- 12)
test bench_indicator_average_directional_index ... bench: 49 ns/iter (+/- 1)
test bench_kaufman ... bench: 34 ns/iter (+/- 3)
test bench_keltner_channel ... bench: 26 ns/iter (+/- 2)
test bench_klinger_volume_oscillator ... bench: 40 ns/iter (+/- 1)
test bench_know_sure_thing ... bench: 41 ns/iter (+/- 0)
test bench_macd ... bench: 23 ns/iter (+/- 0)
test bench_momentum_index ... bench: 13 ns/iter (+/- 0)
test bench_money_flow_index ... bench: 59 ns/iter (+/- 12)
test bench_parabolic_sar ... bench: 17 ns/iter (+/- 2)
test bench_pivot_reversal_strategy ... bench: 30 ns/iter (+/- 4)
test bench_relative_strength_index ... bench: 35 ns/iter (+/- 1)
test bench_relative_vigor_index ... bench: 59 ns/iter (+/- 0)
test bench_smi_ergodic_indicator ... bench: 30 ns/iter (+/- 2)
test bench_stochastic_oscillator ... bench: 48 ns/iter (+/- 4)
test bench_trend_strength_index ... bench: 46 ns/iter (+/- 2)
test bench_trix ... bench: 32 ns/iter (+/- 10)
test bench_true_strength_index ... bench: 38 ns/iter (+/- 16)
test bench_woodies_cci ... bench: 68 ns/iter (+/- 6)
当前不安全状态
默认情况下,该包中没有 unsafe
代码。但您可以通过修改您的 Cargo.toml
或在您的命令行界面中使用 --feature
标志来选择性地启用 unsafe_performance
功能。
unsafe_performance
启用了一些不安全代码块,其中大多数是对向量元素的不安全访问。对于某些方法,它可能通过 ~5-10% 提高性能。
功能
serde
- 启用serde
包支持;period_type_u16
- 将PeriodType
设置为u16
;period_type_u32
- 将PeriodType
设置为u32
;period_type_u64
- 将PeriodType
设置为u64
;value_type_f32
- 将ValueType
设置为f32
;unsafe_performance
- 启用可选的不安全代码块,可能提高性能;
Rust 版本
YaTa 库支持 Rust 稳定版,但您无法使用它运行基准测试。
建议
感谢
如果您喜欢这个库,并且想要表示感谢,您也可以通过捐赠到比特币地址 1P3gTnaTK9LKSYx2nETrKe2zjP4HMkdhvK
来实现。
依赖
~0.4–1MB
~23K SLoC