又一个技术分析库 [用于 Rust]
YaTa implements most common technical analysis methods and indicators.
It also provides you an interface to create your own indicators.
[dependencies]
yata = "0.6"And many others. See all
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);
}length=10length=100……By default, there is no unsafe code in the crate. But you can optionally enable unsafe_performance feature throw you Cargo.toml or by --feature flag in your CLI.
unsafe_performance enables some unsafe code blocks, most of them are unsafe access to a vector's elements. For some methods it may increase performance by ~5-10%.
serde - enables serde crate support;period_type_u16 - sets PeriodType to u16;period_type_u32 - sets PeriodType to u32;period_type_u64 - sets PeriodType to u64;value_type_f32 - sets ValueType to f32;unsafe_performance - enables optional unsafe code blocks, which may increase performance;YaTa library supports Rust stable except that you can't run benchmarks with it.
You are welcome to give any suggestions about implementing new indicators and methods.
If you like this library, and you want to say thanks, you can do it also by donating to bitcoin address 1P3gTnaTK9LKSYx2nETrKe2zjP4HMkdhvK
暂无开放 Issues,或尚未同步最近议题。