finlib_ta/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 finlib_ta::indicators::ExponentialMovingAverage;
16//! use finlib_ta::Next;
17//!
18//! // it can return an error, when an invalid period 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)](crate::indicators::ExponentialMovingAverage)
31//! * [Hull Moving Average (HMA)](crate::indicators::HullMovingAverage)
32//! * [Simple Moving Average (SMA)](crate::indicators::SimpleMovingAverage)
33//! * [Weighted Moving Average (WMA)](crate::indicators::WeightedMovingAverage)
34//! * [Volume Weighted Average Price (VWAP)](crate::indicators::VolumeWeightedAveragePrice)
35//! * Oscillators
36//! * [Relative Strength Index (RSI)](indicators/struct.RelativeStrengthIndex.html)
37//! * [Fast Stochastic](indicators/struct.FastStochastic.html)
38//! * [Slow Stochastic](indicators/struct.SlowStochastic.html)
39//! * [Moving Average Convergence Divergence (MACD)](indicators/struct.MovingAverageConvergenceDivergence.html)
40//! * [Percentage Price Oscillator (PPO)](indicators/struct.PercentagePriceOscillator.html)
41//! * [Commodity Channel Index (CCI)](indicators/struct.CommodityChannelIndex.html)
42//! * [Money Flow Index (MFI)](indicators/struct.MoneyFlowIndex.html)
43//! * Other
44//! * [Standard Deviation (SD)](indicators/struct.StandardDeviation.html)
45//! * [Mean Absolute Deviation (MAD)](indicators/struct.MeanAbsoluteDeviation.html)
46//! * [Bollinger Bands (BB)](indicators/struct.BollingerBands.html)
47//! * [Chandelier Exit (CE)](indicators/struct.ChandelierExit.html)
48//! * [Keltner Channel (KC)](indicators/struct.KeltnerChannel.html)
49//! * [Maximum](indicators/struct.Maximum.html)
50//! * [Minimum](indicators/struct.Minimum.html)
51//! * [True Range](indicators/struct.TrueRange.html)
52//! * [Average True Range (ATR)](indicators/struct.AverageTrueRange.html)
53//! * [Efficiency Ratio (ER)](indicators/struct.EfficiencyRatio.html)
54//! * [Rate of Change (ROC)](indicators/struct.RateOfChange.html)
55//! * [On Balance Volume (OBV)](indicators/struct.OnBalanceVolume.html)
56//!
57
58#![cfg_attr(not(feature = "std"), no_std)]
59
60extern crate alloc;
61#[cfg(feature = "std")]
62extern crate std;
63
64#[cfg(test)]
65#[macro_use]
66mod test_helper;
67
68mod helpers;
69
70pub mod errors;
71pub mod indicators;
72
73mod traits;
74pub use crate::traits::*;
75
76mod data_item;
77pub use crate::data_item::DataItem;