pub struct LiquidationFeatures { /* private fields */ }Expand description
Liquidation Features — decomposes the long- and short-side liquidation notional carried by each tick into a small feature vector.
net = longLiquidation − shortLiquidation
total = longLiquidation + shortLiquidation
imbalance = net / total (0 when total == 0)Liquidation cascades are a perpetual-market-specific tail risk: a wave of
long liquidations forces market sells that beget more liquidations. Splitting
the flow into net, total and a bounded imbalance turns the raw venue feed
into model-ready features — total sizes the stress, imbalance (and its
sign) says which side is being flushed. A positive imbalance means longs are
being liquidated (downside cascade), a negative one shorts (upside squeeze).
Input = DerivativesTick, Output = LiquidationFeaturesOutput. Stateless;
ready after the first tick.
§Example
use wickra_core::{DerivativesTick, Indicator, LiquidationFeatures};
fn tick(long_liq: f64, short_liq: f64) -> DerivativesTick {
DerivativesTick::new(
0.0, 100.0, 100.0, 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, long_liq, short_liq, 0,
)
.unwrap()
}
let mut liq = LiquidationFeatures::new();
// 30 long vs 10 short liquidated: net 20, total 40, imbalance 0.5.
let out = liq.update(tick(30.0, 10.0)).unwrap();
assert_eq!(out.net, 20.0);
assert_eq!(out.total, 40.0);
assert_eq!(out.imbalance, 0.5);Implementations§
Trait Implementations§
Source§impl Clone for LiquidationFeatures
impl Clone for LiquidationFeatures
Source§fn clone(&self) -> LiquidationFeatures
fn clone(&self) -> LiquidationFeatures
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 LiquidationFeatures
impl Debug for LiquidationFeatures
Source§impl Default for LiquidationFeatures
impl Default for LiquidationFeatures
Source§fn default() -> LiquidationFeatures
fn default() -> LiquidationFeatures
Returns the “default value” for a type. Read more
Source§impl Indicator for LiquidationFeatures
impl Indicator for LiquidationFeatures
Source§type Input = DerivativesTick
type Input = DerivativesTick
Type of one input data point (typically
f64 for a price, or Candle / Tick).Source§type Output = LiquidationFeaturesOutput
type Output = LiquidationFeaturesOutput
Type of one output value.
Source§fn update(&mut self, tick: DerivativesTick) -> Option<LiquidationFeaturesOutput>
fn update(&mut self, tick: DerivativesTick) -> Option<LiquidationFeaturesOutput>
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 LiquidationFeatures
impl RefUnwindSafe for LiquidationFeatures
impl Send for LiquidationFeatures
impl Sync for LiquidationFeatures
impl Unpin for LiquidationFeatures
impl UnsafeUnpin for LiquidationFeatures
impl UnwindSafe for LiquidationFeatures
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