pub struct Drawdown { /* private fields */ }Expand description
A finite drawdown value using the convention current / peak - 1.0, capped at 0.0.
Implementations§
Source§impl Drawdown
impl Drawdown
Sourcepub fn new(value: f64) -> Result<Self, DrawdownError>
pub fn new(value: f64) -> Result<Self, DrawdownError>
Creates a drawdown value.
§Errors
Returns DrawdownError::NonFinite for non-finite values and
DrawdownError::Positive for positive values.
Sourcepub fn from_peak_current(peak: f64, current: f64) -> Result<Self, DrawdownError>
pub fn from_peak_current(peak: f64, current: f64) -> Result<Self, DrawdownError>
Computes drawdown from a positive peak and non-negative current value.
§Errors
Returns DrawdownError when inputs are non-finite, the peak is not positive, or the
current value is negative.
Sourcepub fn maximum_from_values(values: &[f64]) -> Result<Self, DrawdownError>
pub fn maximum_from_values(values: &[f64]) -> Result<Self, DrawdownError>
Computes maximum drawdown over a simple price or equity series.
§Errors
Returns DrawdownError for empty series, invalid first peak, or invalid values.
Trait Implementations§
Source§impl PartialOrd for Drawdown
impl PartialOrd for Drawdown
impl Copy for Drawdown
impl StructuralPartialEq for Drawdown
Auto Trait Implementations§
impl Freeze for Drawdown
impl RefUnwindSafe for Drawdown
impl Send for Drawdown
impl Sync for Drawdown
impl Unpin for Drawdown
impl UnsafeUnpin for Drawdown
impl UnwindSafe for Drawdown
Blanket Implementations§
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