Variance Swap

Calculate the fair strike of a variance swap up to every expiry from the option chain: the variance at which a swap on the stock’s realized variance is worth nothing today, replicated with the discrete strike weights of Demeterfi, Derman, Kamal and Zou (1999), and with a strike the value of a swap, also of one traded in the past.

A variance swap pays the variance the stock realizes up to maturity minus the strike; the fair strike is the price of a portfolio of out-of-the-money options that replicates the log contract, whose payoff grows with the realized variance whatever the path:

\[f(S) = \left(\frac{2}{T}\right) \left[\frac{S - S^{*}}{S^{*}} - \ln\left(\frac{S}{S^{*}}\right)\right]\] \[w(K_{i}) = \text{the change in the slope of}\; f \;\text{at}\; K_{i},\;\; \text{with } f \text{ linear between the strikes}\] \[\text{Fair Variance} = \left(\frac{2}{T}\right) \left[\ln\left(\frac{F}{S^{*}}\right) - \left(\frac{F}{S^{*}} - 1\right)\right] + e^{rT}\left[\sum w(K_{p}) P(K_{p}) + \sum w(K_{c}) C(K_{c})\right]\] \[\text{Fair Volatility} = \sqrt{\text{Fair Variance}}\] \[\text{Realized Variance} = \frac{252}{n} \sum \ln\left(\frac{S_{i}}{S_{i-1}}\right)^{2},\;\; \text{over the } n \text{ returns since trade\_date}\] \[\text{Value} = e^{- r (T - t)}\left[\frac{t}{T} \;\text{Realized Variance} + \frac{T - t}{T} \;\text{Fair Variance} - \text{Strike}^{2}\right]\]

with the forward price F and the boundary strike \(S^{*} = K_{0}\), the highest strike at or below it, from put-call parity as in the Cboe VIX methodology, puts below S* and calls above it. The Cboe Variance column is the VIX methodology’s variance of the same expiry (see get_model_free_implied_volatility): it discretises the same integral with the midpoint rule, so the two agree when the strikes are close together and the Fair Variance replicates the payoff at the quoted strikes exactly when they are not.

Also known as: variance swap rate, variance strike, fair variance, DDKZ replication.

Example · AAPL, ^SPX

Install the Finance Toolkit with pip install financetoolkit -U, then call get_variance_swap:

from financetoolkit import Toolkit

toolkit = Toolkit(["AAPL", "^SPX"], api_key="FINANCIAL_MODELING_PREP_KEY")

toolkit.options.get_variance_swap(
    number_of_expirations=2,
    strike=0.3,
    show_columns=["Forward Price", "Fair Variance", "Fair Volatility", "Cboe Variance", "Variance Swap Value"],
)

Which returns:

ItemForward PriceFair VarianceFair VolatilityCboe VarianceVariance Swap Value
('AAPL', '2026-11-30')355.820
('AAPL', '2026-12-02')356.021
('^SPX', '2026-11-30')7,325.8500.04320.20780.0432-0.0468
('^SPX', '2026-12-01')7,326.7000.05150.22700.0515-0.0385

4 rows

Parameters

get_variance_swap accepts the following parameters.

ParameterTypeDescriptionExample
expiration_dateslist[str] | NoneThe expiries to use, the maturities of the swaps. Defaults to None, the nearest number_of_expirations expiries.["2027-12-17", "2028-01-21"]
number_of_expirationsintThe number of nearest expiries to use when no dates are given, at least 1. Defaults to 4.4
strikefloat | NoneThe volatility strike of the swap as a decimal (0.25 for 25%), whose square is the variance strike. Defaults to None, which gives the fair strike only.None, which gives the fair strike only
trade_datestr | NoneThe date the swap was traded, whose returns since then count towards the realized variance. Requires a strike. Defaults to None, a swap traded today.None, a swap traded today
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the Toolkit’s rounding.2
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

  • Paper Demeterfi, K., Derman, E., Kamal, M. and Zou, J. (1999). “More Than You Ever Wanted to Know About Volatility Swaps.” Goldman Sachs Quantitative Strategies Research Notes.
  • Paper Carr, P. and Madan, D. (1998). “Towards a Theory of Volatility Trading.” In Volatility: New Estimation Techniques for Pricing Derivatives, Risk Books, 417-427.
  • Library Referenced against QuantLib’s ReplicatingVarianceSwapEngine
  • Library Referenced against FinancePy’s EquityVarianceSwap.fair_strike
  • Library Referenced against FinancePy’s EquityVarianceSwap.value
  • Library Shares similar logic as QuantLib’s VarianceSwap
Share