ux_indicators/
lib.rs

1//! ta is a Rust library for technical analysis. It provides number of technical indicators
2//! that can be used to build trading strategies for stock markets, futures, forex, cryptocurrencies, etc.
3//!
4//! Every indicator is implemented as a data structure with fields, that define parameters and
5//! state.
6//!
7//! Every indicator implements [Next<T>](trait.Next.html) and [Reset](trait.Reset.html) traits,
8//! which are the core concept of the library.
9//!
10//! Since `Next<T>` is a generic trait, most of the indicators can work with both input types: `f64` and more complex
11//! structures like [DataItem](struct.DataItem.html).
12//!
13//! # Example
14//! ```
15//! use core::indicators::ExponentialMovingAverage;
16//! use core::Next;
17//!
18//! // it can return an error, when an invalid length is passed (e.g. 0)
19//! let mut ema = ExponentialMovingAverage::new(3).unwrap();
20//!
21//! assert_eq!(ema.next(2.0), 2.0);
22//! assert_eq!(ema.next(5.0), 3.5);
23//! assert_eq!(ema.next(1.0), 2.25);
24//! assert_eq!(ema.next(6.25), 4.25);
25//! ```
26//!
27//! # List of indicators
28//!
29//! * Trend
30//!   * [Exponential Moving Average (EMA)](indicators/struct.ExponentialMovingAverage.html)
31//!   * [Simple Moving Average (SMA)](indicators/struct.SimpleMovingAverage.html)
32//! * Oscillators
33//!   * [Relative Strength Index (RSI)](indicators/struct.RelativeStrengthIndex.html)
34//!   * [Fast Stochastic](indicators/struct.FastStochastic.html)
35//!   * [Slow Stochastic](indicators/struct.SlowStochastic.html)
36//!   * [Moving Average Convergence Divergence (MACD)](indicators/struct.MovingAverageConvergenceDivergence.html)
37//!   * [Money Flow Index (MFI)](indicators/struct.MoneyFlowIndex.html)
38//! * Other
39//!   * [Standard Deviation (SD)](indicators/struct.StandardDeviation.html)
40//!   * [Bollinger Bands (BB)](indicators/struct.BollingerBands.html)
41//!   * [Maximum](indicators/struct.Maximum.html)
42//!   * [Minimum](indicators/struct.Minimum.html)
43//!   * [True Range](indicators/struct.TrueRange.html)
44//!   * [Average True Range (ATR)](indicators/struct.AverageTrueRange.html)
45//!   * [Efficiency Ratio (ER)](indicators/struct.EfficiencyRatio.html)
46//!   * [Rate of Change (ROC)](indicators/struct.RateOfChange.html)
47//!   * [On Balance Volume (OBV)](indicators/struct.OnBalanceVolume.html)
48//!
49
50mod utils;
51
52#[macro_use]
53extern crate error_chain;
54
55#[cfg(test)]
56#[macro_use]
57mod test_helper;
58
59mod helpers;
60
61pub mod errors;
62pub mod indicators;
63
64mod traits;
65pub use crate::traits::*;
66
67mod indicator;
68pub use crate::indicator::*;
69
70mod data_item;
71pub use crate::data_item::DataItem;
72
73#[cfg(test)]
74mod tests {
75    #[test]
76    fn it_works() {
77        assert_eq!(2 + 2, 4);
78    }
79}