Skip to content

MedRV

Family: Volatility

What it computes

Emits MedRvTick ticks carrying rv_total, medrv, jump_share off intraday tape (5m bars).

Available on the live, historical, and replay drives.

Methodology

Andersen / Dobrev / Schaumburg (2012) median realized variance with c_med = π / (6 − 4·√3 + π).

See the methodology overview for the citation index.

Inputs

Intraday tape (5m bars).

Key outputs

Rv_total, medrv, jump_share. The full field set is in the tick table below.

Output schema (MedRvTick)

The field / type / description table below is regenerated from the MedRvTick 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.
rv_totalf64Textbook realized variance RV = Σ rᵢ² over the rolling- window bars. Always finite past the first sealed bar — the consumer reads medrv / rv_total as the canonical jump- presence ratio (values below 1 flag a jump-contaminated window).
medrvf64Andersen / Dobrev / Schaumburg (2012) jump-robust median realized variance estimator. NaN with fewer than three bars (the triple-window kernel is undefined).
jump_sharef64Jump-presence ratio (rv_total − medrv) / rv_total — the institutional gauge of how much of the textbook realized variance the jump-robust estimator strips off. Bounded at [0, 1] past the cold-start guard. NaN with fewer than three bars or on a degenerate zero-variance window.
n_intraday_barsi32Count of intraday bars currently inside the rolling window — the ADS N parameter. Values below 3 flag the cold-start regime where medrv and jump_share stay NaN.

Configuration (MedRvParams)

Regenerated from the MedRvParams 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 — one US-equity session at the default 5-minute cadence).
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().medrv(["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()
  .medrv(["QQQ"])
  .onEvent((tick) => {
    console.log(tick);
  });

Rust

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

use kairos::{Client, MedrvRow};

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

let sub = client
    .live()
    .medrv(["QQQ"])
    .on_event(|row: &MedrvRow| println!("medrv={} jump_share={}", row.medrv, row.jump_share))?;

// ... later, to stop delivery ...
sub.unsubscribe();
# Ok(())
# }

Proprietary. All rights reserved.