cxmr_ta_core/
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 ta::indicators::ExponentialMovingAverage;
16//! use ta::{Calculate, 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.calc(2.0), 2.0);
22//! assert_eq!(ema.calc(5.0), 3.5);
23//! assert_eq!(ema.calc(1.0), 2.25);
24//! assert_eq!(ema.calc(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#[macro_use]
50extern crate error_chain;
51
52#[cfg(test)]
53#[macro_use]
54mod test_helper;
55
56mod helpers;
57
58pub mod errors;
59pub mod indicators;
60
61mod traits;
62pub use crate::traits::*;
63
64mod data_item;
65pub use crate::data_item::DataItem;