Appearance
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.
| Field | Type | Description |
|---|---|---|
symbol | Arc<str> | Underlying symbol (interned). |
date | i32 | Trading-session date (YYYYMMDD) at emission time. |
ms_of_day | i32 | Milliseconds since midnight ET at emission time. |
realized_vol | f64 | Yang / Zhang (2000) annualised realized volatility (composite). NaN with fewer than two bars. |
bar_variance | f64 | Yang / Zhang (2000) per-bar composite variance (pre- annualisation). NaN with fewer than two bars. |
overnight_variance | f64 | Overnight-gap variance component (sample variance of ln(O_i / C_{i-1}) over the window). NaN with fewer than two bars. |
open_to_close_variance | f64 | Open-to-close variance component (sample variance of ln(C_i / O_i)). NaN with fewer than two bars. |
rogers_satchell_variance | f64 | Rogers / Satchell (1991) intraday-range variance component (window mean of per-bar Rogers-Satchell readings). Finite past the first bar. |
yang_zhang_k | f64 | Yang / Zhang (2000) Theorem 3 minimum-variance weight k. |
n_intraday_bars | i32 | Count of sealed per-bar samples currently inside the rolling window. |
Configuration (YangZhangVolParams)
Regenerated from the YangZhangVolParams Rust source — see the note above.
| Field | Type | Description |
|---|---|---|
contracts | SecurityFilter | Contracts the subscription tracks. Stocks only. |
conditions | ConditionPolicy | Trade-condition admission policy. |
venues | ExchangeFilter | Exchange / venue admission policy. |
bar_interval_ms | i32 | Per-bar cadence in milliseconds. |
window_bars | i32 | Rolling-window length in bars. |
min_emit_interval_ms | i32 | Minimum 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(())
# }