Appearance
Realized Semi Variance
Family: Volatility
What it computes
Emits RealizedSemiVarianceTick ticks carrying rv_total, rv_plus, rv_minus, signed_asymmetry, downside_fraction off intraday tape (5m bars).
Available on the live, historical, and replay drives.
Methodology
Barndorff-Nielsen / Kinnebrock / Shephard (2010) RV⁺ / RV⁻ decomposition, Patton-Sheppard (2015) signed asymmetry.
See the methodology overview for the citation index.
Inputs
Intraday tape (5m bars).
Key outputs
Rv_total, rv_plus, rv_minus, signed_asymmetry, downside_fraction. The full field set is in the tick table below.
Output schema (RealizedSemiVarianceTick)
The field / type / description table below is regenerated from the RealizedSemiVarianceTick 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. |
rv_total | f64 | Total realized variance RV = Σ rᵢ² over the rolling-window bars. Always finite past the first sealed bar. |
rv_plus | f64 | Upside realized semivariance RV⁺ = Σ (max(rᵢ, 0))² — the textbook BNKS "good volatility" component. NaN with an empty FIFO. |
rv_minus | f64 | Downside realized semivariance RV⁻ = Σ (min(rᵢ, 0))² — the textbook BNKS "bad volatility" component. NaN with an empty FIFO. |
signed_asymmetry | f64 | Signed-jump-style asymmetry component RV⁺ − RV⁻ per Patton-Sheppard (2015). Positive values flag upside-asymmetric flow; negative values flag downside- asymmetric flow. NaN with an empty FIFO. |
downside_fraction | f64 | Downside fraction RV⁻ / RV — the institutional gauge of crash-side variance contribution, in [0, 1] past the constant-price guard. NaN on a constant-price window where RV = 0. |
n_intraday_bars | i32 | Count of intraday bars currently inside the rolling window — the BNKS N parameter. Values of 0 flag the cold-start regime where every variance column stays NaN. |
Configuration (RealizedSemiVarianceParams)
Regenerated from the RealizedSemiVarianceParams Rust source — see the note above.
| Field | Type | Description |
|---|---|---|
contracts | SecurityFilter | Contracts the subscription tracks. Stocks only — the analytic silently ignores option / index trades at the on_tick entry point. |
conditions | ConditionPolicy | Trade-condition admission policy applied to every print. |
venues | ExchangeFilter | Exchange / venue admission policy. |
bar_interval_ms | i32 | Per-bar cadence in milliseconds. Defaults to [DEFAULT_BAR_INTERVAL_MS] (300_000 ms / 5 min). |
window_bars | i32 | Rolling-window length in bars. Defaults to [DEFAULT_WINDOW_BARS] (78 — one US-equity session at the default 5-minute cadence). |
min_emit_interval_ms | i32 | Minimum 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().realized_semi_variance(["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()
.realizedSemiVariance(["QQQ"])
.onEvent((tick) => {
console.log(tick);
});Rust
rust
// Cargo.toml:
// kairos = "0.1"
use kairos::{Client, RealizedSemiVarianceRow};
# fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect(("me@example.com", "secret"))?;
let sub = client
.live()
.realized_semi_variance(["QQQ"])
.on_event(|row: &RealizedSemiVarianceRow| println!("rv_plus={} rv_minus={}", row.rv_plus, row.rv_minus))?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }