Trait yata::core::IndicatorConfig
source · pub trait IndicatorConfig: Clone {
type Instance: IndicatorInstance<Config = Self>;
const NAME: &'static str;
// Required methods
fn validate(&self) -> bool;
fn set(&mut self, name: &str, value: String) -> Result<(), Error>;
fn size(&self) -> (u8, u8);
fn init<T: OHLCV>(self, initial_value: &T) -> Result<Self::Instance, Error>;
// Provided methods
fn name(&self) -> &'static str { ... }
fn init_fn<'a, T: OHLCV>(
self,
initial_value: &'a T
) -> Result<Box<dyn FnMut(&'a T) -> IndicatorResult>, Error>
where Self: 'static { ... }
fn over<T, S>(self, inputs: S) -> Result<Vec<IndicatorResult>, Error>
where T: OHLCV,
S: AsRef<[T]>,
Self: Sized { ... }
}
Expand description
Each indicator has it’s own Configuration with parameters
Each that config should implement IndicatorConfig
trait
See example with Example Indicator
Required Associated Types§
sourcetype Instance: IndicatorInstance<Config = Self>
type Instance: IndicatorInstance<Config = Self>
Type of State
Required Associated Constants§
Required Methods§
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)
Provided Methods§
sourcefn init_fn<'a, T: OHLCV>(
self,
initial_value: &'a T
) -> Result<Box<dyn FnMut(&'a T) -> IndicatorResult>, Error>where
Self: 'static,
fn init_fn<'a, T: OHLCV>(
self,
initial_value: &'a T
) -> Result<Box<dyn FnMut(&'a T) -> IndicatorResult>, Error>where
Self: 'static,
Creates an IndicatorInstance
function from this IndicatorConfig
.
sourcefn over<T, S>(self, inputs: S) -> Result<Vec<IndicatorResult>, Error>
fn over<T, S>(self, inputs: S) -> Result<Vec<IndicatorResult>, Error>
Evaluates indicator config over sequence of OHLC and returns sequence of IndicatorResult
s
use yata::prelude::*;
use yata::helpers::{RandomCandles};
use yata::indicators::Trix;
let candles: Vec<_> = RandomCandles::new().take(10).collect();
let trix = Trix::default();
let results = trix.over(&candles).unwrap();
println!("{:?}", results);
Object Safety§
This trait is not object safe.
Implementors§
source§impl IndicatorConfig for Example
impl IndicatorConfig for Example
Implementing IndicatorConfig
trait