#technical-analysis #data-analysis #indicator #ema #finance #trading

ta

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

13 unstable releases (5 breaking)

0.5.0 Jun 26, 2021
0.4.0 Nov 3, 2020
0.3.1 Oct 20, 2020
0.1.5 Dec 16, 2019
0.0.1-beta Nov 27, 2017

#45 in Science

Download history 939/week @ 2024-07-27 1005/week @ 2024-08-03 702/week @ 2024-08-10 696/week @ 2024-08-17 832/week @ 2024-08-24 751/week @ 2024-08-31 798/week @ 2024-09-07 875/week @ 2024-09-14 759/week @ 2024-09-21 726/week @ 2024-09-28 628/week @ 2024-10-05 802/week @ 2024-10-12 694/week @ 2024-10-19 745/week @ 2024-10-26 715/week @ 2024-11-02 568/week @ 2024-11-09

2,840 downloads per month
Used in 11 crates (10 directly)

MIT license

125KB
3K SLoC

Technical Analysis for Rust (ta)

Build Status Crates.io Docs.rs License

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:

  • 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)
    • Percentage Price Oscillator (PPO)
    • Commodity Channel Index (CCI)
    • Money Flow Index (MFI)
  • Other
    • Minimum
    • Maximum
    • True Range
    • Standard Deviation (SD)
    • Mean Absolute Deviation (MAD)
    • Average True Range (AR)
    • Efficiency Ratio (ER)
    • Bollinger Bands (BB)
    • Chandelier Exit (CE)
    • Keltner Channel (KC)
    • Rate of Change (ROC)
    • On Balance Volume (OBV)

Features

  • serde - allows to serialize and deserialize indicators. NOTE: the backward compatibility of serialized data with the future versions of ta is not guaranteed because internal implementation of the indicators is a subject to change.

Running benchmarks

cargo bench

License

MIT © Sergey Potapov

Contributors

Dependencies

~165KB