1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#![warn(missing_docs, missing_debug_implementations)]

//! Commonly used methods for manipulating timeseries.
//! Every method implements [`Method`](crate::core::Method) trait.
//!
//! To create a method instance use [`Method::new`](crate::core::Method::new).
//! To get new output value over the input value use [`Method::next`](crate::core::Method::next).
//!
//! ```
//! // creating Weighted Moving Average of length `5`
//! use yata::prelude::*;
//! use yata::methods::WMA;
//!
//! let mut wma = WMA::new(5, &20.0).unwrap();
//!
//! let input_value = &34.51;
//! let output_value = wma.next(input_value);
//! ```
//!
//! # Examples
//!
//! ```
//! use yata::prelude::*;
//! use yata::methods::SMA;
//!
//! let mut sma = SMA::new(3, &5.0).unwrap();
//! sma.next(&5.0);
//! sma.next(&4.0);
//! assert_eq!(sma.next(&6.0), 5.0);
//! assert_eq!(sma.next(&2.0), 4.0);
//! assert_eq!(sma.next(&-2.0), 2.0);
//! ```

mod sma;
pub use sma::*;
mod wma;
pub use wma::*;
mod ema;
pub use ema::*;
mod wsma;
pub use wsma::*;
mod rma;
pub use rma::*;
mod smm;
pub use smm::*;
mod hma;
pub use hma::*;
mod lin_reg;
pub use lin_reg::*;
mod swma;
pub use swma::*;
mod conv;
pub use conv::*;
mod vwma;
pub use vwma::*;
mod trima;
pub use trima::*;
//
mod derivative;
pub use derivative::*;
mod integral;
pub use integral::*;
mod momentum;
pub use momentum::*;
mod rate_of_change;
pub use rate_of_change::*;
mod tsi;
pub use tsi::*;
mod st_dev;
pub use st_dev::*;
mod volatility;
pub use volatility::*;
mod cci;
pub use cci::*;
mod mean_abs_dev;
pub use mean_abs_dev::*;
mod median_abs_dev;
pub use median_abs_dev::*;
mod vidya;
pub use vidya::*;

mod cross;
pub use cross::*;
mod reversal;
pub use reversal::*;
mod highest_lowest;
pub use highest_lowest::*;
mod adi;
mod highest_lowest_index;
pub use adi::*;
pub use highest_lowest_index::*;
mod past;
pub use past::*;
mod heikin_ashi;
pub use heikin_ashi::HeikinAshi;
mod tr;
pub use tr::TR;
/// Renko implementation entities
///
/// For more information see [`Renko`]
pub mod renko;
#[doc(inline)]
pub use renko::Renko;
mod collapse_timeframe;
pub use collapse_timeframe::CollapseTimeframe;

#[cfg(test)]
mod tests {
	use crate::core::{Method, ValueType};
	use crate::helpers::assert_eq_float;
	use std::fmt::Debug;

	pub(super) fn test_const<P, I: ?Sized, O: Debug + PartialEq>(
		method: &mut dyn Method<Params = P, Input = I, Output = O>,
		input: &I,
		output: &O,
	) {
		for _ in 0..100 {
			assert_eq!(&method.next(input), output);
		}
	}

	pub(super) fn test_const_float<P, I: ?Sized>(
		method: &mut dyn Method<Params = P, Input = I, Output = ValueType>,
		input: &I,
		output: ValueType,
	) {
		for _ in 0..100 {
			// assert!((method.next(&input) - output).abs() < SIGMA);
			assert_eq_float(output, method.next(input));
		}
	}
}