[−][src]Struct yata::methods::ADI
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.
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
Implementations
impl<T: OHLCV> ADI<T>
[src]
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]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
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
fn new(length: Self::Params, candle: Self::Input) -> Self
[src]
fn next(&mut self, candle: Self::Input) -> Self::Output
[src]
fn name(&self) -> &str
[src]
fn memsize(&self) -> (usize, usize) where
Self: Sized,
[src]
Self: Sized,
fn iter_data<I>(&mut self, input: I) -> MethodOverIterator<'_, Self, I> where
I: Iterator<Item = Self::Input>,
Self: Sized,
[src]
I: Iterator<Item = Self::Input>,
Self: Sized,
fn over<I>(&mut self, sequence: I) -> Sequence<Self::Output> where
I: Iterator<Item = Self::Input>,
Self: Sized,
[src]
I: Iterator<Item = Self::Input>,
Self: Sized,
impl<T: OHLCV> Serialize for ADI<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for ADI<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for ADI<T> where
T: Send,
T: Send,
impl<T> Sync for ADI<T> where
T: Sync,
T: Sync,
impl<T> Unpin for ADI<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for ADI<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,