σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
Derivatives Pricing skill›Module 5 · Volatility surfaces and models›Topic 5.1·~1 hr 10 minAdvanced

Building a volatility surface and checking it for arbitrage

Skill positionModule 5 of 6 · Topic 1 of 6
5.1 Building a volatility surface and checking it for arbitrage
—Lab score— / 100Total XP—Streak—
Lecture0% read

8 min readCode examples: 5

  1. 01The smile and the SVI curve
  2. 02From prices to implied volatility
  3. 03Calendar and butterfly arbitrage
  4. 04A good surface and two bad ones on real data
  5. 05What you will build

Two options on the same index, with the same expiry, can have different implied volatilities: in our example 27.2% for a low strike and 20.2% for a high one. A table of these numbers is a volatility surface, and some tables cannot be right, because they would let someone make money with no risk. This topic builds a surface from a model, recovers it from prices, and finds the arbitrage in a surface that is wrong.

01

The smile and the SVI curve

Where we are. The last topic took the volatility of the asset as one number. The market does not: each strike and expiry has its own implied volatility, the volatility that, put in the Black-Scholes formula, gives the quoted price. Plotted against the strike, implied volatilities usually form a smile or a skew: low strikes are more expensive than high ones, because investors pay for protection against falls.

DefinitionTotal variance

The implied variance times the time to expiry, w = vol² × t. It is the natural unit for comparing expiries: for the same volatility, a longer option has more total variance. We measure the strike by the log-moneyness k = ln(K / F), where F is the forward price, so that k = 0 is at-the-money-forward.

Quotes are available at few strikes, so we need a curve that can be fitted. The SVI (stochastic volatility inspired) curve describes the total variance of one expiry with five numbers. It is popular because it has the right shape and a simple formula.

w(k) = a + b × ( ρ × (k − m) + √( (k − m)² + σ² ) )(1)a is the level, b the steepness of the wings, ρ the tilt (the skew), m the position of the lowest point and σ how rounded the bottom is

Worked example 1. *Problem:* a one-year smile has a = 0.024, b = 0.08, ρ = −0.6, m = 0 and σ = 0.2. What are the total variance and the volatility at k = −0.2, 0 and 0.2? *Plan:* evaluate the curve, then take the square root of w / t. *Steps:* below.

main.pyPython
k = np.array([-0.2, 0.0, 0.2])w = svi_variance(k, 0.024, 0.08, -0.6, 0.0, 0.2)1print(w.round(5).tolist())print(np.sqrt(w / 1.0).round(4).tolist())2
[0.05623, 0.04, 0.03703]
[0.2371, 0.2, 0.1924]
  1. 1Total variance at the three strikes.
  2. 2Volatility = sqrt(w / t) with t = 1.

*Check:* the total variances are 0.05623, 0.04 and 0.03703, so the volatilities are 23.71%, 20.00% and 19.24%. At k = 0 the variance is a + b × σ = 0.024 + 0.016 = 0.04, a 20% volatility. *What to notice:* with ρ = −0.6 the low strike is more expensive than the high one: this is the skew of equity indexes.

02

From prices to implied volatility

A surface is built in two directions. From volatilities to prices, we put each volatility in Black-Scholes: the strike is F × exp(k) and the volatility is √(w / t). From prices to volatilities, we need to solve bs_call(vol) = price for vol. There is no formula for this, but the price rises with the volatility, so a bisection always works: try the middle of an interval, and keep the half that contains the answer.

Worked example 2. *Problem:* a one-year at-the-money call with a 5% rate costs 10.4506 when the spot is 100. Another call, strike 120 and six months, costs 4.2419. What are their implied volatilities? *Plan:* use bisection. *Steps:* below.

main.pyPython
print(round(implied_vol(10.4506, 100.0, 100.0, 0.05, 1.0), 4))1print(round(implied_vol(4.2419, 100.0, 120.0, 0.05, 0.5), 4))2print(round(bs_call(100.0, 120.0, 0.05, 0.35, 0.5), 4))
0.2
0.35
4.2419
  1. 1The at-the-money call.
  2. 2The out-of-the-money call.

*Check:* the first volatility is 0.2, and the second 0.35: the price of a 35% volatility option at this strike is 4.2419, which is the third number. *What to notice:* 100 halvings of an interval of width 5 give a precision far below any price tick.

Worked example 3. *Problem:* build the whole surface for a spot of 100 and a rate of 3%, with four expiries (0.25, 0.5, 1, 2 years) and nine strikes (k from −0.3 to 0.3), with a 20% volatility level, then recover it from the prices. *Plan:* make one SVI smile per expiry, make the price grid, then the implied surface. *Steps:* below.

