pub struct KyleLambda { /* private fields */ }Expand description
Kyle’s Lambda — estimated market impact coefficient.
Estimates how much the price moves per unit of signed order flow (volume imbalance). Computed as OLS slope of price change on signed volume:
λ = Cov(ΔP, ΔQ) / Var(ΔQ)
where ΔQ is signed volume (positive = buy-initiated, negative = sell-initiated).
Returns None until the window is full or if signed volume has zero variance.
§Example
use fin_primitives::microstructure::KyleLambda;
use rust_decimal_macros::dec;
let mut kl = KyleLambda::new(4).unwrap();
kl.update(dec!(0.10), dec!(200)).unwrap();
kl.update(dec!(0.05), dec!(100)).unwrap();
kl.update(dec!(-0.08), dec!(-150)).unwrap();
kl.update(dec!(0.12), dec!(250)).unwrap();
let lambda = kl.get(); // Some(estimated lambda)Implementations§
Source§impl KyleLambda
impl KyleLambda
Sourcepub fn update(
&mut self,
price_change: Decimal,
signed_volume: Decimal,
) -> Result<(), FinError>
pub fn update( &mut self, price_change: Decimal, signed_volume: Decimal, ) -> Result<(), FinError>
Records a price change and signed volume observation.
price_change:close_t - close_{t-1}(can be negative).signed_volume: net order flow (positive = buy pressure, negative = sell pressure).
§Errors
Returns FinError::InvalidInput if either value is non-finite.
Sourcepub fn sample_count(&self) -> usize
pub fn sample_count(&self) -> usize
Returns the number of samples buffered.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KyleLambda
impl RefUnwindSafe for KyleLambda
impl Send for KyleLambda
impl Sync for KyleLambda
impl Unpin for KyleLambda
impl UnsafeUnpin for KyleLambda
impl UnwindSafe for KyleLambda
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