Appearance
Bid Ask Persistence
Family: Microstructure
What it computes
Emits BidAskPersistenceTick ticks carrying change_probability, persistence, posterior_variance, changes_in_window, quotes_in_window off stock NBBO quote tape.
Available on the live, historical, and replay drives.
Methodology
Bayer / Liesenfeld (2010) Bayesian Beta-Bernoulli posterior change-probability of the NBBO mid-quote over a rolling N-tick window under the Jeffreys (1946) Beta(0.5, 0.5) prior.
See the methodology overview for the citation index.
Inputs
Stock NBBO quote tape.
Key outputs
Change_probability, persistence, posterior_variance, changes_in_window, quotes_in_window. The full field set is in the tick table below.
Output schema (BidAskPersistenceTick)
The field / type / description table below is regenerated from the BidAskPersistenceTick 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. |
change_probability | f64 | Bayesian posterior change-probability of the NBBO mid-quote in the next admitted NBBO update given the trailing window flicker rate. Range [0, 1]. |
persistence | f64 | Persistence rate — 1 − change_probability. The institutional liquidity-stability reading the analytic is named for. Range [0, 1]. |
posterior_variance | f64 | Posterior variance — Var(p) = (α · β) / ((α + β)² · (α + β + 1)). Shrinks toward zero as the rolling window fills. |
changes_in_window | i32 | Count of mid-quote changes inside the rolling window. |
quotes_in_window | i32 | Count of admitted NBBO updates inside the rolling window. |
Configuration (BidAskPersistenceParams)
Regenerated from the BidAskPersistenceParams 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. |
window_quotes | u32 | Rolling-window size in admitted NBBO updates. Defaults to [DEFAULT_WINDOW_QUOTES] (100 quotes). |
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().bid_ask_persistence(["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()
.bidAskPersistence(["QQQ"])
.onEvent((tick) => {
console.log(tick);
});Rust
rust
// Cargo.toml:
// kairos = "0.1"
use kairos::{Client, BidAskPersistenceRow};
# fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect(("me@example.com", "secret"))?;
let sub = client
.live()
.bid_ask_persistence(["QQQ"])
.on_event(|row: &BidAskPersistenceRow| {
println!("persistence={} change_probability={}", row.persistence, row.change_probability)
})?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }