pub struct AverageDrawdown { /* private fields */ }Expand description
Rolling Average Drawdown.
Input is treated as an equity-curve sample. Over the trailing window of
period values the indicator identifies each distinct drawdown episode
— a stretch where equity is below the running peak — and reports the mean
of the episodes’ maximum depths:
episode opens when equity < running peak
episode closes when equity reaches a new peak (full recovery)
depth(episode) = (episode_peak − episode_trough) / episode_peak
AvgDD = mean(depth over episodes in window) (0 if no drawdown)This is the conventional “average drawdown” (mean depth across separate
drawdowns), which is distinct from the crate::PainIndex — the latter
averages the under-water fraction at every bar, so a long shallow
drawdown weighs more there than here. Output is a non-negative fraction
(0.05 ≈ 5 % mean episode depth).
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> BatchNanExt for T
impl<T> BatchNanExt for T
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