pub struct McClellanOscillator { /* private fields */ }Expand description
McClellan Oscillator — the difference between a 19-period and a 39-period exponential moving average of ratio-adjusted net advances.
Each tick’s breadth is reduced to ratio-adjusted net advances (RANA),
(advancers - decliners) / (advancers + decliners) * 1000. Dividing by the
number of participating issues makes the reading independent of universe size,
so the oscillator stays comparable as the universe grows or shrinks. The
oscillator is then the fast EMA minus the slow EMA of that series, using the
classic McClellan smoothing constants 0.10 (19-period) and 0.05
(39-period). Both EMAs are seeded from the first tick’s RANA, so the
oscillator is defined from the first update (warmup_period == 1); it starts
at 0.0 and crosses zero as breadth momentum shifts.
A tick with no advancing or declining issues yields a RANA of 0.0 (the
participating count is floored to one).
Input = CrossSection, Output = f64.
§Example
use wickra_core::{CrossSection, Indicator, McClellanOscillator, Member};
let mut osc = McClellanOscillator::new();
let tick = CrossSection::new(
vec![
Member::new(1.0, 10.0, false, false),
Member::new(1.0, 10.0, false, false),
Member::new(1.0, 10.0, false, false),
Member::new(-1.0, 10.0, false, false),
],
0,
)
.unwrap();
// First tick seeds both EMAs to the same value -> oscillator 0.
assert_eq!(osc.update(tick), Some(0.0));Implementations§
Trait Implementations§
Source§impl Clone for McClellanOscillator
impl Clone for McClellanOscillator
Source§fn clone(&self) -> McClellanOscillator
fn clone(&self) -> McClellanOscillator
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 McClellanOscillator
impl Debug for McClellanOscillator
Source§impl Default for McClellanOscillator
impl Default for McClellanOscillator
Source§fn default() -> McClellanOscillator
fn default() -> McClellanOscillator
Source§impl Indicator for McClellanOscillator
impl Indicator for McClellanOscillator
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 McClellanOscillator
impl RefUnwindSafe for McClellanOscillator
impl Send for McClellanOscillator
impl Sync for McClellanOscillator
impl Unpin for McClellanOscillator
impl UnsafeUnpin for McClellanOscillator
impl UnwindSafe for McClellanOscillator
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