One Volatility per Strike
The model has one volatility for every strike; if quotes at several strikes imply different volatilities, they do not come from this model, and the implied volatility becomes a way to quote a price, strike by strike.
The question
The formula has one volatility, and it is the same for every strike. Suppose several call quotes on the same stock and the same date, at different strikes, are all produced by this model. Then they all imply the same volatility. What if they do not?
This lesson computes the implied volatility of each quote and compares them. The quotes are made up to show a pattern: they describe no market.
Work it by hand
The book's example has spot 100, rate 0.05 and one year. A model with the volatility 0.2 prices the strike-100 call at 10.45 and the strike-80 call at 24.59. Take the quotes 10.45 and 25.81 for those two strikes.
The first quote equals the model's price, so it implies 0.2. The second is above the model's price at 0.2, and the price rises with the volatility, so it implies a volatility above 0.2. The two strikes disagree. If both came from one model they would imply the same number, so the two quotes cannot both be prices of this model at one volatility.
Run it
The program prices a call at each strike with a flat model of volatility 0.2 and asks the engine for the implied volatility of each quote. Line 1 builds that flat model. The loop of lines 5 to 12 takes the strike and the quote of position k from the two lists. Line 7 calls calibration.implied_vol, and lines 10 and 11 keep the highest and the lowest implied volatility.
The picture shows the implied volatilities as points and the model's volatility as a line.

let m = model.black_scholes(spot, rate, 0.0, vol);
let engine = pricing.analytic();
let ivs = float_list(); let flat = float_list(); let model_price = float_list();
let top = 0.0; let bottom = 5.0;
for (k in range(0, strikes.len())) {
let call = instrument.european_call(strikes.at(k), 1.0);
let iv = calibration.implied_vol(call, m, engine, quotes.at(k));
ivs.add(lmf.round(iv, 6)); flat.add(vol);
model_price.add(lmf.round(pricing.price(call, m, engine).price(), 2));
if (iv > top) { top = iv; }
if (iv < bottom) { bottom = iv; }
}
lmcode_return_put("implied", ivs); lmcode_return_put("flat", flat);
lmcode_return_put("model_price", model_price);
let answer = int(math_round(lmf.round(top - bottom, 4) * 10000.0));
{
"answer": 1001,
"implied": [
0.270011,
0.230118,
0.199984,
0.179989,
0.169904
],
"flat": [
0.2,
0.2,
0.2,
0.2,
0.2
],
"model_price": [
24.59,
16.7,
10.45,
6.04,
3.25
]
}Line 15 returns the highest implied volatility minus the lowest, in whole basis points. You can change both lists and the three numbers, with as many strikes as quotes, from 1 to 64 strikes.
A quote list shorter than the strike list stops line 7 with "FloatList.at: index out of range: 2" for three strikes and two quotes, and extra quotes are ignored. A quote that no volatility reaches stops it with "price 0 is outside the range reachable with volatility in [0.0001, 5]".
Your turn
The program below is meant to return the position, counting from 1, of the strike whose call quote implies the highest volatility, for years years, spot and rate, with the strikes and quotes in two lists of the same length. The strikes may come in any order. Decide whether it does, and find the candidates that do. Check runs each candidate on the data shown and on four others.

let best = 0.0;
let answer = 0;
for (k in range(0, strikes.len())) {
if (quotes.at(k) > best) { best = quotes.at(k); answer = k + 1; }
}
{
"answer": 5
}strikes and quotes are lists of the same length: quotes at position k is the price of the European call (no dividend) with strike strikes at position k, for spot, rate and years. Return, as a whole number counting from 1, the position of the strike whose quote implies the highest Black-Scholes volatility. The strikes may be in any order.
Read the result carefully
The page shows a limit of the model: it has one volatility and the quotes do not. The implied volatility is then a way of quoting a price strike by strike, not a property of the stock. Nothing here says which price is right or whether any price is out of line: the quotes are invented.
The inputs are made up, and the page describes a model and is not investment advice.
A model in which the variance itself moves, and what curve of implied volatilities it gives, is the subject of Heston and the Smile Step by Step.
Recap
- The model has one volatility for every strike.
- Quotes that imply different volatilities do not come from this model.
- An implied volatility is a way to quote a price for one strike.
- Implied volatilities are compared strike by strike.