Implied volatility, arbitrage-free surfaces and local volatility
Invert option prices to implied volatility and study smile, risk-neutral density, SVI, surface arbitrage and Dupire local volatility.
After this lesson you can
- Invert prices to implied volatility robustly using safeguarded Newton steps and rational bounds.
- Describe smile, skew and term structure and relate them to risk-neutral tails and asymmetry.
- Extract risk-neutral density with Breeden-Litzenberger and diagnose negative densities.
- State and check calendar and butterfly no-arbitrage conditions in total variance.
- Fit constrained SVI slices and derive Dupire local volatility.
Before you start
A quote expressed as volatility
Implied volatility is the value of reproducing a European Black-Scholes price for fixed inputs . It is a price coordinate, not a claim that actual volatility is constant. For a call, positive vega makes price strictly increasing in , so a finite interior solution is unique.
Before inversion, check the bounds
Equality at the lower bound corresponds to ; the upper bound is a limit as , not a finite solution. Put bounds are and . Outside the bounds no compatible volatility exists; within a bid-ask very near intrinsic value, small vega makes inversion ill-conditioned. A rounded price can make several volatilities indistinguishable.
Newton updates , but tiny vega or a step outside the interval can make it fail. Keep a bracket around the root and use bisection if the Newton step is unsafe. The Brenner-Subrahmanyam approximation is a starting point near the money with zero rates and dividends, not an accurate formula at every strike. Jäckel develops specialized inversion methods; the lab implements a safeguarded method, not that algorithm.
From smile to density
The smile or skew describes how implied volatility changes with strike and maturity. Equity indices often show higher implied volatility at low strikes; jump asymmetry, demand for protection and leverage effects are possible mechanisms, not a single causal explanation. Compare quotes with the same maturity and forward, respecting bid-ask and times.
With deterministic discounting and sufficiently regular density under ,
The Breeden-Litzenberger formula expresses strike convexity: a negative density implies a negative-cost, nonnegative-payoff butterfly under the model’s assumptions and simultaneous prices. With discrete data, consider bid-ask intervals, nonuniform steps and measurement error; differentiating twice amplifies noise. Breeden and Litzenberger (1978) relate option prices to contingent state claims.
Total variance and surface constraints
With forward , use and . For deterministic carry curves, comparing normalized calls at the same shows that absence of calendar arbitrage requires nondecreasing in at fixed . Comparing unnormalized prices at fixed strike can confuse that result with the carry effect.
The reason is convexity: if is a martingale under the model assumptions, expected does not decrease with horizon by conditional Jensen. Normalized Black price at fixed strictly increases with ; hence price ordering implies total-variance ordering. If carry or numeraire is treated differently, normalization must be justified again.
For a smooth positive slice define
Surface no-arbitrage requires for nonnegative density and compatible temporal growth over the full domain. Global sufficiency also needs appropriate tail and boundary conditions; testing a finite grid does not certify wings or intermediate maturities. Red in the chart means failure at a sampled point, not a complete proof of arbitrage or its absence in the continuum.
SVI and local volatility
The SVI parameterization of a slice is
shifts the level, scales the wings, modulates asymmetry, shifts the center and smooths curvature. The condition guarantees nonnegativity of the slice minimum but not or compatibility across maturities. Fitting slices separately can cause crossings. SSVI couples slices through an ATM-variance parameterization and additional calendar and wing conditions; Gatheral and Jacquier give explicit conditions for constructing surfaces without static arbitrage.
For example, with and positive function , SSVI writes
For , one family of sufficient conditions in the paper requires , , and for all . These concern the full SSVI surface, not constraints automatically imposed by the lab’s slice fit. For use the appropriate limit of the calendar condition.
Dupire local volatility follows from the forward pricing equation. For constant rates and dividends and a sufficiently smooth surface,
The second equality uses forward and a time derivative at fixed . The denominator must be positive and numerator nonnegative; near zero, division and second derivatives amplify errors. Under suitable regularity and conditions, local diffusion reproduces marginals compatible with the call surface and is determined where density is positive. Other dynamic models can reproduce those marginals with different temporal dependence: the surface does not identify a unique dynamic across all model classes.
Lab: safeguarded inversion
The inversion routine reports quote status, handles limits and uses Newton only inside a bracketed root; other iterations use bisection. Tolerance is in price, so small vega limits recoverable accuracy of .
import numpy as np
from scipy.special import ndtr
from scipy.optimize import brentq
def bs(S,K,r,q,T,sigma,kind='call'):
S,K,r,q,T,sigma=np.broadcast_arrays(*[np.asarray(x,float) for x in (S,K,r,q,T,sigma)])
A=S*np.exp(-q*T); B=K*np.exp(-r*T); v=sigma*np.sqrt(T); safe=np.where(v>0,v,1.)
d1=(np.log(A/B)+.5*v*v)/safe; d2=d1-v
c=np.where(v>0,A*ndtr(d1)-B*ndtr(d2),np.maximum(A-B,0))
return c if kind=='call' else c-A+B
def implied(price,S,K,r,q,T,kind='call',tol=1e-11,maxiter=100):
P,S,K,r,q,T=np.broadcast_arrays(*[np.asarray(x,float) for x in (price,S,K,r,q,T)])
if kind not in ('call','put') or np.any(S<=0) or np.any(K<=0) or np.any(T<=0): raise ValueError('Entradas inválidas')
A=S*np.exp(-q*T); B=K*np.exp(-r*T); lower=np.maximum(A-B,0) if kind=='call' else np.maximum(B-A,0); upper=A if kind=='call' else B
scale=np.maximum(1.,np.maximum(A,B)); eps=tol*scale
outside=~np.isfinite(P)|(P<lower-eps)|(P>upper+eps); near_upper=~outside&(P>=upper-eps)
valid=~outside&~near_upper; at_lower=valid&(P<=lower+eps)
lo=np.zeros(P.shape); hi=np.full(P.shape,8.); sigma=np.clip((P-lower)*np.sqrt(2*np.pi)/(A*np.sqrt(T)),.2,2.)
result=np.full(P.shape,np.nan); result=np.where(at_lower,0.,result); iterations=np.zeros(P.shape,int); active=valid&~at_lower
bracket=bs(S,K,r,q,T,hi,kind)>=P; active &= bracket
for i in range(maxiter):
if not np.any(active): break
value=bs(S,K,r,q,T,sigma,kind); residual=value-P; done=active&(np.abs(residual)<=eps)
result=np.where(done,sigma,result); iterations=np.where(done,i+1,iterations); active &= ~done
lo=np.where(active&(residual<0),sigma,lo); hi=np.where(active&(residual>=0),sigma,hi)
v=sigma*np.sqrt(T); d1=(np.log(A/B)+.5*v*v)/np.where(v>0,v,1.); vega=A*np.exp(-.5*d1*d1)/np.sqrt(2*np.pi)*np.sqrt(T)
newton=sigma-residual/np.maximum(vega,1e-300); candidate=np.where((newton>lo)&(newton<hi)&(vega>1e-12),newton,(lo+hi)/2)
sigma=np.where(active,candidate,sigma)
status=np.where(at_lower,'límite cero',np.where(np.isfinite(result),'ok',np.where(outside,'fuera de cotas',np.where(near_upper,'cota superior o indistinguible','sin convergencia o intervalo'))))
return result,iterations,statusKs=np.array([60.,80.,90.,100.,110.,120.,140.]); vols=np.array([.15,.25,.5,1.]); K,V=np.meshgrid(Ks,vols); prices=bs(100,K,.03,.01,1,V)
iv,it,status=implied(prices,100,K,.03,.01,1); lower=np.maximum(100*np.exp(-.01)-K*np.exp(-.03),0)
identifiable=(prices-lower>1e-7)&(status=='ok'); ref=np.full(K.shape,np.nan)
for index in zip(*np.where(identifiable)):
ref[index]=brentq(lambda x: float(bs(100,K[index],.03,.01,1,x)-prices[index]),1e-9,8.)
print('estados',dict(zip(*np.unique(status,return_counts=True))),'casos identificables',int(identifiable.sum()))
print('máximo error frente a Brent',float(np.nanmax(np.abs(iv-ref))),'mediana iteraciones',float(np.median(it[identifiable])),'fracción con menos de 10',float(np.mean(it[identifiable]<10)))
bad,_,diagnostic=implied(np.array([-1.,101.,0.]),100,100,0,0,1); print('precios inválidos y límite',bad,diagnostic)
g=np.random.default_rng(281515); K=100*np.exp(g.uniform(-.4,.4,1000)); V=g.uniform(.12,.8,1000); T=g.uniform(.25,2.,1000)
prices=bs(100,K,.03,.01,T,V); iv,it,status=implied(prices,100,K,.03,.01,T); lower=np.maximum(100*np.exp(-.01*T)-K*np.exp(-.03*T),0); ok=(status=='ok')&(prices-lower>1e-7)
print('muestra adicional identificable',int(ok.sum()),'fracción con menos de 10',float(np.mean(it[ok]<10)),'máximo error frente a volatilidad generadora',float(np.max(np.abs(iv[ok]-V[ok]))))The iteration fraction is a result of the tested set, not a 99% promise for all quotes. Numerical equalities near intrinsic value are classified as a limit within tolerance and need not recover the original volatility.
The 0.2 floor on the initial guess is a heuristic to avoid starting with near-zero vega; it does not constrain the solution. In the 28-case grid all finished in fewer than ten iterations and maximum error versus Brent was . In the additional synthetic sample, 999 of 1000 finished in fewer than ten and maximum error versus generating volatility was ; their ranges are defined in the cell. Prices −1 and 101 are rejected for the ATM call and price zero is classified as the zero-volatility limit.
Lab: fitting and local-volatility repricing
We generate prices from a known mixture of two GBMs with the same forwards and volatilities 16% and 35%, weights 0.7 and 0.3. This is a synthetic mixture distribution, not real data or a simulation of one constant volatility. Add uniform price perturbation, fit SVI slices with constrained least squares and check and calendar on a finite grid. Total variance is linearly interpolated in time and spatial endpoints extended constantly for repricing: that extension is an additional numerical assumption.
from scipy.optimize import minimize
def svi(k,p):
a,b,rho,m,s=p; z=k-m; root=np.sqrt(z*z+s*s)
return a+b*(rho*z+root), b*(rho+z/root), b*s*s/root**3
def g_svi(k,p):
w,wk,wkk=svi(k,p); return (1-k*wk/(2*w))**2-.25*wk**2*(1/w+.25)+.5*wkk
g=np.random.default_rng(281501); maturities=np.array([.5,1.,2.]); strikes=np.linspace(75,130,23); ks=np.log(strikes/100); grid=np.linspace(-.6,.6,121); fitted=[]
for T in maturities:
true=.7*bs(100,strikes,0,0,T,.16)+.3*bs(100,strikes,0,0,T,.35)
noisy=np.clip(true+g.uniform(-.02,.02,len(strikes)),np.maximum(100-strikes,0)+1e-8,100-1e-8)
iv,_,status=implied(noisy,100,strikes,0,0,T); observed=iv*iv*T
if not np.all(status=='ok'): raise RuntimeError('Cotización sintética no identificable')
prev=fitted[-1] if fitted else None
def objective(p): return float(np.mean((svi(ks,p)[0]-observed)**2))
cons=[{'type':'ineq','fun':lambda p:svi(grid,p)[0]-1e-5},{'type':'ineq','fun':lambda p:g_svi(grid,p)-1e-5}]
if prev is not None: cons.append({'type':'ineq','fun':lambda p,prev=prev:svi(grid,p)[0]-svi(grid,prev)[0]-1e-6})
fit=minimize(objective,[.02*T,.04*T,-.2,0,.25],method='SLSQP',bounds=[(1e-5,.5),(1e-5,1),(-.95,.95),(-.6,.6),(.02,1)],constraints=cons,options={'maxiter':500,'ftol':1e-12})
if not fit.success: raise RuntimeError(fit.message)
fitted.append(fit.x); print('T',T,'RMSE w',round(np.sqrt(fit.fun),7),'mínimo g',round(float(g_svi(grid,fit.x).min()),6),'parámetros',np.round(fit.x,5))
print('mínimos de calendario en rejilla',[round(float(np.min(svi(grid,fitted[i+1])[0]-svi(grid,fitted[i])[0])),7) for i in range(2)])def local_vol(t,k):
k=np.asarray(k); t=max(t,1e-5)
if t<=maturities[0]:
w,wk,wkk=svi(k,fitted[0]); wt=w/maturities[0]; w*=t/maturities[0]; wk*=t/maturities[0]; wkk*=t/maturities[0]
else:
j=min(np.searchsorted(maturities,t)-1,len(maturities)-2); t0,t1=maturities[j:j+2]; u=(t-t0)/(t1-t0)
a=svi(k,fitted[j]); b=svi(k,fitted[j+1]); w=(1-u)*a[0]+u*b[0]; wk=(1-u)*a[1]+u*b[1]; wkk=(1-u)*a[2]+u*b[2]; wt=(b[0]-a[0])/(t1-t0)
den=(1-k*wk/(2*w))**2-.25*wk*wk*(1/w+.25)+.5*wkk
if np.any(wt<=0) or np.any(den<=0): raise ValueError('Dupire inválida en la rejilla')
return np.sqrt(wt/den)
g=np.random.default_rng(281502); N,steps=12000,160; dt=2/steps; logS=np.full(N,np.log(100.)); kgrid=np.linspace(-.6,.6,241); snapshots={}; clipped=0
for i in range(steps):
t=(i+.5)*dt; siggrid=local_vol(t,kgrid); raw=logS-np.log(100.); clipped+=int(np.sum((raw<kgrid[0])|(raw>kgrid[-1])))
vol=np.interp(raw,kgrid,siggrid); logS+=-.5*vol**2*dt+vol*np.sqrt(dt)*g.standard_normal(N)
if i+1 in (80,160): snapshots[(i+1)*dt]=np.exp(logS.copy())
for T in (1.,2.):
K=100.; sample=np.maximum(snapshots[T]-K,0); j=list(maturities).index(T); w=svi(np.array([0.]),fitted[j])[0][0]; fitted_call=float(bs(100,K,0,0,T,np.sqrt(w/T)))
print('T',T,'MC',round(sample.mean(),5),'EE',round(sample.std(ddof=1)/np.sqrt(N),5),'call ajustada',round(fitted_call,5))
print('fracción de estados fuera de rejilla',clipped/(N*steps))The test checks the cycle over a finite domain and discretization. Piecewise temporal interpolation, extension in k and Monte Carlo sampling add errors; a good fit at observed strikes does not validate the wings. If or the time derivative fails on the grid, the cell stops instead of taking a square root of a negative number.
In the run, total-variance RMSE for 0.5, 1 and 2 years was 0.0003435, 0.0002990 and 0.0003186; grid calendar minima were 0.0232616 and 0.0467100. For strike 100, local Monte Carlo gave 8.72273 with SE 0.14698 at one year and 12.38714 with SE 0.22233 at two, versus fitted prices 8.61007 and 12.15585. 2.92% of states per step fell outside the grid and used boundary extension; this limits validation and does not prove exact equality in the wings.
Public data: VIX is not strike volatility
VIX summarizes a portfolio of SPX options with maturity near 30 days according to the Cboe methodology. It is not the implied volatility of a particular call or data for directly fitting the synthetic slices above. The local cell queries the primary source and fixes the analysis date; public files may be revised.
import pandas as pd
url='https://cdn.cboe.com/api/global/us_indices/daily_prices/VIX_History.csv'
vix=pd.read_csv(url); vix['DATE']=pd.to_datetime(vix['DATE']); sample=vix[vix['DATE'].between('2026-11-11','2026-11-16')].sort_values('DATE')
print(sample[['DATE','CLOSE']].to_string(index=False))npm run lab and open the connection link.In the November 17, 2026 download, closes for the 11th, 12th, 13th and 16th were 17.49, 18.70, 19.30 and 22.91 index points. Source: Cboe, VIX history. These historical observations can change if the provider corrects its file.
Exercises
Step 1 of 3. What remains after one derivative in K?
Step 1 of 3. What does normalized Black price depend on at fixed k?
def implied_vol(price,S,K,r,q,T,kind):
raise NotImplementedError()Ideas to remember
Implied volatility represents a price and can be ill-conditioned when vega is small. Density, calendar and butterfly impose constraints across the full surface; a grid provides a partial diagnostic. Dupire differentiates twice and requires regularity: fitting and validating the domain is part of the calculation.