Skip to main content

KyleLambdaEstimate

Struct KyleLambdaEstimate 

Source
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: f64

OLS price-impact coefficient (price change per unit of signed order flow).

§r_squared: f64

R-squared of the OLS regression.

Implementations§

Source§

impl KyleLambdaEstimate

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for KyleLambdaEstimate

Source§

impl Debug for KyleLambdaEstimate

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.