main.pyPython
params = []for t in EXPIRIES:    vt = 0.2 * (1 + 0.1 * t)    b = 2 * vt**2 * t    params.append((vt**2 * t - b * 0.2, b, -0.6, 0.0, 0.2))w = total_variance_grid(KS, params)prices = price_grid(100.0, 0.03, EXPIRIES, KS, w)surface = implied_surface(prices, 100.0, 0.03, EXPIRIES, KS)print(prices[1].round(4).tolist())1print(surface[1].round(4).tolist())print(surface[:, 4].round(4).tolist(), float(np.abs(surface - np.sqrt(w / EXPIRIES[:, None])).max()) < 1e-9)2
[26.3415, 19.1418, 11.9896, 8.7301, 5.9186, 3.709, 2.1469, 0.5781, 0.1216]
[0.2723, 0.249, 0.2269, 0.2175, 0.21, 0.2049, 0.2022, 0.202, 0.2059]
[0.205, 0.21, 0.22, 0.24] True
  1. 1Prices at the nine strikes of the six-month expiry.
  2. 2The ATM column and the round trip.

*Check:* the six-month prices fall from 26.3415 at the lowest strike to 0.1216 at the highest. The recovered six-month volatilities are 27.23% at k = −0.3, 21.00% at the forward and 20.59% at k = 0.3. The at-the-money volatility grows with the expiry, 20.5%, 21.0%, 22.0% and 24.0%, and the round trip is exact. *What to notice:* every expiry has the same shape of smile, scaled up by the longer time: the total variance of the two-year slice is 0.1152 at the forward, about five times the 0.0221 of the six-month slice, and it is the total variances that the calendar test compares.

03

Calendar and butterfly arbitrage

Two conditions make a surface free of static arbitrage. The first concerns expiries. If a longer option had *less* total variance than a shorter one at the same k, then buying the long one and selling the short one would cost nothing now and never lose: a calendar arbitrage. So total variance must not decrease with the expiry.

The second concerns strikes. A butterfly spread (buy one call at a low strike, sell two at the middle strike, buy one at a high strike) can never lose money, so its price must not be negative. As the strikes get closer together, its price per unit of width becomes the second derivative of the call price with respect to the strike, which is the risk-neutral density of the asset price (times the discount factor). A negative density is a butterfly arbitrage.

calendar: w(k, t₂) ≥ w(k, t₁) if t₂ > t₁, butterfly: density(K) = exp(r × t) × ∂²C / ∂K² ≥ 0(2)C is the call price as a function of the strike K; the second derivative is estimated from three neighbouring strikes, which need not be equally spaced

Worked example 4. *Problem:* take the good surface of example 3 and make two bad ones. In the first, the one-year smile is cut to 40% of its total variance. In the second, all smiles are made steeper and sharper (σ = 0.02, b four times larger). What do the two tests say? *Plan:* count the violations of each test. *Steps:* below.

main.pyPython
cut = [(a * 0.4, b * 0.4, r, m, s) if t == 1.0 else (a, b, r, m, s) for t, (a, b, r, m, s) in zip(EXPIRIES, params)]print(int(calendar_violations(total_variance_grid(KS, cut)).sum()), int(calendar_violations(w).sum()))1steep = []for t in EXPIRIES:    vt = 0.2 * (1 + 0.1 * t)    b = 8 * vt**2 * t    steep.append((vt**2 * t - b * 0.02, b, -0.6, 0.0, 0.02))grid = price_grid(100.0, 0.03, EXPIRIES, KS, total_variance_grid(KS, steep))for i, t in enumerate(EXPIRIES):    strikes = 100.0 * np.exp(0.03 * t + KS)    print(t, int(butterfly_violations(grid[i], strikes, 0.03, t).sum()), density(grid[i], strikes, 0.03, t).min().round(5))2
9 0
0.25 0 0.00444
0.5 0 0.00187
1.0 2 -0.00417
2.0 2 -0.01242
  1. 1Violations of the cut surface and of the good one.
  2. 2Butterfly violations and the lowest density, per expiry.

*Check:* the cut surface has 9 calendar violations, one at each strike, all between the six-month and the one-year expiry, and the good one has 0. In the steep surface the three-month and six-month slices are fine (lowest density 0.00444 and 0.00187), but the one-year and two-year slices have 2 violations each, with lowest densities −0.00417 and −0.01242. *What to notice:* a negative density sits next to a very high one (0.098 at the middle strike of the one-year slice): the smile is so sharp that the price curve is not convex.

No violation is not a proof

These tests look at a finite grid. A surface can pass on nine strikes and still fail between them or beyond the last one, where the wings matter. Real surfaces are also checked in the wings, and the SVI parameters are restricted (for example, b and ρ must keep the slopes of the wings below known limits) to keep them arbitrage-free by construction.

04

A good surface and two bad ones on real data

Worked example 5. *Problem:* put the real market into the example: for three days, use the SPY volatility of the last year as the volatility level and the 1-year Treasury yield as the rate, build the three surfaces, and run the tests. *Plan:* study makes the good, cut and steep surfaces on each day, recovers the good surface from its prices, and counts violations. *Steps:* below.

