Skip to content

Garman Klass Explicit

Family: Volatility

What it computes

Emits GarmanKlassExplicitTick ticks carrying realized_vol, bar_variance, n_intraday_bars off stock trade tape (5m bars).

Available on the live, historical, and replay drives.

Methodology

Garman / Klass (1980) OHLC realized volatility σ²_GK = 0.5 · ln(H/L)² − (2·ln 2 − 1) · ln(C/O)² aggregated over a rolling per-bar (O, H, L, C) window.

See the methodology overview for the citation index.

Inputs

Stock trade tape (5m bars).

Key outputs

Realized_vol, bar_variance, n_intraday_bars. The full field set is in the tick table below.

Output schema (GarmanKlassExplicitTick)

The field / type / description table below is regenerated from the GarmanKlassExplicitTick 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) at emission time.
ms_of_dayi32Milliseconds since midnight ET at emission time.
realized_volf64Garman / Klass (1980) annualised realized volatility over the rolling-window per-bar (O, H, L, C) ladder. NaN with an empty FIFO.
bar_variancef64Garman / Klass (1980) per-bar variance averaged across the window (per-bar units, pre-annualisation). NaN with an empty FIFO. May be slightly negative under finite-sample variation when the open-close drift dominates the high-low range; the annualised vol is clamped at zero.
n_intraday_barsi32Count of sealed per-bar OHLC quadruples currently inside the rolling window.

Configuration (GarmanKlassExplicitParams)

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

FieldTypeDescription
contractsSecurityFilterContracts the subscription tracks. Stocks 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.
bar_interval_msi32Per-bar cadence in milliseconds. Defaults to [DEFAULT_BAR_INTERVAL_MS] (300_000 ms / 5 min).
window_barsi32Rolling-window length in bars. Defaults to [DEFAULT_WINDOW_BARS] (78).
min_emit_interval_msi32Minimum interval between consecutive emissions per symbol, in milliseconds. Defaults to [DEFAULT_MIN_EMIT_INTERVAL_MS] (60_000 ms). Set to 0 to publish on every sealed bar.

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

Rust

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

use kairos::{Client, GarmanKlassExplicitRow};

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

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

Proprietary. All rights reserved.