Skip to content

Tick Rule Imbalance

Family: Microstructure

What it computes

Emits TickRuleImbalanceTick ticks carrying imbalance, uptick_volume, downtick_volume, total_volume, n_classified off trade tape.

Available on the live, historical, and replay drives.

Methodology

Easley / O'Hara (1987) tick-rule signed-volume imbalance (uptick_volume − downtick_volume) / total_volume over a rolling print-count window.

See the methodology overview for the citation index.

Inputs

Trade tape.

Key outputs

Imbalance, uptick_volume, downtick_volume, total_volume, n_classified. The full field set is in the tick table below.

Output schema (TickRuleImbalanceTick)

The field / type / description table below is regenerated from the TickRuleImbalanceTick 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.
imbalancef64Signed-volume imbalance ratio (uptick_volume − downtick_volume) / total_volume. NaN when total_volume == 0.
uptick_volumei64Buyer-initiated share volume over the rolling window.
downtick_volumei64Seller-initiated share volume over the rolling window.
total_volumei64Total classified share volume over the rolling window — uptick_volume + downtick_volume. Indeterminate (zero-tick / first print) volume is excluded.
n_classifiedi32Number of classified prints contributing to the rolling window.

Configuration (TickRuleImbalanceParams)

Regenerated from the TickRuleImbalanceParams 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_printsi32Rolling-window length in admitted prints. Defaults to [DEFAULT_WINDOW_PRINTS] (100 prints).
min_emit_interval_msi32Minimum interval between consecutive emissions per symbol, in milliseconds. Defaults to [DEFAULT_MIN_EMIT_INTERVAL_MS] (1_000 ms).

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

Rust

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

use kairos::{Client, TickRuleImbalanceRow};

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

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

Proprietary. All rights reserved.