pub struct AverageDrawdown { /* private fields */ }Expand description
Rolling Average Drawdown.
Input is treated as an equity-curve sample. The indicator scans the
trailing window of period values, tracks the running peak inside the
window, and reports the mean of all bar-by-bar drawdowns (the average
“pain” of being under water):
drawdown_t = (peak_t − equity_t) / peak_t (running peak inside window)
AvgDD = mean(drawdown_t over window)Output is non-negative (a fraction; 0.05 ≈ 5 % average drawdown). This
is the Pain Index under a different name — see crate::PainIndex
for the same metric exposed under its conventional label.
Each update is O(period).
Implementations§
Trait Implementations§
Source§impl Clone for AverageDrawdown
impl Clone for AverageDrawdown
Source§fn clone(&self) -> AverageDrawdown
fn clone(&self) -> AverageDrawdown
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AverageDrawdown
impl Debug for AverageDrawdown
Source§impl Indicator for AverageDrawdown
impl Indicator for AverageDrawdown
Source§fn update(&mut self, input: f64) -> Option<f64>
fn update(&mut self, input: f64) -> Option<f64>
Feed one new data point into the indicator and return the freshly computed
output, or
None if the indicator is still warming up.Source§fn reset(&mut self)
fn reset(&mut self)
Reset all internal state, leaving the indicator equivalent to a freshly
constructed instance with the same parameters.
Source§fn warmup_period(&self) -> usize
fn warmup_period(&self) -> usize
Number of inputs required before the first non-
None output can be produced.Auto Trait Implementations§
impl Freeze for AverageDrawdown
impl RefUnwindSafe for AverageDrawdown
impl Send for AverageDrawdown
impl Sync for AverageDrawdown
impl Unpin for AverageDrawdown
impl UnsafeUnpin for AverageDrawdown
impl UnwindSafe for AverageDrawdown
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>>
Run the indicator over a slice of inputs in order, returning one output (or
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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