Skip to main content

Module variance_swap

Module variance_swap 

Source
Expand description

Volatility derivatives: variance swaps (and the volatility-swap strike under GBM).

A variance swap pays notional * (realized variance - strike) at maturity, with realized variance the annualized mean of squared log returns (no mean subtraction — the market convention). Its fair strike is model-free by the log-contract replication (Demeterfi-Derman-Kamal-Zou 1999):

K_var = (2/T) * [ int_0^F P(K)/K^2 dK + int_F^inf C(K)/K^2 dK ]

with undiscounted OTM option prices struck off the forward. On a flat surface the integral collapses to sigma^2 exactly (the test checks to 1e-6); a skewed smile adds the convexity that makes variance strikes trade above ATM vol squared.

The volatility swap (paying realized vol) needs the distribution, not just the expectation: under GBM the exact fair strike is the chi-distribution mean sigma * sqrt(2/n) * Gamma((n+1)/2) / Gamma(n/2) — below sigma for finite sampling by Jensen.

Structs§

VarianceSwap
A (possibly seasoned) variance swap.
VarianceSwapData
JSON contract data ("product_type": "variance_swap").

Functions§

fair_corridor_variance_strike
Fair corridor variance strike: variance accrues only while the spot is inside [low, high] (Carr-Lewis), which truncates the replication integral to the corridor’s strikes: K_corr = (2/T) int_low^high Q(K)/K^2 dK. Corridors are exactly additive: adjacent corridors sum to the full variance strike (tested), and the full-line corridor reproduces fair_variance_strike.
fair_gamma_swap_strike
Fair gamma-swap strike: the spot-weighted variance (1/T) int (S_t/S_0) sigma_t^2 dt, replicated by the S ln S contract with a 1/K strike kernel:
fair_variance_strike
Model-free fair variance strike by the log-contract replication. smile(strike) -> implied vol; integration over ten ATM standard deviations of log-strike with a fine Simpson rule.
realized_corridor_variance
Realized leg of a corridor variance swap: squared returns accrue when the previous observation was inside [low, high] (the standard convention).
realized_gamma_variance
Realized leg of a gamma swap over a spot path: the annualized spot-weighted squared returns (A/n) sum (S_i/S_0) ln(S_i/S_{i-1})^2.
realized_variance
Annualized realized variance of a log-return series, market convention (mean not subtracted).
volatility_swap_strike_gbm
Exact fair volatility-swap strike under GBM with observations sampling dates: sigma sqrt(2/n) Gamma((n+1)/2)/Gamma(n/2), the mean of the chi distribution — strictly below sigma, converging to it as sampling densifies.