greyblake / ta-rs

Technical analysis library for Rust language
MIT License
691 stars 129 forks source link
finance finances financial financial-analysis indicator indicators library market-data math moving-average rust rust-lang rust-library stock-market stocks technical-analysis trading trading-algorithms trading-strategies trading-systems

Technical Analysis for Rust (ta)

Build Status Crates.io Docs.rs License

Stand With Ukraine

Technical analysis library for Rust.

Getting started

Add to you Cargo.toml:

[dependencies]
ta = "0.4.0"

Example:

use ta::indicators::ExponentialMovingAverage;
use ta::Next;

// it can return an error, when an invalid length is passed (e.g. 0)
let mut ema = ExponentialMovingAverage::new(3).unwrap();

assert_eq!(ema.next(2.0), 2.0);
assert_eq!(ema.next(5.0), 3.5);
assert_eq!(ema.next(1.0), 2.25);
assert_eq!(ema.next(6.25), 4.25);

See more in the examples here. Check also the documentation.

Basic ideas

A data item which represent a stock quote may implement the following traits:

It's not necessary to implement all of them, but it must be enough to fulfill requirements for a particular indicator. You probably should prefer using DataItem unless you have reasons to implement your own structure.

Indicators typically implement the following traits:

List of indicators

So far there are the following indicators available.

Features

Running benchmarks

cargo bench

Donations

You can support the project by donating NEAR tokens.

Our NEAR wallet address is ta-rs.near

License

MIT © Sergey Potapov

Contributors