Appearance
Microprice
Family: Microstructure
What it computes
Emits MicropriceTick ticks carrying microprice, mid, tilt, bid_size, ask_size off stock NBBO quote tape.
Available on the live, historical, and replay drives.
Methodology
Gatheral-Oomen (2010) depth-weighted mid microprice = (bid · ask_size + ask · bid_size) / (bid_size + ask_size) — short-horizon fair-value proxy under the standing NBBO; the Stoikov (2018) state-conditional micro-price is the designated upgrade.
See the methodology overview for the citation index.
Inputs
Stock NBBO quote tape.
Key outputs
Microprice, mid, tilt, bid_size, ask_size. The full field set is in the tick table below.
Output schema (MicropriceTick)
The field / type / description table below is regenerated from the MicropriceTick 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). Stock-only analytic — the symbol is the full user-facing identity. |
date | i32 | Trading-session date (YYYYMMDD). |
ms_of_day | i32 | Milliseconds since midnight at emission time. |
microprice | f64 | Depth-weighted mid (Gatheral-Oomen 2010): (bid · ask_size + ask · bid_size) / (bid_size + ask_size). The size-weighted fair value between the NBBO legs. |
mid | f64 | Arithmetic mid-price: (bid + ask) / 2. |
tilt | f64 | microprice − mid. Positive tilt = micro-price above mid (heavier bid-side depth → fair value pulled toward ask); negative tilt = micro-price below mid (heavier ask-side depth → fair value pulled toward bid). |
bid_size | i32 | Bid size at emission time (resting shares on the best bid). |
ask_size | i32 | Ask size at emission time (resting shares on the best ask). |
Configuration (MicropriceParams)
Regenerated from the MicropriceParams Rust source — see the note above.
| Field | Type | Description |
|---|---|---|
contracts | SecurityFilter | Contracts the subscription tracks. Stock-only NBBO stream — the filter must resolve to stock contracts. |
conditions | ConditionPolicy | Trade-condition admission policy applied to the NBBO bid-side condition byte; the same policy gates trade prints on related analytics so the filtered universe is consistent. |
venues | ExchangeFilter | Exchange / venue admission policy. |
min_emit_interval_ms | i32 | Minimum interval between consecutive emissions per symbol, in milliseconds. Defaults to [DEFAULT_MIN_EMIT_INTERVAL_MS] (0 ms — every admission emits). |
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().microprice(["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()
.microprice(["QQQ"])
.onEvent((tick) => {
console.log(tick);
});Rust
rust
// Cargo.toml:
// kairos = "0.1"
use kairos::{Client, MicropriceRow};
# fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect(("me@example.com", "secret"))?;
let sub = client
.live()
.microprice(["QQQ"])
.on_event(|row: &MicropriceRow| println!("microprice={} mid={}", row.microprice, row.mid))?;
// ... later, to stop delivery ...
sub.unsubscribe();
# Ok(())
# }