Skip to content

Quote Lifetime

Family: Microstructure

What it computes

Emits QuoteLifetimeTick ticks carrying side, bucket_index, bucket_lo_ms, bucket_hi_ms, count off stock NBBO quote tape.

Available on the live, historical, and replay drives.

Methodology

Per-side log10-spaced NBBO sealed-lifetime histogram across the bid and ask legs over the active session — per-leg decomposition of the top_book_persistence running mean for HFT quote-flicker diagnostics; flat-tick stream of 2 × bucket_count events per per-leg change, one per (side, bucket) cell.

See the methodology overview for the citation index.

Inputs

Stock NBBO quote tape.

Key outputs

Side, bucket_index, bucket_lo_ms, bucket_hi_ms, count. The full field set is in the tick table below.

Output schema (QuoteLifetimeTick)

The field / type / description table below is regenerated from the QuoteLifetimeTick 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. Identical across every per-snapshot event burst.
side&'static strQuote side this row describes — "bid" for the bid leg, "ask" for the ask leg.
bucket_indexu32Bucket index (0 = [0, bucket_unit_ms)).
bucket_lo_msi32Inclusive lower bound of the bucket in milliseconds.
bucket_hi_msi32Exclusive upper bound of the bucket in milliseconds. i32::MAX marks the open-ended terminal bucket.
counti32Number of sealed lifetimes that fell in this bucket inside the active session.

Configuration (QuoteLifetimeParams)

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

FieldTypeDescription
contractsSecurityFilterContracts the subscription tracks. Stock-only NBBO stream.
conditionsConditionPolicyTrade-condition admission policy applied to the NBBO bid-side condition byte.
venuesExchangeFilterExchange / venue admission policy.
bucket_unit_msi32Histogram bucket unit (ms). Defaults to [DEFAULT_BUCKET_UNIT_MS] (1 ms — the institutional HFT flicker resolution).
bucket_countu32Histogram bucket count. Defaults to [DEFAULT_BUCKET_COUNT] (6 log10-spaced cells).
min_emit_interval_msi32Minimum interval between consecutive emissions per symbol, in milliseconds. Defaults to [DEFAULT_MIN_EMIT_INTERVAL_MS] (1_000 ms / 1 Hz).

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().quote_lifetime(["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()
  .quoteLifetime(["QQQ"])
  .onEvent((tick) => {
    console.log(tick);
  });

Rust

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

use kairos::{Client, QuoteLifetimeRow};

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

let sub = client
    .live()
    .quote_lifetime(["QQQ"])
    .on_event(|row: &QuoteLifetimeRow| println!("side={} bucket_index={}", row.side, row.bucket_index))?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }

Proprietary. All rights reserved.