[][src]Struct yata::methods::ADI

pub struct ADI<T: OHLCV> { /* fields omitted */ }

Accumulation Distribution Index of specified length for timeseries of OHLCV

CLV ranges from -1 when the close is the low of the day, to +1 when it's the high. For instance if the close is 3/4 the way up the range then CLV is +0.5. The accumulation/distribution index adds up volume multiplied by the CLV factor, i.e.

ADI = ADI_prev + CLV * volume

The name accumulation/distribution comes from the idea that during accumulation buyers are in control and the price will be bid up through the day, or will make a recovery if sold down, in either case more often finishing near the day's high than the low. The opposite applies during distribution.

The accumulation/distribution index is similar to on balance volume, but acc/dist is based on the close within the day's range, instead of the close-to-close up or down that the latter uses.

Can be used by a shortcut ADI

Used in indicators: Chaikin Money Flow, Chaikin Oscillator

Parameters

Has a single parameter length: PeriodType

When length == 0, ADI becomes windowless. That means full ADI value accumulation over time.

When length > 0, ADI will be calculated over the last length values.

Input type

Input type is OHLCV

Output type

Output type is ValueType

Examples

use yata::prelude::*;
use yata::methods::ADI;
use yata::helpers::RandomCandles;

let mut candles = RandomCandles::default();
let mut windowless = ADI::new(0, candles.first());
let mut windowed = ADI::new(3, candles.first()); // <----- Window size 3

let candle = candles.next().unwrap();
assert_ne!(windowless.next(candle), windowed.next(candle));

let candle = candles.next().unwrap();
assert_ne!(windowless.next(candle), windowed.next(candle));

let candle = candles.next().unwrap();
assert!((windowless.next(candle)-windowed.next(candle)).abs() < 1e-10); // Must be equal here

Perfomance

O(1)

See also

ADI

Implementations

impl<T: OHLCV> ADI<T>[src]

pub fn get_value(&self) -> ValueType[src]

Returns last calculated value

Trait Implementations

impl<T: Clone + OHLCV> Clone for ADI<T>[src]

impl<T: Debug + OHLCV> Debug for ADI<T>[src]

impl<'de, T: OHLCV> Deserialize<'de> for ADI<T>[src]

impl<T: OHLCV> Method for ADI<T>[src]

type Params = PeriodType

Method parameters

type Input = T

Input value type

type Output = ValueType

Output value type

impl<T: OHLCV> Serialize for ADI<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for ADI<T> where
    T: RefUnwindSafe

impl<T> Send for ADI<T> where
    T: Send

impl<T> Sync for ADI<T> where
    T: Sync

impl<T> Unpin for ADI<T> where
    T: Unpin

impl<T> UnwindSafe for ADI<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.