Skip to content

Yang Zhang Vol

Family: Volatility

What it computes

Emits YangZhangVolTick ticks carrying realized_vol, bar_variance, overnight_variance, open_to_close_variance, rogers_satchell_variance, yang_zhang_k, n_intraday_bars off stock trade tape (5m bars).

Available on the live, historical, and replay drives.

Methodology

Yang / Zhang (2000) minimum-variance OHLC composite σ²_YZ = σ²_overnight + k · σ²_oc + (1 − k) · σ²_RS with the Yang-Zhang Theorem 3 minimum-variance weight k = 0.34 / (1.34 + (n+1)/(n−1)).

See the methodology overview for the citation index.

Inputs

Stock trade tape (5m bars).

Key outputs

Realized_vol, bar_variance, overnight_variance, open_to_close_variance, rogers_satchell_variance, yang_zhang_k, n_intraday_bars. The full field set is in the tick table below.

Output schema (YangZhangVolTick)

The field / type / description table below is regenerated from the YangZhangVolTick 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_volf64Yang / Zhang (2000) annualised realized volatility (composite). NaN with fewer than two bars.
bar_variancef64Yang / Zhang (2000) per-bar composite variance (pre- annualisation). NaN with fewer than two bars.
overnight_variancef64Overnight-gap variance component (sample variance of ln(O_i / C_{i-1}) over the window). NaN with fewer than two bars.
open_to_close_variancef64Open-to-close variance component (sample variance of ln(C_i / O_i)). NaN with fewer than two bars.
rogers_satchell_variancef64Rogers / Satchell (1991) intraday-range variance component (window mean of per-bar Rogers-Satchell readings). Finite past the first bar.
yang_zhang_kf64Yang / Zhang (2000) Theorem 3 minimum-variance weight k.
n_intraday_barsi32Count of sealed per-bar samples currently inside the rolling window.

Configuration (YangZhangVolParams)

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

FieldTypeDescription
contractsSecurityFilterContracts the subscription tracks. Stocks only.
conditionsConditionPolicyTrade-condition admission policy.
venuesExchangeFilterExchange / venue admission policy.
bar_interval_msi32Per-bar cadence in milliseconds.
window_barsi32Rolling-window length in bars.
min_emit_interval_msi32Minimum interval between consecutive emissions per symbol, in milliseconds. 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().yang_zhang_vol(["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()
  .yangZhangVol(["QQQ"])
  .onEvent((tick) => {
    console.log(tick);
  });

Rust

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

use kairos::{Client, YangZhangVolRow};

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

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

Proprietary. All rights reserved.