main.pyPython
data = load_data()out = study(data)1for date, row in out.items():    print(date, round(row["vol"], 4), [round(v, 4) for v in row["atm_vols"]], row["calendar_good"], row["calendar_cut"], row["butterfly_good"], row["butterfly_steep"])
2022-01-03 0.1298 [0.1331, 0.1363, 0.1428, 0.1558] 0 9 0 2
2023-07-03 0.1938 [0.1986, 0.2035, 0.2131, 0.2325] 0 9 0 4
2026-08-21 0.1291 [0.1323, 0.1355, 0.142, 0.1549] 0 9 0 2
  1. 1One result per date.

*Check:* the SPY volatility of the last year was 12.98%, 19.38% and 12.91%, and the at-the-money implied volatilities of the good surface rise with the expiry, from 13.3% to 15.6% in January 2022 and from 13.2% to 15.5% in August 2026. The round trip is exact to 1e-11. The good surface has no violations on any day; the cut surface has 9 calendar violations each time, and the steep surface has 2, 4 and 2 butterfly violations. *What to notice:* the day with the highest volatility, July 2023 (19.38%), has the most butterfly violations in the same steep smile: a sharper bend in the smile is a bigger step for the price curve to follow.

  • FunctionQuestion it answers
  • svi_variance(k, a, b, rho, m, sigma)What is the total variance at this log-moneyness?a + b (rho (k - m) + sqrt((k - m)^2 + sigma^2))
  • total_variance_grid(ks, params)What is the smile of every expiry?one SVI row per expiry
  • implied_vol(price, spot, strike, rate, t)Which volatility gives this price?bisection on the Black-Scholes price
  • price_grid(spot, rate, expiries, ks, total_var)What are the option prices of a surface?Black-Scholes at the forward strikes
  • implied_surface(prices, spot, rate, expiries, ks)Which surface do these prices imply?implied_vol at every point
  • calendar_violations(total_var, tol)Where does total variance fall with the expiry?differences between rows below minus tolerance
  • density(prices, strikes, rate, t)What density do the prices imply?second difference of the price in the strike
  • butterfly_violations(prices, strikes, rate, t, tol)Where is the density negative?density below minus tolerance
What the real data saysSPY volatility of the last year, 1-year Treasury yield, and made-up SVI smiles around them
SPY volatility, 3 Jan 202212.98 %rate 0.40 %
SPY volatility, 3 Jul 202319.38 %rate 5.43 %
SPY volatility, 21 Aug 202612.91 %rate 4.03 %
ATM volatility at 2 years, 21 Aug 202615.49 %3 months: 13.23 %
Butterfly violations of the steep surface2 / 4 / 2the good surface has none on any day
Calendar violations of the cut surface9on each of the three days

Key takeaways

  • Implied volatility is a price in other units. It is the volatility that makes Black-Scholes match the quote; bisection finds it because the price rises with the volatility.
  • Compare expiries in total variance. w = vol² × t at the same log-moneyness k must not fall as the expiry grows, or a calendar spread is free money.
  • The density must not be negative. The second derivative of the call price in the strike, times exp(r t), is the risk-neutral density; a negative value is a butterfly arbitrage.
  • Model the smile, then test it. SVI describes one expiry with five numbers; building prices from it and running the two tests is how a surface is checked.
Quick check
Your turn. At the same log-moneyness, the 6-month option has an implied volatility of 20% and the 1-year option 16%. Is there a calendar arbitrage?
Pick an answer.
05

What you will build

The lab follows the lecture. Tasks 1 and 2 build the SVI smiles. Tasks 3, 4 and 5 go back and forth between volatilities and prices. Task 6 is the calendar test, task 7 the density and task 8 the butterfly test. Task 9 runs a good surface and two bad ones on three real days.

Next topic: this surface is a static picture of today. The next one, Rough volatility: an overview, asks how volatility itself moves over time, and why recent research says that its paths are much rougher than the usual models assume.

Lab · what's graded

9 tasks · 100 pts
  • The SVI smile10 pts
  • A grid of smiles5 pts
  • Implied volatility10 pts
  • A grid of prices10 pts
  • The implied surface10 pts
  • Calendar arbitrage10 pts
  • The implied density10 pts
  • Butterfly arbitrage10 pts
  • A good surface and two bad ones25 pts
Explorer · lab-dv-07
▾ lab-dv-07
▾ data
…
bash · in-browser
learner@quantcraft:~/lab-dv-07$
Python not loaded yetPythonLn 1, Col 1Spaces: 4UTF-8

Reset this topic?

Everything in lab-dv-07 goes back to the starter files and the terminal is cleared. Your current solution will be lost — this can't be undone.

Will be reset
  • main.py → starter code
  • Terminal history and test output
  • Unsubmitted changes
Will be kept
  • Best lab score
  • Your XP and streak
  • Lecture progress and notes