pub trait IndicatorInstanceDyn<T: OHLCV> {
    // Required methods
    fn next(&mut self, candle: &T) -> IndicatorResult;
    fn over(&mut self, inputs: &dyn AsRef<[T]>) -> Vec<IndicatorResult>;
    fn config(&self) -> &dyn IndicatorConfigDyn<T>;
    fn size(&self) -> (u8, u8);
    fn name(&self) -> &'static str;
}
Expand description

Dynamically dispatchable IndicatorInstance

Required Methods§

source

fn next(&mut self, candle: &T) -> IndicatorResult

Evaluates given candle and returns IndicatorResult

source

fn over(&mut self, inputs: &dyn AsRef<[T]>) -> Vec<IndicatorResult>

Evaluates the State over the given sequence of candles and returns sequence of IndicatorResults.

use yata::prelude::dd::*;
use yata::helpers::{RandomCandles};
use yata::indicators::Trix;

let candles: Vec<_> = RandomCandles::new().take(10).collect();
let static_config = Trix::default();
let dyn_config: Box<dyn IndicatorConfigDyn<_>> = Box::new(static_config); // here we are loosing information about `IndicatorConfig`s type.
let mut state = dyn_config.init(&candles[0]).unwrap();

let results = state.over(&candles);
println!("{:?}", results);
source

fn config(&self) -> &dyn IndicatorConfigDyn<T>

Returns a reference to dynamically dispatched Configuration, associated with the current State

source

fn size(&self) -> (u8, u8)

Returns count of indicator’s raw values and count of indicator’s signals.

See more at IndicatorConfig

source

fn name(&self) -> &'static str

Returns a name of the indicator

Implementors§

source§

impl<T, I> IndicatorInstanceDyn<T> for I
where T: OHLCV, I: IndicatorInstance + 'static,