Skip to content

Closing Auction Imbalance

Family: Flow surveillance

What it computes

Emits ClosingAuctionImbalanceTick ticks carrying window_start_ms, window_end_ms, buy_volume, sell_volume, total_volume, imbalance, n_prints off stock trade tape.

Available on the live, historical, and replay drives.

Methodology

Lee-Ready (1991) signed-volume imbalance over the pre-close auction window.

See the methodology overview for the citation index.

Inputs

Stock trade tape.

Key outputs

Window_start_ms, window_end_ms, buy_volume, sell_volume, total_volume, imbalance, n_prints. The full field set is in the tick table below.

Output schema (ClosingAuctionImbalanceTick)

The field / type / description table below is regenerated from the ClosingAuctionImbalanceTick 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 — the first post-close admission (or watermark) timestamp that triggered the seal.
window_start_msi32Window-start boundary (ms-of-day) — session_close_ms_of_day − window_ms.
window_end_msi32Window-close boundary (ms-of-day).
buy_volumei64Buyer-initiated share volume over the window.
sell_volumei64Seller-initiated share volume over the window.
total_volumei64Total classified share volume over the window — buy_volume + sell_volume. Indeterminate (zero-tick / first print) volume is excluded.
imbalancef64Signed-flow imbalance ratio (buy_volume − sell_volume) / total_volume. NaN when total_volume == 0.
n_printsi32Number of classified prints contributing to the imbalance.

Configuration (ClosingAuctionImbalanceParams)

Regenerated from the ClosingAuctionImbalanceParams 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.
venuesExchangeFilterExchange / venue admission policy.
window_msi32Length of the closing auction window in milliseconds. Defaults to [DEFAULT_WINDOW_MS] (300_000 ms — five minutes).
session_close_ms_of_dayi32Session-close boundary in milliseconds-of-day. Defaults to [DEFAULT_SESSION_CLOSE_MS] (57_600_000 — 16:00:00 ET).

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

Rust

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

use kairos::{Client, ClosingAuctionImbalanceRow};

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

let sub = client
    .live()
    .closing_auction_imbalance(["QQQ"])
    .on_event(|row: &ClosingAuctionImbalanceRow| {
        println!("imbalance={} total_volume={}", row.imbalance, row.total_volume)
    })?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }

Proprietary. All rights reserved.