pub struct KyleLambdaEstimate {
pub lambda: f64,
pub r_squared: f64,
}Expand description
Kyle’s Lambda estimated via OLS regression of price changes on signed volume.
lambda = OLS slope of price_changes ~ signed_volumes.
r_squared = coefficient of determination of that regression (0 to 1).
§Example
use fin_primitives::microstructure::KyleLambdaEstimate;
let changes = vec![0.1, 0.2, -0.05, 0.15];
let volumes = vec![100.0, 200.0, -50.0, 150.0];
let est = KyleLambdaEstimate::estimate(&changes, &volumes);
assert!(est.lambda >= 0.0 || est.lambda < 0.0); // finite value
assert!((0.0..=1.0).contains(&est.r_squared));Fields§
§lambda: f64OLS price-impact coefficient (price change per unit of signed order flow).
r_squared: f64R-squared of the OLS regression.
Implementations§
Source§impl KyleLambdaEstimate
impl KyleLambdaEstimate
Sourcepub fn estimate(price_changes: &[f64], signed_volumes: &[f64]) -> Self
pub fn estimate(price_changes: &[f64], signed_volumes: &[f64]) -> Self
Estimate Kyle’s Lambda from slices of price changes and signed volumes.
Uses OLS: lambda = Cov(ΔP, Q) / Var(Q).
R-squared is computed as (Cor(ΔP, Q))^2.
Returns lambda = 0.0 and r_squared = 0.0 when there are fewer than 2
observations or when signed volume has zero variance.
Trait Implementations§
Source§impl Clone for KyleLambdaEstimate
impl Clone for KyleLambdaEstimate
impl Copy for KyleLambdaEstimate
Auto Trait Implementations§
impl Freeze for KyleLambdaEstimate
impl RefUnwindSafe for KyleLambdaEstimate
impl Send for KyleLambdaEstimate
impl Sync for KyleLambdaEstimate
impl Unpin for KyleLambdaEstimate
impl UnsafeUnpin for KyleLambdaEstimate
impl UnwindSafe for KyleLambdaEstimate
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