pub struct CumulativeVolumeIndex { /* private fields */ }Expand description
Cumulative Volume Index (CVI) — the running total of volume-normalised net advancing volume across a universe.
On each CrossSection tick the increment is (advancing volume - declining volume) / total volume: the share of the tick’s total volume that flowed,
net, into advancing issues. The index accumulates this share over time. Where
the raw AdVolumeLine sums absolute net volume — and
so drifts with secular growth in trading activity — the CVI normalises each
tick by its own total volume, so a one-share-net day in a thin market counts
the same as in a heavy one. This keeps the index comparable across regimes of
very different volume.
When a tick has zero total volume the net is necessarily zero too, so the
increment is zero and the index is unchanged (the divisor is floored to the
smallest positive f64 purely to keep the division defined).
Input = CrossSection, Output = f64, warmup_period == 1.
§Example
use wickra_core::{CrossSection, CumulativeVolumeIndex, Indicator, Member};
let mut cvi = CumulativeVolumeIndex::new();
// adv vol 150, dec vol 50, total 200 -> (150 - 50) / 200 = 0.5.
let tick = CrossSection::new(
vec![
Member::new(1.0, 150.0, false, false),
Member::new(-1.0, 50.0, false, false),
],
0,
)
.unwrap();
assert_eq!(cvi.update(tick), Some(0.5));Implementations§
Trait Implementations§
Source§impl Clone for CumulativeVolumeIndex
impl Clone for CumulativeVolumeIndex
Source§fn clone(&self) -> CumulativeVolumeIndex
fn clone(&self) -> CumulativeVolumeIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CumulativeVolumeIndex
impl Debug for CumulativeVolumeIndex
Source§impl Default for CumulativeVolumeIndex
impl Default for CumulativeVolumeIndex
Source§fn default() -> CumulativeVolumeIndex
fn default() -> CumulativeVolumeIndex
Source§impl Indicator for CumulativeVolumeIndex
impl Indicator for CumulativeVolumeIndex
Source§type Input = CrossSection
type Input = CrossSection
f64 for a price, or Candle / Tick).Source§fn update(&mut self, section: CrossSection) -> Option<f64>
fn update(&mut self, section: CrossSection) -> Option<f64>
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
None output can be produced.Auto Trait Implementations§
impl Freeze for CumulativeVolumeIndex
impl RefUnwindSafe for CumulativeVolumeIndex
impl Send for CumulativeVolumeIndex
impl Sync for CumulativeVolumeIndex
impl Unpin for CumulativeVolumeIndex
impl UnsafeUnpin for CumulativeVolumeIndex
impl UnwindSafe for CumulativeVolumeIndex
Blanket Implementations§
Source§impl<T> BatchExt for Twhere
T: Indicator,
impl<T> BatchExt for Twhere
T: Indicator,
Source§fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
fn batch(&mut self, inputs: &[Self::Input]) -> Vec<Option<Self::Output>>
None during warmup) per input.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more