pub struct AdvanceDeclineRatio { /* private fields */ }Expand description
Advance/Decline Ratio (ADR) — the number of advancing symbols divided by the number of declining symbols across a universe.
On each CrossSection tick the ratio is advancers / decliners: a reading
above one means advancing issues outnumber declining ones (broad strength),
while a reading below one signals broad weakness. Because it is a ratio rather
than a difference, the ADR is comparable across universes of different sizes.
When a tick has no declining symbols the denominator is floored to one, so the ratio degrades gracefully to the advancer count instead of dividing by zero.
Input = CrossSection, Output = f64. The ratio is defined from the first
tick, so warmup_period == 1 and the indicator is ready after one update.
§Example
use wickra_core::{AdvanceDeclineRatio, CrossSection, Indicator, Member};
let mut adr = AdvanceDeclineRatio::new();
// 3 advancers, 1 decliner -> ratio 3.0.
let tick = CrossSection::new(
vec![
Member::new(1.0, 10.0, false, false),
Member::new(0.5, 10.0, false, false),
Member::new(2.0, 10.0, false, false),
Member::new(-1.0, 10.0, false, false),
],
0,
)
.unwrap();
assert_eq!(adr.update(tick), Some(3.0));Implementations§
Source§impl AdvanceDeclineRatio
impl AdvanceDeclineRatio
Sourcepub const fn new() -> AdvanceDeclineRatio
pub const fn new() -> AdvanceDeclineRatio
Construct a new Advance/Decline Ratio indicator.
Trait Implementations§
Source§impl Clone for AdvanceDeclineRatio
impl Clone for AdvanceDeclineRatio
Source§fn clone(&self) -> AdvanceDeclineRatio
fn clone(&self) -> AdvanceDeclineRatio
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 AdvanceDeclineRatio
impl Debug for AdvanceDeclineRatio
Source§impl Default for AdvanceDeclineRatio
impl Default for AdvanceDeclineRatio
Source§fn default() -> AdvanceDeclineRatio
fn default() -> AdvanceDeclineRatio
Source§impl Indicator for AdvanceDeclineRatio
impl Indicator for AdvanceDeclineRatio
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 AdvanceDeclineRatio
impl RefUnwindSafe for AdvanceDeclineRatio
impl Send for AdvanceDeclineRatio
impl Sync for AdvanceDeclineRatio
impl Unpin for AdvanceDeclineRatio
impl UnsafeUnpin for AdvanceDeclineRatio
impl UnwindSafe for AdvanceDeclineRatio
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