pub struct FundingRateZScore { /* private fields */ }Expand description
Funding Rate Z-Score — the latest funding rate expressed in standard
deviations from its rolling mean over the trailing window of window ticks.
zScore = (fundingRate − mean) / population_stddev over the last `window` ticksA reading of +2 means funding is two standard deviations richer than its
recent norm — an unusually crowded long, a contrarian fade signal; −2 is
the mirror. Normalising the funding rate this way makes funding extremes
comparable across regimes and assets. A window with zero dispersion (a flat
funding series) yields 0. The indicator warms up for window ticks, then
emits the rolling z-score, maintained in O(1) per tick.
Input = DerivativesTick, Output = f64.
§Example
use wickra_core::{DerivativesTick, FundingRateZScore, Indicator};
fn tick(rate: f64) -> DerivativesTick {
DerivativesTick::new(rate, 100.0, 100.0, 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0)
.unwrap()
}
let mut z = FundingRateZScore::new(2).unwrap();
assert_eq!(z.update(tick(0.001)), None);
// Window [0.001, 0.003]: mean 0.002, population stddev 0.001 -> (0.003 - 0.002) / 0.001 = 1.
assert!((z.update(tick(0.003)).unwrap() - 1.0).abs() < 1e-9);Implementations§
Trait Implementations§
Source§impl Clone for FundingRateZScore
impl Clone for FundingRateZScore
Source§fn clone(&self) -> FundingRateZScore
fn clone(&self) -> FundingRateZScore
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 FundingRateZScore
impl Debug for FundingRateZScore
Source§impl Indicator for FundingRateZScore
impl Indicator for FundingRateZScore
Source§type Input = DerivativesTick
type Input = DerivativesTick
Type of one input data point (typically
f64 for a price, or Candle / Tick).Source§fn update(&mut self, tick: DerivativesTick) -> Option<f64>
fn update(&mut self, tick: DerivativesTick) -> 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 FundingRateZScore
impl RefUnwindSafe for FundingRateZScore
impl Send for FundingRateZScore
impl Sync for FundingRateZScore
impl Unpin for FundingRateZScore
impl UnsafeUnpin for FundingRateZScore
impl UnwindSafe for FundingRateZScore
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