Appearance
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.
| Field | Type | Description |
|---|---|---|
symbol | Arc<str> | Underlying symbol (interned). |
date | i32 | Trading-session date (YYYYMMDD). |
ms_of_day | i32 | Milliseconds since midnight at emission time. Identical across every per-snapshot event burst. |
side | &'static str | Quote side this row describes — "bid" for the bid leg, "ask" for the ask leg. |
bucket_index | u32 | Bucket index (0 = [0, bucket_unit_ms)). |
bucket_lo_ms | i32 | Inclusive lower bound of the bucket in milliseconds. |
bucket_hi_ms | i32 | Exclusive upper bound of the bucket in milliseconds. i32::MAX marks the open-ended terminal bucket. |
count | i32 | Number of sealed lifetimes that fell in this bucket inside the active session. |
Configuration (QuoteLifetimeParams)
Regenerated from the QuoteLifetimeParams Rust source — see the note above.
| Field | Type | Description |
|---|---|---|
contracts | SecurityFilter | Contracts the subscription tracks. Stock-only NBBO stream. |
conditions | ConditionPolicy | Trade-condition admission policy applied to the NBBO bid-side condition byte. |
venues | ExchangeFilter | Exchange / venue admission policy. |
bucket_unit_ms | i32 | Histogram bucket unit (ms). Defaults to [DEFAULT_BUCKET_UNIT_MS] (1 ms — the institutional HFT flicker resolution). |
bucket_count | u32 | Histogram bucket count. Defaults to [DEFAULT_BUCKET_COUNT] (6 log10-spaced cells). |
min_emit_interval_ms | i32 | Minimum 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(())
# }