Skip to content

Effective Spread

Family: Microstructure

What it computes

Emits EffectiveSpreadTick ticks carrying / M_t` aggregated over a rolling window against the standing NBBO mid off P_t − M_t.

Drive availability: trade + quote tape.

Methodology

Bessembinder (2003) effective half-spread `ES_t = 2·.

See the methodology overview for the citation index.

Inputs

P_t − M_t.

Key outputs

/ M_t` aggregated over a rolling window against the standing NBBO mid. The full field set is in the tick table below.

Output schema (EffectiveSpreadTick)

The field / type / description table below is regenerated from the EffectiveSpreadTick 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.
effective_half_spreadf64Bessembinder (2003) effective half-spread in dollars — `(1 / N) · Σ
effective_half_spread_bpsf64Bessembinder (2003) effective half-spread in basis points — `10_000 · (1 / N) · Σ
n_observationsi32Number of admitted prints contributing to the rolling estimate.

Configuration (EffectiveSpreadParams)

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

FieldTypeDescription
contractsSecurityFilterContracts the subscription tracks. Stock-only — the analytic silently ignores option / index trades at the on_tick entry point.
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). Set to 0 to surface every admission.

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

Rust

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

use kairos::{Client, EffectiveSpreadRow};

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

let sub = client
    .live()
    .effective_spread(["QQQ"])
    .on_event(|row: &EffectiveSpreadRow| {
        println!("effective_half_spread={} n_observations={}", row.effective_half_spread, row.n_observations)
    })?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }

Proprietary. All rights reserved.