pub struct PpoHistogram { /* private fields */ }Expand description
PPO Histogram — the ppo − signal bar of the Percentage Price Oscillator.
ppo = 100 · (EMA_fast − EMA_slow) / EMA_slow
signal = EMA(ppo, signal_period)
histogram = ppo − signalPpo itself only emits the percentage line; this indicator
adds the classic 9-period signal EMA on top and reports the resulting
zero-centered histogram. Because PPO is scale-free (the EMA gap is divided
by the slow EMA), the histogram is comparable across instruments — a
PPO histogram of 0.4 means the same relative momentum on any asset, unlike
the price-unit MacdHistogram.
With Appel’s defaults fast = 12, slow = 26, signal = 9, the first
value lands after slow + signal − 1 inputs — the point at which the slow
EMA and then the signal EMA are both seeded.
§Example
use wickra_core::{Indicator, PpoHistogram};
let mut indicator = PpoHistogram::new(12, 26, 9).unwrap();
let mut last = None;
for i in 0..80 {
last = indicator.update(100.0 + f64::from(i));
}
assert!(last.is_some());Implementations§
Source§impl PpoHistogram
impl PpoHistogram
Sourcepub fn new(fast: usize, slow: usize, signal: usize) -> Result<Self>
pub fn new(fast: usize, slow: usize, signal: usize) -> Result<Self>
Construct a PPO histogram with the fast/slow EMA periods and the
signal EMA period.
§Errors
Returns Error::PeriodZero if any period is 0, or
Error::InvalidPeriod if fast >= slow.
Trait Implementations§
Source§impl Clone for PpoHistogram
impl Clone for PpoHistogram
Source§fn clone(&self) -> PpoHistogram
fn clone(&self) -> PpoHistogram
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 PpoHistogram
impl Debug for PpoHistogram
Source§impl Indicator for PpoHistogram
impl Indicator for PpoHistogram
Source§fn update(&mut self, input: f64) -> Option<f64>
fn update(&mut self, input: f64) -> 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 PpoHistogram
impl RefUnwindSafe for PpoHistogram
impl Send for PpoHistogram
impl Sync for PpoHistogram
impl Unpin for PpoHistogram
impl UnsafeUnpin for PpoHistogram
impl UnwindSafe for PpoHistogram
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