Appearance
Risk Neutral Density
Family: Volatility
What it computes
Emits RiskNeutralDensityTick ticks carrying per_strike density, integrated_mass off chain snapshot.
Available on the live and replay drives. The historical drive fails closed with KAIROS_ERR_HISTORICAL_UNWIRED until the relevant cache is hydrated externally.
Methodology
Breeden-Litzenberger (1978) q(K) = e^{rT} * d²C/dK² density via the three-point non-uniform-grid stencil on the listed call-mid strip (exact for quadratics on any strike spacing).
See the methodology overview for the citation index.
Inputs
Chain snapshot.
Key outputs
Per_strike density, integrated_mass. The full field set is in the tick table below.
Output schema (RiskNeutralDensityTick)
The field / type / description table below is regenerated from the RiskNeutralDensityTick 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 at emission time. |
expiration | i32 | Expiration YYYYMMDD for which the density was recovered. |
strikes_used | i32 | Count of interior strikes the second-difference admitted. |
integrated_mass | f64 | Total mass: trapezoidal integral of the recovered density over the admitted strike grid. A well-formed density integrates to approximately 1.0; deviations flag a sparse or arbitraged strip. |
per_strike | Vec<DensityPoint> | Per-strike density points, oldest-strike first. |
Configuration (RiskNeutralDensityParams)
Regenerated from the RiskNeutralDensityParams Rust source — see the note above.
| Field | Type | Description |
|---|---|---|
contracts | SecurityFilter | Underlying symbols the subscription tracks. |
conditions | ConditionPolicy | Trade-condition admission policy. Retained for surface consistency with the other vol analytics; the density kernel operates on the chain snapshot, not the live trade tape. |
venues | ExchangeFilter | Exchange / venue admission policy. Retained for surface consistency with the other vol analytics. |
daily_close | Arc<DailyCloseCache> | Boot-time hydrated daily-close history. The empty default is a placeholder — the analytic's per-strike density kernel consumes a chain snapshot rather than the daily-close history, but the cache slot is retained so the DefaultSpec hook can fail closed with the same documented cache-dependency error the other vol analytics surface. |
min_strikes | i32 | Minimum number of admitted strikes for the centred second-difference. Defaults to [DEFAULT_MIN_STRIKES] (5). |
risk_free_rate | f64 | Risk-free rate (annualised continuously compounded) for the e^{rT} discount unwind on the second derivative. 0.0 selects the institutional default of r = 0 — sufficient for the short-tenor equity-options regime where the per-tenor r·T factor is small. |
target_expiration | i32 | Target expiration YYYYMMDD. 0 selects the front expiration on the supplied chain snapshot (the per-symbol nearest-dated expiration with at least min_strikes admitted strikes). |
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().risk_neutral_density(["SPX"]).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()
.riskNeutralDensity(["SPX"])
.onEvent((tick) => {
console.log(tick);
});Rust
rust
// Cargo.toml:
// kairos = "0.1"
use kairos::{Client, RiskNeutralDensityRow};
# fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::connect(("me@example.com", "secret"))?;
let sub = client
.live()
.risk_neutral_density(["SPX"])
.on_event(|row: &RiskNeutralDensityRow| println!("strikes_used={} integrated_mass={}", row.strikes_used, row.integrated_mass))?;
// ... later ...
sub.unsubscribe();
# Ok(())
# }