Appearance
Sweep Clustering
Family: Flow surveillance
What it computes
Emits SweepClusteringTick ticks carrying buy_clusters, sell_clusters, total_clusters, buy_cluster_volume, sell_cluster_volume off stock trade tape.
Available on the live, historical, and replay drives.
Methodology
Rolling-window aggregator over Lee-Ready (1991) same-side print-burst clusters; companion to sweep_detector.
See the methodology overview for the citation index.
Inputs
Stock trade tape.
Key outputs
Buy_clusters, sell_clusters, total_clusters, buy_cluster_volume, sell_cluster_volume. The full field set is in the tick table below.
Output schema (SweepClusteringTick)
The field / type / description table below is regenerated from the SweepClusteringTick 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. |
buy_clusters | i32 | Rolling count of buyer-side clusters inside the aggregate window. |
sell_clusters | i32 | Rolling count of seller-side clusters inside the aggregate window. |
total_clusters | i32 | Total clusters inside the aggregate window. |
buy_cluster_volume | i64 | Total contracts in buyer-side clusters inside the window. |
sell_cluster_volume | i64 | Total contracts in seller-side clusters inside the window. |
Configuration (SweepClusteringParams)
Regenerated from the SweepClusteringParams Rust source — see the note above.
| Field | Type | Description |
|---|---|---|
contracts | SecurityFilter | Contracts the subscription tracks. Stock-only. |
conditions | ConditionPolicy | Trade-condition admission policy. |
venues | ExchangeFilter | Exchange / venue admission policy. |
cluster_window_ms | i32 | Cluster-window length in ms. Defaults to [DEFAULT_CLUSTER_WINDOW_MS] (200 ms). |
min_cluster_prints | i32 | Minimum consecutive same-side prints to count a cluster. Defaults to [DEFAULT_MIN_CLUSTER_PRINTS] (3). |
aggregate_window_ms | i32 | Aggregate-window length in ms. Defaults to [DEFAULT_AGGREGATE_WINDOW_MS] (60_000 ms — one minute). |
min_emit_interval_ms | i32 | Minimum 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().sweep_clustering(["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()
.sweepClustering(["QQQ"])
.onEvent((tick) => {
console.log(tick);
});Rust
rust
// Cargo.toml:
// kairos = "0.1"
use kairos::{Client, SweepClusteringRow};
# fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect(("me@example.com", "secret"))?;
let sub = client
.live()
.sweep_clustering(["QQQ"])
.on_event(|row: &SweepClusteringRow| println!("buy_clusters={} sell_clusters={}", row.buy_clusters, row.sell_clusters))?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }