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§

source

type Instance: IndicatorInstance<Config = Self>

Type of State

Required Associated Constants§

source

const NAME: &'static str

Name of an indicator

Required Methods§

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)

source

fn init<T: OHLCV>(self, initial_value: &T) -> Result<Self::Instance, Error>

Initializes the State based on current Configuration

Provided Methods§

source

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

Returns a name of the indicator

source

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.

source

fn over<T, S>(self, inputs: S) -> Result<Vec<IndicatorResult>, Error>
where T: OHLCV, S: AsRef<[T]>, Self: Sized,

Evaluates indicator config over sequence of OHLC and returns sequence of IndicatorResults

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

Implementing IndicatorConfig trait

§

type Instance = ExampleInstance

source§

const NAME: &'static str = "Example"

source§

impl IndicatorConfig for Aroon

§

type Instance = AroonInstance

source§

const NAME: &'static str = "Aroon"

source§

impl IndicatorConfig for BollingerBands

§

type Instance = BollingerBandsInstance

source§

const NAME: &'static str = "BollingerBands"

source§

impl IndicatorConfig for ChaikinMoneyFlow

§

type Instance = ChaikinMoneyFlowInstance

source§

const NAME: &'static str = "ChaikinMoneyFlow"

source§

impl IndicatorConfig for ChandeMomentumOscillator

§

type Instance = ChandeMomentumOscillatorInstance

source§

const NAME: &'static str = "ChandeMomentumOscillator"

source§

impl IndicatorConfig for CommodityChannelIndex

§

type Instance = CommodityChannelIndexInstance

source§

const NAME: &'static str = "CommodityChannelIndex"

source§

impl IndicatorConfig for DonchianChannel

§

type Instance = DonchianChannelInstance

source§

const NAME: &'static str = "DonchianChannel"

source§

impl IndicatorConfig for HullMovingAverage

§

type Instance = HullMovingAverageInstance

source§

const NAME: &'static str = "HullMovingAverage"

source§

impl IndicatorConfig for IchimokuCloud

§

type Instance = IchimokuCloudInstance

source§

const NAME: &'static str = "IchimokuCloud"

source§

impl IndicatorConfig for Kaufman

§

type Instance = KaufmanInstance

source§

const NAME: &'static str = "Kaufman"

source§

impl IndicatorConfig for MomentumIndex

§

type Instance = MomentumIndexInstance

source§

const NAME: &'static str = "MomentumIndex"

source§

impl IndicatorConfig for MoneyFlowIndex

§

type Instance = MoneyFlowIndexInstance

source§

const NAME: &'static str = "MoneyFlowIndex"

source§

impl IndicatorConfig for ParabolicSAR

§

type Instance = ParabolicSARInstance

source§

const NAME: &'static str = "ParabolicSAR"

source§

impl IndicatorConfig for PivotReversalStrategy

§

type Instance = PivotReversalStrategyInstance

source§

const NAME: &'static str = "PivotReversalStrategy"

source§

impl IndicatorConfig for PriceChannelStrategy

§

type Instance = PriceChannelStrategyInstance

source§

const NAME: &'static str = "PriceChannelStrategy"

source§

impl IndicatorConfig for TrendStrengthIndex

§

type Instance = TrendStrengthIndexInstance

source§

const NAME: &'static str = "TrendStrengthIndex"

source§

impl IndicatorConfig for TrueStrengthIndex

§

type Instance = TrueStrengthIndexInstance

source§

const NAME: &'static str = "TrueStrengthIndex"

source§

impl IndicatorConfig for WoodiesCCI

§

type Instance = WoodiesCCIInstance

source§

const NAME: &'static str = "WoodiesCCI"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for AverageDirectionalIndex<M>

§

type Instance = AverageDirectionalIndexInstance<M>

source§

const NAME: &'static str = "AverageDirectionalIndex"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for AwesomeOscillator<M>

§

type Instance = AwesomeOscillatorInstance<M>

source§

const NAME: &'static str = "AwesomeOscillator"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for ChaikinOscillator<M>

§

type Instance = ChaikinOscillatorInstance<M>

source§

const NAME: &'static str = "ChaikinOscillator"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for ChandeKrollStop<M>

§

type Instance = ChandeKrollStopInstance<M>

source§

const NAME: &'static str = "ChandeKrollStop"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for CoppockCurve<M>

§

type Instance = CoppockCurveInstance<M>

source§

const NAME: &'static str = "CoppockCurve"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for DetrendedPriceOscillator<M>

§

type Instance = DetrendedPriceOscillatorInstance<M>

source§

const NAME: &'static str = "DetrendedPriceOscillator"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for EaseOfMovement<M>

§

type Instance = EaseOfMovementInstance<M>

source§

const NAME: &'static str = "EaseOfMovement"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for EldersForceIndex<M>

§

type Instance = EldersForceIndexInstance<M>

source§

const NAME: &'static str = "EldersForceIndex"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for Envelopes<M>

§

type Instance = EnvelopesInstance<M>

source§

const NAME: &'static str = "Envelopes"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for FisherTransform<M>

§

type Instance = FisherTransformInstance<M>

source§

const NAME: &'static str = "FisherTransform"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for KeltnerChannel<M>

§

type Instance = KeltnerChannelInstance<M>

source§

const NAME: &'static str = "KeltnerChannel"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for KlingerVolumeOscillator<M>

§

type Instance = KlingerVolumeOscillatorInstance<M>

source§

const NAME: &'static str = "KlingerVolumeOscillator"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for KnowSureThing<M>

§

type Instance = KnowSureThingInstance<M>

source§

const NAME: &'static str = "KnowSureThing"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for MACD<M>

§

type Instance = MACDInstance<M>

source§

const NAME: &'static str = "MACD"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for RelativeStrengthIndex<M>

§

type Instance = RelativeStrengthIndexInstance<M>

source§

const NAME: &'static str = "RelativeStrengthIndex"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for RelativeVigorIndex<M>

§

type Instance = RelativeVigorIndexInstance<M>

source§

const NAME: &'static str = "RelativeVigorIndex"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for SMIErgodicIndicator<M>

§

type Instance = SMIErgodicIndicatorInstance<M>

source§

const NAME: &'static str = "SMIErgodicIndicator"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for StochasticOscillator<M>

§

type Instance = StochasticOscillatorInstance<M>

source§

const NAME: &'static str = "StochasticOscillator"

source§

impl<M: MovingAverageConstructor> IndicatorConfig for Trix<M>

§

type Instance = TRIXInstance<M>

source§

const NAME: &'static str = "Trix"