Trait yata::core::IndicatorConfigDyn
source · 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§
sourcefn init(
&self,
initial_value: &T
) -> Result<Box<dyn IndicatorInstanceDyn<T>>, Error>
fn init( &self, initial_value: &T ) -> Result<Box<dyn IndicatorInstanceDyn<T>>, Error>
Dynamically initializes the State based on the current Configuration
sourcefn over(&self, inputs: &dyn AsRef<[T]>) -> Result<Vec<IndicatorResult>, Error>
fn over(&self, inputs: &dyn AsRef<[T]>) -> Result<Vec<IndicatorResult>, Error>
Evaluates dynamically dispatched IndicatorConfig
over series of OHLC and returns series of IndicatorResult
s
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);
sourcefn set(&mut self, name: &str, value: String) -> Result<(), Error>
fn set(&mut self, name: &str, value: String) -> Result<(), Error>
Dynamically sets Configuration parameters
sourcefn size(&self) -> (u8, u8)
fn size(&self) -> (u8, u8)
Returns an IndicatorResult
size processing by the indicator (count of raw values, count of signals)