pub trait IndicatorInstance: Sized {
    type Config: IndicatorConfig<Instance = Self>;

    // Required methods
    fn config(&self) -> &Self::Config;
    fn next<T: OHLCV>(&mut self, candle: &T) -> IndicatorResult;

    // Provided methods
    fn over<T, S>(&mut self, inputs: S) -> Vec<IndicatorResult>
       where T: OHLCV,
             S: AsRef<[T]> { ... }
    fn size(&self) -> (u8, u8) { ... }
    fn name(&self) -> &'static str { ... }
    fn into_fn<'a, T>(self) -> Box<dyn FnMut(&'a T) -> IndicatorResult>
       where T: OHLCV,
             Self: 'static { ... }
}
Expand description

Base trait for implementing indicators State

Required Associated Types§

source

type Config: IndicatorConfig<Instance = Self>

Type of Indicator Configuration

Required Methods§

source

fn config(&self) -> &Self::Config

Returns a reference to the indicator Configuration

source

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

Evaluates given candle and returns IndicatorResult

Provided Methods§

source

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

Evaluates the State over the given sequence of candles 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 mut state = trix.init(&candles[0]).unwrap();

let results = state.over(&candles);
println!("{:?}", results);
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

source

fn into_fn<'a, T>(self) -> Box<dyn FnMut(&'a T) -> IndicatorResult>
where T: OHLCV, Self: 'static,

Creates a function from IndicatorInstance

Object Safety§

This trait is not object safe.

Implementors§

source§

impl IndicatorInstance for ExampleInstance

Implementing IndicatorInstance trait for Example

source§

impl IndicatorInstance for AroonInstance

source§

impl IndicatorInstance for BollingerBandsInstance

source§

impl IndicatorInstance for ChaikinMoneyFlowInstance

source§

impl IndicatorInstance for ChandeMomentumOscillatorInstance

source§

impl IndicatorInstance for CommodityChannelIndexInstance

source§

impl IndicatorInstance for DonchianChannelInstance

source§

impl IndicatorInstance for HullMovingAverageInstance

source§

impl IndicatorInstance for IchimokuCloudInstance

source§

impl IndicatorInstance for KaufmanInstance

source§

impl IndicatorInstance for MomentumIndexInstance

source§

impl IndicatorInstance for MoneyFlowIndexInstance

source§

impl IndicatorInstance for ParabolicSARInstance

source§

impl IndicatorInstance for PivotReversalStrategyInstance

source§

impl IndicatorInstance for PriceChannelStrategyInstance

source§

impl IndicatorInstance for TrendStrengthIndexInstance

source§

impl IndicatorInstance for TrueStrengthIndexInstance

source§

impl IndicatorInstance for WoodiesCCIInstance

source§

impl<M: MovingAverageConstructor> IndicatorInstance for AverageDirectionalIndexInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for AwesomeOscillatorInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for ChaikinOscillatorInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for ChandeKrollStopInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for CoppockCurveInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for DetrendedPriceOscillatorInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for EaseOfMovementInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for EldersForceIndexInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for EnvelopesInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for FisherTransformInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for KeltnerChannelInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for KlingerVolumeOscillatorInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for KnowSureThingInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for MACDInstance<M>

§

type Config = MACD<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for RelativeStrengthIndexInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for RelativeVigorIndexInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for SMIErgodicIndicatorInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for StochasticOscillatorInstance<M>

source§

impl<M: MovingAverageConstructor> IndicatorInstance for TRIXInstance<M>

§

type Config = Trix<M>