On 21 August 2026 SPY's volatility over the last month was 12.8%, over the last year 12.9%, and over six months 14.2%. A single number cannot price every option, because the market quotes a different volatility for each strike and each expiry. Here the quotes come from a smile on top of those real volatilities (the course has no option quotes), and a surface built from them gives 12.85% for a strike 5% above the spot in nine months. A six-month put struck 10% below the spot costs 8.42 with the surface and only 4.15 with one flat volatility: the smile adds 4.27. This topic builds the surface, checks it, and makes the engine read from it.
From prices to a grid of volatilities
Where we are. In topic 5 you found the implied volatility of one quote. A market has hundreds of quotes: a call for each strike and each expiry. Turn each price into its implied volatility and you get a grid with the strikes in one direction and the expiries in the other: an implied volatility surface. If Black-Scholes-Merton were true the grid would be flat. It never is: volatility is higher for low strikes (a skew, because people pay for protection against a fall) and it changes with the expiry (a term structure).
Volatility alone is awkward to compare across expiries, because a year of 20% is more uncertainty than a month of 20%. The better measure is the total variance, σ² × T: the variance of the log-price up to expiry. It grows with the expiry, and it is the quantity that is interpolated between expiries.
Worked example 1. *Problem:* the spot is 100, the rate 5% and the dividend yield 2%. A surface has volatilities [0.26, 0.20, 0.17] at the strikes 90, 100 and 110 for a 6-month expiry, and [0.25, 0.20, 0.175] for a 1-year expiry. Make the call prices, recover the volatilities from them, and find their total variances. *Plan:* use bsm_price, implied_vol_grid and total_variance. *Steps:* below.
strikes, expiries = [90.0, 100.0, 110.0], [0.5, 1.0]vols = [[0.26, 0.20, 0.17], [0.25, 0.20, 0.175]]prices = [[bsm_price(100.0, k, 0.05, 0.02, v, e, "call") for k, v in zip(strikes, row)] for row, e in zip(vols, expiries)]1print([[round(p, 4) for p in row] for row in prices])grid = implied_vol_grid(prices, strikes, expiries, 100.0, 0.05, 0.02)2print([[round(v, 5) for v in row] for row in grid])3print([[round(w, 5) for w in row] for row in total_variance(grid, expiries)])
[[13.8632, 6.3076, 1.8659], [16.6358, 9.227, 4.2424]] [[0.26, 0.2, 0.17], [0.25, 0.2, 0.175]] [[0.0338, 0.02, 0.01445], [0.0625, 0.04, 0.03062]]
- 1Prices from the volatilities we chose.
- 2Back from the prices to volatilities.
- 3Volatility squared times the expiry.
*Check:* the prices are 13.8632, 6.3076 and 1.8659 for 6 months, and 16.6358, 9.227 and 4.2424 for 1 year; the recovered volatilities are the ones we started from, to five decimals. The total variances are 0.0338, 0.02 and 0.01445 for 6 months and 0.0625, 0.04 and 0.03062 for 1 year: every strike has more total variance at the longer expiry. *What to notice:* the 1-year at-the-money price 9.227 is the number of topic 5; the surface is that topic repeated on a grid.
A surface must not allow arbitrage
Quotes can be inconsistent, because they come from different dealers or are stale. A surface built on them must be checked before it is used, since a price taken from a surface that allows arbitrage can be exploited. Two checks are standard. The calendar check: at the same strike, total variance cannot fall as the expiry grows, or a long-dated option would be worth less than a short-dated one. The butterfly check: at one expiry the call price must be a convex function of the strike. Convex means that the slope (p[j] − p[j−1]) ÷ (k[j] − k[j−1]) between strikes rises as the strike rises. If it falls, a butterfly (buy the strikes on the two sides, sell two of the middle strike) would cost a negative amount and pay a non-negative one.
Worked example 2. *Problem:* check the surface of example 1 for both kinds of arbitrage. Then lower the 1-year volatility at the 90 strike to 18%, and check the calendar again. Finally add 3.0 to the price of the 1-year call at 100, and check the butterfly. *Plan:* use calendar_violations and butterfly_violations. *Steps:* below.
strikes, expiries = [90.0, 100.0, 110.0], [0.5, 1.0]vols = [[0.26, 0.20, 0.17], [0.25, 0.20, 0.175]]prices = [[bsm_price(100.0, k, 0.05, 0.02, v, e, "call") for k, v in zip(strikes, row)] for row, e in zip(vols, expiries)]print(calendar_violations(vols, expiries), butterfly_violations(prices, strikes))1bad = [[0.26, 0.20, 0.17], [0.18, 0.20, 0.175]]print(calendar_violations(bad, expiries), [round(w, 4) for w in total_variance(bad, expiries)[1]])2high = [list(row) for row in prices]high[1][1] += 3.0print(round(high[1][1], 3), butterfly_violations(high, strikes))3
[] [] [(1, 0)] [0.0324, 0.04, 0.0306] 12.227 [(1, 1)]
- 1The clean surface: no violations.
- 2A longer expiry with less total variance at the first strike.
- 3A price that is too high in the middle.
*Check:* the clean surface has no violations: [] []. With the 1-year volatility at 90 lowered to 18%, the total variance there is 0.0324, below the 0.0338 of the 6-month, and the check returns [(1, 0)]: expiry 1, strike 0; the 1-year total variances are 0.0324, 0.04 and 0.0306. With the 1-year at-the-money call at 12.227, the check returns [(1, 1)]: the slope to the left of the 100 strike, −0.44, is now above the slope to the right, −0.80. *What to notice:* a violation is reported at the place where the data are inconsistent; fixing it means going back to the quotes.
Interpolating a surface
A pricing engine needs the volatility at any strike and expiry, not only at the grid points. Interpolate in two steps. First, for each expiry in the grid, read the volatility at the strike by linear interpolation between the neighbouring strikes, flat outside the grid. Second, interpolate across expiries, but not in volatility: in total variance, linearly, and then convert back with σ = √(w ÷ T). This is the convention of QuantLib's BlackVarianceSurface. Interpolating the volatility itself would give too little variance in the middle; total variance grows in a straight line between two expiries for a constant volatility rate. Before the first expiry and after the last, the surface keeps the volatility of the nearest expiry.
Worked example 3. *Problem:* use the surface of example 1 and find the volatility at (strike, expiry) of (100, 0.75), (95, 0.75), (100, 0.25), (120, 2.0), (105, 1.0) and (95, 0.5). Then take a flat 20% surface at 6 months and a flat 30% surface at 1 year, and compare the volatility at 9 months with the average of the volatilities. *Plan:* use surface_vol. *Steps:* below.
strikes, expiries = [90.0, 100.0, 110.0], [0.5, 1.0]vols = [[0.26, 0.20, 0.17], [0.25, 0.20, 0.175]]for k, t in ((100.0, 0.75), (95.0, 0.75), (100.0, 0.25), (120.0, 2.0), (105.0, 1.0), (95.0, 0.5)): print(k, t, round(surface_vol(strikes, expiries, vols, k, t), 5))1print(round(surface_vol(strikes, expiries, [[0.20] * 3, [0.30] * 3], 100.0, 0.75), 5), 0.25)2
100.0 0.75 0.2 95.0 0.75 0.22668 100.0 0.25 0.2 120.0 2.0 0.175 105.0 1.0 0.1875 95.0 0.5 0.23 0.2708 0.25
- 1Six points on and off the grid.
- 2Total variance, not volatility, is interpolated.
*Check:* the six volatilities are 0.2, 0.22668, 0.2, 0.175, 0.1875 and 0.23. At (100, 0.75) both expiries say 20%, so the surface says 20%. At (95, 0.75) the strike is halfway between the nodes of 90 and 100, so the smile gives 23% at 6 months and 22.5% at 1 year, and the time interpolation lands at 0.22668. At 0.25, before the first expiry, and at (120, 2.0), after the last strike and expiry, the surface is flat. For the flat 20% and 30% surfaces the volatility at 9 months is 0.2708, not the 0.25 of the average, because the total variances 0.02 and 0.09 are averaged: 0.055 ÷ 0.75, whose square root is 0.2708.
A surface that follows its quotes
A live surface is made of quotes that change. As in topic 8, the surface is an observable that registers with its quotes, one for each strike and expiry, and passes the news on. It does not store the volatilities: it reads the quotes when asked. The engine registers with the spot, the rate, the dividend yield and the surface. When it prices an option it asks the surface for the volatility at the option's strike and expiry, and the formula does the rest. Each option in a book gets its own volatility from one object.
Worked example 4. *Problem:* make a surface from the grid of example 1 with SimpleQuotes, and price a 1-year put with strike 90 on spot 100 with the surface engine, and with a flat 20% volatility. Then move the 1-year quote at strike 90 to 28%, and price again. Set the same value again and read the price. Finally move the 1-year quote at strike 110 and price again. Count the engine's calculations. *Plan:* use VolSurface, SurfaceEngine and BSMEngine. *Steps:* below.
strikes, expiries = [90.0, 100.0, 110.0], [0.5, 1.0]vols = [[0.26, 0.20, 0.17], [0.25, 0.20, 0.175]]spot, rate, div = SimpleQuote(100.0), SimpleQuote(0.05), SimpleQuote(0.02)quotes = [[SimpleQuote(v) for v in row] for row in vols]surface = VolSurface(strikes, expiries, quotes)engine = SurfaceEngine(spot, rate, div, surface)put = Option(90.0, 1.0, "put")put.set_pricing_engine(engine)flat = Option(90.0, 1.0, "put")flat.set_pricing_engine(BSMEngine(spot, rate, div, SimpleQuote(0.20)))print(round(put.NPV(), 4), round(flat.NPV(), 4), engine.count)1quotes[1][0].set_value(0.28)2print(round(put.NPV(), 4), engine.count)quotes[1][0].set_value(0.28)put.NPV()print(engine.count)3quotes[1][2].set_value(0.20)4print(round(put.NPV(), 4), engine.count)
4.2266 2.7145 1 5.1801 2 2 5.1801 3
- 1The skew: the surface prices the put with 25% volatility, the flat engine with 20%.
- 2A quote of the surface moved.
- 3The same value again: no calculation.
- 4A quote that does not enter this put: still recalculated.
*Check:* the first line is 4.2266 2.7145 1: the surface prices the 90 put at 4.2266 (a 25% volatility at the 1-year, 90 node) against 2.7145 with the flat 20%. After the quote moves to 28% the price is 5.1801 and the count is 2. Setting the same value again leaves the count at 2. Moving the quote at strike 110 leaves the price at 5.1801 and the count goes to 3. *What to notice:* the notification does not say which quote moved, so the engine recalculates for a quote that does not enter the price; the price itself is unchanged.
A surface for SPY
Worked example 5. *Problem:* on the last day of the data, set the level of the expiries 1 month, 3 months, 6 months and 1 year to the historical volatility of the last 21, 63, 126 and 252 days. Make the call quotes for the strikes 80%, 90%, 100%, 110% and 120% of the spot with the smile of this topic, recover the surface, and check it. Find the volatility at 105% of the spot and 9 months. Add 5% of the spot to one price and check the butterfly. Finally price a 6-month put at 90% of the spot with the surface and with the flat 6-month level, and count the engine's calculations when one quote moves and when it is set again. *Plan:* study combines the functions and the classes. *Steps:* below.
out = study(load_data())print([round(v, 4) for v in out["atm_vols"]], out["recovery_error"] < 1e-6)1print(out["calendar"], out["butterfly"], out["broken"], round(out["vol_interp"], 4))2print(round(out["put_surface"], 3), round(out["put_flat"], 3), round(out["smile_effect"], 3), out["engine_calcs"])3
[0.1282, 0.1367, 0.142, 0.1287] True 0 0 1 0.1285 8.421 4.154 4.268 2
- 1The level of the surface from real volatilities.
- 2The checks, the broken price, and the interpolated volatility.
- 3The put with the smile and without.
*Check:* the levels are 0.1282, 0.1367, 0.142 and 0.1287 for the four expiries, and the volatilities recovered from the prices match the smile (True). The clean surface has 0 calendar and 0 butterfly violations, and the broken price gives 1. The volatility at 105% and 9 months is 0.1285. The put at 90% of the spot costs 8.421 with the surface and 4.154 with the flat level, so the smile adds 4.268; the count is 2 calculations. *What to notice:* an out-of-the-money put is the option that depends most on the skew: the single-volatility price is half of the surface price.
The quotes of this topic come from a simple formula for the smile, not from real option prices, which the course data do not contain. The shape is realistic (higher volatility for low strikes), the levels come from real SPY returns, and the machinery is the real one. A real surface also has to cope with missing strikes, quotes that cross, and the wings beyond the traded strikes. QuantLib offers BlackVarianceSurface for a grid like this, and parametric fits such as SVI when the quotes are sparse.
- NameQuestion it answers
- implied_vol_grid(prices, strikes, expiries, spot, rate, div)What volatility does each quote imply?uses implied_volQuantLib: BlackVarianceSurface from the quotes
- total_variance(vols, expiries)How much variance until each expiry?σ² × T
- calendar_violations(vols, expiries)Does a long expiry cost less than a short one?uses total_variancea check on the surface
- butterfly_violations(prices, strikes)Are the call prices convex in the strike?a check on the prices
- surface_vol(strikes, expiries, vols, strike, t)What is the volatility at any strike and expiry?uses linear_interpQuantLib: BlackVolTermStructure.blackVol
- VolSurface(strikes, expiries, quotes)A surface that follows its quotesuses surface_volQuantLib: BlackVarianceSurface with quote handles
- SurfaceEngine(spot, rate, div, surface)Prices an option with the volatility of its own strikeuses bsm_priceQuantLib: AnalyticEuropeanEngine with a surface
What you will build
The lab follows the lecture. Task 1 turns a grid of call prices into a grid of implied volatilities, and task 2 into total variances. Task 3 finds the calendar arbitrage in a surface and task 4 the butterfly arbitrage in call prices. Task 5 interpolates a volatility at any strike and expiry. Task 6 is a surface that follows its quotes and task 7 the engine that reads a volatility from it. Task 8 builds a surface for SPY on the last real day, checks it and prices a put with and without the smile.
Next topic: Short-rate models: calibrating Hull–White. Everything so far had the interest rate as a number or a curve known today. Interest-rate options, such as caps and swaptions, depend on how rates move. The next topic gives the short rate a model, the Hull–White model, with two parameters, and calibrates them so that the model reproduces a set of option volatilities, much as this topic reproduced the quotes with a surface.
Lab · what's graded
8 tasks · 100 pts- The implied volatility grid10 pts
- Total variance6 pts
- Calendar arbitrage10 pts
- Butterfly arbitrage12 pts
- Interpolating the surface22 pts
- The surface10 pts
- The surface engine10 pts
- A surface for SPY20 pts