Skip to content

Kyles Lambda

Family: Microstructure

What it computes

Emits KylesLambdaTick ticks carrying lambda, r_squared, n_obs off trade + Lee-Ready.

Available on the live, historical, and replay drives.

Methodology

Kyle (1985) OLS price-impact regression.

See the methodology overview for the citation index.

Inputs

Trade + Lee-Ready.

Key outputs

Lambda, r_squared, n_obs. The full field set is in the tick table below.

Output schema (KylesLambdaTick)

The field / type / description table below is regenerated from the KylesLambdaTick Rust source by docs-site/scripts/inject-doc-tables.ts on every npm run docs:build. Do not hand-edit between the sentinels.

FieldTypeDescription
symbolArc<str>Underlying symbol (interned).
datei32Trading-session date (YYYYMMDD).
ms_of_dayi32Milliseconds since midnight at emission time.
lambdaf64Kyle (1985) λ — dollars of price impact per signed share. Larger λ = thinner book / higher adverse-selection cost. NaN on a degenerate sample (Σ Q² = 0, or fewer than two distinct observations).
r_squaredf64No-intercept coefficient of determination 1 − Σ(ΔPᵢ − λ × Qᵢ)² / Σ(ΔPᵢ²). NaN on zero ΔP variance.
n_observationsi32Sample count inside the trailing window.
mean_signed_volumef64Mean signed volume (Σ Qᵢ) / n across the window. The Kyle no-intercept estimator assumes this is approximately zero in equilibrium — surfacing it lets desks audit the assumption.
mean_dpf64Mean trade-by-trade price change (Σ ΔPᵢ) / n across the window.

Configuration (KylesLambdaParams)

Regenerated from the KylesLambdaParams Rust source — see the note above.

FieldTypeDescription
contractsSecurityFilterContracts the subscription tracks. The Kyle estimator runs off the stock trade tape with the NBBO providing the Lee-Ready signing context.
conditionsConditionPolicyTrade-condition admission policy applied to every print.
venuesExchangeFilterExchange / venue admission policy.
window_msi32Rolling-window length in milliseconds. Defaults to [DEFAULT_WINDOW_MS] (60_000 ms).
min_emit_interval_msi32Minimum interval between consecutive emissions per symbol, in milliseconds. Defaults to [DEFAULT_MIN_EMIT_INTERVAL_MS] (1_000 ms).

Example

Python

python
import kairos_thetadata as kt

client = kt.Client.connect(kt.Credentials.from_env())

def on_event(row):
    print(row)

sub = client.live().kyles_lambda(["QQQ"]).on_event(on_event)
sub.wait(timeout_seconds=60.0)

TypeScript

typescript
import { Client, Credentials } from "kairos-thetadata";

const client = await Client.connect(Credentials.fromEnv());

await client
  .live()
  .kylesLambda(["QQQ"])
  .onEvent((tick) => {
    console.log(tick);
  });

Rust

rust
// Cargo.toml:
//   kairos = "0.1"

use kairos::{Client, KylesLambdaRow};

# fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect(("me@example.com", "secret"))?;

let sub = client
    .live()
    .kyles_lambda(["QQQ"])
    .on_event(|row: &KylesLambdaRow| println!("lambda={} r_squared={}", row.lambda, row.r_squared))?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }

Proprietary. All rights reserved.