pub trait IndicatorConfigDyn<T: OHLCV> {
    // Required methods
    fn init(
        &self,
        initial_value: &T
    ) -> Result<Box<dyn IndicatorInstanceDyn<T>>, Error>;
    fn over(
        &self,
        inputs: &dyn AsRef<[T]>
    ) -> Result<Vec<IndicatorResult>, Error>;
    fn name(&self) -> &'static str;
    fn validate(&self) -> bool;
    fn set(&mut self, name: &str, value: String) -> Result<(), Error>;
    fn size(&self) -> (u8, u8);
}
Expand description

Dynamically dispatchable IndicatorConfig

Required Methods§

source

fn init( &self, initial_value: &T ) -> Result<Box<dyn IndicatorInstanceDyn<T>>, Error>

Dynamically initializes the State based on the current Configuration

source

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

Evaluates dynamically dispatched IndicatorConfig over series of OHLC and returns series 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 results = dyn_config.over(&candles).unwrap();
println!("{:?}", results);
source

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

Returns a name of the indicator

source

fn validate(&self) -> bool

Validates if Configuration is OK

source

fn set(&mut self, name: &str, value: String) -> Result<(), Error>

Dynamically sets Configuration parameters

source

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

Returns an IndicatorResult size processing by the indicator (count of raw values, count of signals)

Implementors§

source§

impl<T, I, C> IndicatorConfigDyn<T> for C
where T: OHLCV, I: IndicatorInstanceDyn<T> + IndicatorInstance<Config = Self> + 'static, C: IndicatorConfig<Instance = I> + Clone + 'static,