Struct yata::methods::Cross[][src]

pub struct Cross { /* fields omitted */ }

Searches for two timeseries lines of type ValueType cross each other.

If value crossed base upwards, then returns Action::BUY_ALL

If value crossed base downwards, then returns Action::SELL_ALL

Else (if series did not cross each other) returns Action::None

Parameters

Has no parameters

Input type

Input type is (value: ValueType, base: ValueType)

Output type

Output type is Action

Examples

use yata::prelude::*;
use yata::methods::Cross;

let mut cross = Cross::default();

let t1 = vec![0.0, 1.0, 2.0, 3.0, 4.0, 5.0];
let t2 = vec![5.0, 3.0, 1.8, 2.9, 4.1, 5.6];
let r  = vec![ 0,   0,   1,   0,   -1,  0 ];

(0..t1.len()).for_each(|i| {
    let value = t1[i];
    let base = t2[i];
    let cross_value = cross.next((value, base)).analog();
    assert_eq!(cross_value, r[i]);
});

Performance

O(1)

See also

CrossAbove, CrossUnder

Trait Implementations

impl Clone for Cross[src]

impl Copy for Cross[src]

impl Debug for Cross[src]

impl Default for Cross[src]

impl<'de> Deserialize<'de> for Cross[src]

impl Method<'_> for Cross[src]

type Params = ()

Method parameters

type Input = (ValueType, ValueType)

Input value type

type Output = Action

Output value type

impl Serialize for Cross[src]

Auto Trait Implementations

impl RefUnwindSafe for Cross

impl Send for Cross

impl Sync for Cross

impl Unpin for Cross

impl UnwindSafe for Cross

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.