pub struct PainIndex { /* private fields */ }Expand description
Rolling Pain Index — Thomas Becker’s continuous-pain risk measure.
Input is treated as an equity-curve sample. The Pain Index is the mean
drawdown depth over the trailing window of period bars, expressed as a
non-negative fraction:
peak_t = running max over window up to t
dd_t = (peak_t − equity_t) / peak_t (0 if no drawdown)
PainIdx = mean(dd_t over window)Where Ulcer Index uses an RMS aggregation that punishes deep drawdowns disproportionately, the Pain Index uses a plain arithmetic mean. The two are normally similar; the Pain Index reads slightly lower on stresses with a few large drawdowns and similar elsewhere.
Each update is O(period).
Implementations§
Trait Implementations§
Source§impl Indicator for PainIndex
impl Indicator for PainIndex
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 PainIndex
impl RefUnwindSafe for PainIndex
impl Send for PainIndex
impl Sync for PainIndex
impl Unpin for PainIndex
impl UnsafeUnpin for PainIndex
impl UnwindSafe for PainIndex
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