#technical-analysis #financial #ema #trading #indicators

ta

Technical analysis library. Implements number of indicators: EMA, SMA, RSI, MACD, Stochastic, etc.

8 releases

✓ Uses Rust 2018 edition

0.1.5 Dec 16, 2019
0.1.4 Apr 9, 2019
0.1.3 Mar 28, 2019
0.1.1 Feb 27, 2019
0.0.1-alpha Sep 29, 2017

#29 in Science

Download history 296/week @ 2019-12-14 4/week @ 2019-12-21 17/week @ 2019-12-28 24/week @ 2020-01-04 49/week @ 2020-01-11 75/week @ 2020-01-18 13/week @ 2020-01-25 8/week @ 2020-02-01 17/week @ 2020-02-08 28/week @ 2020-02-15 34/week @ 2020-02-22 21/week @ 2020-02-29 20/week @ 2020-03-07 18/week @ 2020-03-14 36/week @ 2020-03-21 12/week @ 2020-03-28

173 downloads per month
Used in rust-binance

MIT license

90KB
2K SLoC

Technical Analysis for Rust (ta)

Build Status License Documentation

Technical analysis library for Rust.

Getting started

Add to you Cargo.toml:

[dependencies]

ta = "0.1.5"

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:

  • Open
  • High
  • Low
  • Close
  • Volume

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:

  • Next<T> (often Next<f64> and Next<&DataItem>) - to feed and get the next value
  • Reset - to reset an indicator
  • Debug
  • Display
  • Default
  • Clone

List of indicators

So far there are the following indicators available.

  • Trend
    • Exponential Moving Average (EMA)
    • Simple Moving Average (SMA)
  • Oscillators
    • Relative Strength Index (RSI)
    • Fast Stochastic
    • Slow Stochastic
    • Moving Average Convergence Divergence (MACD)
    • Money Flow Index (MFI)
  • Other
    • Minimum
    • Maximum
    • True Range
    • Average True Range (AR)
    • Efficiency Ratio (ER)
    • Bollinger Bands (BB)
    • Rate of Change (ROC)
    • OnBalanceVolume (OBV)

Running benchmarks

cargo bench

License

MIT © Sergey Potapov

Contributors

  • greyblake Potapov Sergey - creator, maintainer.
  • Bartoshko - BollingerBands
  • shreyasdeotare Shreyas Deotare - MoneyFlowIndex, OnBalanceVolume
  • edwardycl - StandardDeviation Implementation & More Efficient BollingerBands

Dependencies

~335KB