Appearance
Variance Ratio Test
Family: Microstructure
What it computes
Emits VarianceRatioTestTick ticks carrying lag_q, variance_ratio, z_statistic, var_r1, var_rq, n_intraday_bars off stock trade tape (1m bars).
Available on the live, historical, and replay drives.
Methodology
Lo / MacKinlay (1988) random-walk test VR(q) = Var(r_q) / (q · Var(r_1)) with the overlapping-sample null variance 2(2q−1)(q−1)/(3qN) (eq. 14) and unbiased overlap divisor (eq. 12a-12b).
See the methodology overview for the citation index.
Inputs
Stock trade tape (1m bars).
Key outputs
Lag_q, variance_ratio, z_statistic, var_r1, var_rq, n_intraday_bars. The full field set is in the tick table below.
Output schema (VarianceRatioTestTick)
The field / type / description table below is regenerated from the VarianceRatioTestTick 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. |
lag_q | i32 | Lag q the variance ratio was fit against. |
variance_ratio | f64 | Variance ratio VR(q) = Var(r_q) / (q · Var(r_1)). NaN with fewer than q + 1 bars or on a degenerate flat-tape window. |
z_statistic | f64 | Asymptotic Lo / MacKinlay z-statistic under the homoscedasticity-adjusted variance. NaN whenever variance_ratio is. |
var_r1 | f64 | Per-bar return sample variance Var(r_1). Surfaced even on the cold-start regime so the consumer can read the rolling-window intraday vol directly. |
var_rq | f64 | q-bar overlapping return variance Var(r_q), estimated with the Lo / MacKinlay (1988) unbiased overlap divisor (N − q + 1)(1 − q/N) and deviations measured against q · μ̂ (their eq. (12a)-(12b)). NaN with fewer than q + 1 bars. |
n_intraday_bars | i32 | Count of intraday bars currently inside the rolling window. |
Configuration (VarianceRatioTestParams)
Regenerated from the VarianceRatioTestParams 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] (60_000 ms / 1 min). |
lag_q | i32 | Lag window q — the multi-bar horizon over which the variance ratio is fit. Defaults to [DEFAULT_LAG_Q] (4). |
window_bars | i32 | Rolling-window length in bars. Defaults to [DEFAULT_WINDOW_BARS] (128). |
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().variance_ratio_test(["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()
.varianceRatioTest(["QQQ"])
.onEvent((tick) => {
console.log(tick);
});Rust
rust
// Cargo.toml:
// kairos = "0.1"
use kairos::{Client, VarianceRatioTestRow};
# fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect(("me@example.com", "secret"))?;
let sub = client
.live()
.variance_ratio_test(["QQQ"])
.on_event(|row: &VarianceRatioTestRow| println!("variance_ratio={} z_statistic={}", row.variance_ratio, row.z_statistic))?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }