Local Volatility Surface

Calculate the Dupire (1994) local volatility surface: the volatility of the stock at each price and time that reproduces the SVI or SSVI implied volatility surface fitted to the option chains (see get_volatility_surface).

The local volatility \(\sigma_{\text{loc}} (K , T)\) is the volatility, as a function of the price of the underlying and the time, of the only diffusion \(dS / S = (r - q) dt + \sigma_{\text{loc}} (S , t) dW\) that reprices every European option of the surface. Where the implied volatility at a strike is an average of the volatility along the paths to expiration, the local volatility is the instantaneous volatility the market prices for the moment the underlying stands at K at time T. It is the input of local volatility models for pricing path-dependent options consistently with the smile, and it shows the skew more steeply than the implied volatility (about twice as steep near the money).

The formula is as follows:

\[\sigma_{loc}^{2}(k,\; T) = \frac{\frac{\partial w}{\partial T}}{g(k)}\] \[g(k) = 1 - \frac{k}{w} \cdot \frac{\partial w}{\partial k} + \frac{1}{4} \cdot \left(- \frac{1}{4} - \frac{1}{w} + \frac{k^{2}}{w^{2}}\right) \cdot \left(\frac{\partial w}{\partial k}\right)^{2} + \frac{\frac{1}{2} \cdot \text{∂}^{2} w}{\partial k^{2}}\]

Where w(k, T) is the total implied variance (implied volatility squared times the time to expiration T) of the fitted surface, \(k = \ln (K / F_{T})\) the log-moneyness with \(F_{T}\) the forward price of the expiry. The derivatives in k are analytic per slice and \(\partial w / \partial T\) is taken at fixed k by finite differences between the expiries (three-point for unequal spacing at the inner expiries, one-sided at the first and the last), so the surface needs at least two expiries. The local volatility exists where \(g (k) > 0\) (no butterfly arbitrage) and \(\partial w / \partial T \geq 0\) (no calendar-spread arbitrage) and is NaN elsewhere, which SSVI avoids by construction where the at-the-money variance rises with the expiry.

The strikes are an evenly spaced grid around the price of the underlying quoted with the chains, from (1 - strike_price_range) to (1 + strike_price_range) times it, the same for every expiry. The forward price is \(F_{T} = S \cdot e^{(r - q) \cdot T}\) with the continuously compounded rate r and yield q.

See: Dupire, B. (1994), “Pricing with a smile”, Risk, 7(1), 18-20; Gatheral, J. (2006), “The Volatility Surface: A Practitioner’s Guide”, Wiley, eq. 1.10; and Gatheral, J., & Jacquier, A. (2014), “Arbitrage-free SVI volatility surfaces”, Quantitative Finance, 14(1), 59-71.

Also known as: Dupire local volatility, local vol surface.

Example · JPM

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

from financetoolkit import Toolkit

toolkit = Toolkit(["JPM"], api_key="FINANCIAL_MODELING_PREP_KEY")

local_volatility = toolkit.options.get_local_volatility_surface(
    method="ssvi", number_of_expirations=4
)

local_volatility.loc["JPM"]

Which returns:

Parameters

get_local_volatility_surface accepts the following parameters.

ParameterTypeDescriptionExample
expiration_dateslist[str] | NoneThe expiration dates to build the surface over, at least two. Defaults to None, meaning the first number_of_expirations expiration dates at least one calendar day away (those every ticker lists, if they share any).["2027-12-17", "2028-01-21"]
put_optionboolWhether to fit the implied volatility of the put options instead of the call options. Defaults to False.True
risk_free_ratefloatThe risk free rate to use for the calculation. Defaults to None, which uses the Toolkit’s risk-free rate on the pricing date: the 10-year Treasury yield unless the Toolkit’s risk_free_rate parameter selects ‘13w’, ‘5y’ or ‘30y’, converted from its semi-annual bond-equivalent quote to continuous compounding. A rate passed here is used as given, as a continuously compounded rate.0.04
dividend_yieldfloatThe dividend yield to use for the calculation. Defaults to None, which uses the dividend yield on the pricing date (the dividends of the 365 days up to it relative to its close, as the continuously compounded ln(1 + q)). A given value is used as a continuous yield.0.02
number_of_expirationsintThe number of near-term expiration dates when expiration_dates is not given. Defaults to 6.4
outlier_thresholdfloatThe number of median absolute deviations from the median implied volatility beyond which a quote is treated as an outlier and dropped before fitting. Defaults to 5.0.3.0
methodstrThe implied volatility surface to start from. Options are: “svi” (raw SVI per expiry), “ssvi” (SSVI across the expiries). Defaults to “svi”."svi"
strike_price_rangefloatThe range of strikes, as a fraction of the price of the underlying in each direction. Defaults to 0.25, from 75% to 125%.0.1
number_of_strikesintThe number of strikes in the grid. Defaults to 11.100
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).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

Share