pub struct SterlingRatio { /* private fields */ }Expand description
Sterling Ratio over a trailing window of period returns.
equity_t = Π_{i<=t} (1 + return_i) (compounded curve)
peak_t = max_{s<=t} equity_s
dd_t = (peak_t − equity_t) / peak_t (fractional drawdown, >= 0)
Sterling = mean(returns) / mean(dd_t)The Sterling Ratio rewards return per unit of typical pain: it divides the
average per-period return by the average drawdown experienced along the
compounded equity curve. Of the three drawdown-based ratios Wickra ships it is
the gentlest on outliers — averaging the drawdowns means one deep crater does
not dominate the way it does in the BurkeRatio (which
sums squared drawdowns) or the MartinRatio (which uses
the root-mean-square percentage drawdown). A window that never draws down has
zero average drawdown and the indicator reports 0.0.
The first value lands after period returns; each update rebuilds the equity
curve over the window (O(period)), which is O(1) in the length of the overall
series.
§Example
use wickra_core::{Indicator, SterlingRatio};
let mut indicator = SterlingRatio::new(12).unwrap();
let mut last = None;
for i in 0..24 {
last = indicator.update((f64::from(i) * 0.5).sin() * 0.05);
}
assert!(last.is_some());Implementations§
Source§impl SterlingRatio
impl SterlingRatio
Trait Implementations§
Source§impl Clone for SterlingRatio
impl Clone for SterlingRatio
Source§fn clone(&self) -> SterlingRatio
fn clone(&self) -> SterlingRatio
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 SterlingRatio
impl Debug for SterlingRatio
Source§impl Indicator for SterlingRatio
impl Indicator for SterlingRatio
Source§fn update(&mut self, ret: f64) -> Option<f64>
fn update(&mut self, ret: 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 SterlingRatio
impl RefUnwindSafe for SterlingRatio
impl Send for SterlingRatio
impl Sync for SterlingRatio
impl Unpin for SterlingRatio
impl UnsafeUnpin for SterlingRatio
impl UnwindSafe for SterlingRatio
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> 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
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