[−][src]Trait yata::core::Method
Trait for creating methods for timeseries
Regular methods usage
Iterate over vector's values
use yata::methods::SMA; use yata::prelude::*; let s:Vec<f64> = vec![1.,2.,3.,4.,5.,6.,7.,8.,9.,10.]; let mut ma = SMA::new(2, s[0]); s.iter().enumerate().for_each(|(index, &value)| { assert_eq!(ma.next(value), (value + s[index.saturating_sub(1)])/2.); });
Get a whole new vector over the input vector
use yata::methods::SMA; use yata::prelude::*; let s:Vec<f64> = vec![1.,2.,3.,4.,5.,6.,7.,8.,9.,10.]; let mut ma = SMA::new(2, s[0]); let result = ma.over(s.iter().copied()); assert_eq!(result.as_slice(), &[1., 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5]);
Change vector values using method
use yata::core::Sequence; use yata::methods::SMA; use yata::prelude::*; let mut s:Sequence<f64> = Sequence::from(vec![1.,2.,3.,4.,5.,6.,7.,8.,9.,10.]); let mut ma = SMA::new(2, s[0]); s.apply(&mut ma); assert_eq!(s.as_slice(), &[1., 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5]);
Be advised
There is no reset
method on the trait. If you need reset a state of the Method
instance, you should just create a new one.
Associated Types
Loading content...Required methods
fn new(parameters: Self::Params, initial_value: Self::Input) -> Self where
Self: Sized,
Self: Sized,
Static method for creating an instance of the method with given parameters
and initial value
(simply first input value)
fn next(&mut self, value: Self::Input) -> Self::Output
Generates next output value based on the given input value
Provided methods
fn name(&self) -> &str
Returns a name of the method
fn memsize(&self) -> (usize, usize) where
Self: Sized,
Self: Sized,
Returns memory size of the method (size, align)
fn iter_data<I>(&mut self, input: I) -> MethodOverIterator<'_, Self, I> where
I: Iterator<Item = Self::Input>,
Self: Sized,
I: Iterator<Item = Self::Input>,
Self: Sized,
Creates an iterator
which produces values by the Method
over given input data Iterator
fn over<I>(&mut self, sequence: I) -> Sequence<Self::Output> where
I: Iterator<Item = Self::Input>,
Self: Sized,
I: Iterator<Item = Self::Input>,
Self: Sized,
Iterates the Method
over the given Iterator
and returns timeserie of output values
Guarantees
The length of an output Sequence
is always equal to the length of input one
use yata::methods::SMA; use yata::prelude::*; let s:Vec<f64> = vec![1.,2.,3.,4.,5.,6.,7.,8.,9.,10.]; let mut ma = SMA::new(5, s[0]); let result = ma.over(s.iter().copied()); assert_eq!(result.len(), s.len());
use yata::methods::SMA; use yata::prelude::*; let s:Vec<f64> = vec![1.,2.,3.,4.,5.,6.,7.,8.,9.,10.]; let mut ma = SMA::new(100, s[0]); let result = ma.over(s.iter().copied()); assert_eq!(result.len(), s.len());
Implementors
impl Method for Conv
[src]
type Params = Vec<ValueType>
type Input = ValueType
type Output = Self::Input
fn new(weights: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for Cross
[src]
type Params = ()
type Input = (ValueType, ValueType)
type Output = Action
fn new(_: Self::Params, value: Self::Input) -> Self where
Self: Sized,
[src]
Self: Sized,
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for CrossAbove
[src]
type Params = ()
type Input = (ValueType, ValueType)
type Output = Action
fn new(_: Self::Params, value: Self::Input) -> Self where
Self: Sized,
[src]
Self: Sized,
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for CrossUnder
[src]
type Params = ()
type Input = (ValueType, ValueType)
type Output = Action
fn new(_: Self::Params, value: Self::Input) -> Self where
Self: Sized,
[src]
Self: Sized,
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for DEMA
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for DMA
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for Derivative
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for EMA
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for HMA
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for Highest
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: ValueType) -> ValueType
[src]
impl Method for HighestLowestDelta
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self where
Self: Sized,
[src]
Self: Sized,
fn next(&mut self, value: ValueType) -> ValueType
[src]
impl Method for Integral
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for LinReg
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for LinearVolatility
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for Lowest
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: ValueType) -> ValueType
[src]
impl Method for Momentum
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for PivotHighSignal
[src]
type Params = (PeriodType, PeriodType)
type Input = ValueType
type Output = Action
fn new(params: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for PivotLowSignal
[src]
type Params = (PeriodType, PeriodType)
type Input = ValueType
type Output = Action
fn new(params: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for PivotSignal
[src]
type Params = (PeriodType, PeriodType)
type Input = ValueType
type Output = Action
fn new(params: Self::Params, value: Self::Input) -> Self where
Self: Sized,
[src]
Self: Sized,
fn next(&mut self, value: ValueType) -> Self::Output
[src]
impl Method for RMA
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for RateOfChange
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for SMA
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for SMM
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for SWMA
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for StDev
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for TEMA
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for TMA
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for TRIMA
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for VWMA
[src]
type Params = PeriodType
type Input = (ValueType, ValueType)
type Output = ValueType
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl Method for WMA
[src]
type Params = PeriodType
type Input = ValueType
type Output = Self::Input
fn new(length: Self::Params, value: Self::Input) -> Self
[src]
fn next(&mut self, value: Self::Input) -> Self::Output
[src]
impl<T> Method for Past<T> where
T: Sized + Copy + Default + Debug,
[src]
T: Sized + Copy + Default + Debug,