5D Library › Implied Volatility Surfaces, Skew Premia and Quantitative Risk Control of Vertical Spreads · 中文
Chapter 1 Black–Scholes–Merton Pricing and the Inversion of Implied Volatility
One formula, five inputs
In 1973 Black and Scholes published their pricing formula for European options (Black and Scholes 1973); in the same year Merton extended it to underlyings paying a continuous dividend and proved a set of model-free price bounds, one of which is that an American call on a non-dividend-paying underlying should never be exercised early, so its price equals that of the European call (Merton 1973). The idea behind the formula is that if the underlying follows geometric Brownian motion, trading is continuous and frictionless, and the interest rate and volatility are constant, then the option’s payoff can be replicated continuously with the underlying and a riskless asset, so its price depends neither on investors’ risk preferences nor on the underlying’s expected return.
With spot , strike , time to expiry (years), risk-free rate , continuous dividend yield and volatility ,
where
is the standard normal distribution function. Python’s standard library
has no ready-made
,
but
,
so math.erf suffices. Of the five inputs only
cannot be observed directly, which is where “implied volatility” comes
from.
The program below computes prices under illustrative parameters, checks put–call parity , and uses the binomial tree of Cox, Ross and Rubinstein (Cox et al. 1979) to show the discrete model converging to the formula. The last part compares the exact price of an at-the-money-forward option () with the shortcut , the origin of the approximation in the next section.
Calculation
# Black-Scholes-Merton prices with the normal CDF from math.erf, put-call parity, the
# Cox-Ross-Rubinstein tree converging to the formula, and the at-the-money shortcut.
# Illustrative parameters, not market quotes.
import math
def ncdf(x):
return 0.5 * (1.0 + math.erf(x / math.sqrt(2.0)))
def bsm(S, K, T, r, sig, q=0.0, kind="call"):
d1 = (math.log(S / K) + (r - q + 0.5 * sig * sig) * T) / (sig * math.sqrt(T))
d2 = d1 - sig * math.sqrt(T)
if kind == "call":
return S * math.exp(-q * T) * ncdf(d1) - K * math.exp(-r * T) * ncdf(d2)
return K * math.exp(-r * T) * ncdf(-d2) - S * math.exp(-q * T) * ncdf(-d1)
def crr(S, K, T, r, sig, n, kind="put", american=False):
dt = T / n
u = math.exp(sig * math.sqrt(dt)); d = 1 / u
p = (math.exp(r * dt) - d) / (u - d); disc = math.exp(-r * dt)
pay = (lambda s: max(K - s, 0.0)) if kind == "put" else (lambda s: max(s - K, 0.0))
v = [pay(S * u ** j * d ** (n - j)) for j in range(n + 1)]
for i in range(n - 1, -1, -1):
v = [disc * (p * v[j + 1] + (1 - p) * v[j]) for j in range(i + 1)]
if american:
v = [max(v[j], pay(S * u ** j * d ** (i - j))) for j in range(i + 1)]
return v[0]
if __name__ == "__main__":
S, K, T, r, sig = 100.0, 100.0, 30 / 365, 0.03, 0.20
c, p = bsm(S, K, T, r, sig), bsm(S, K, T, r, sig, kind="put")
print(f"S = K = 100, 30 days, r = 3 %, sigma = 20 %: call {c:.4f}, put {p:.4f}")
print(f"parity C - P = {c - p:.6f}; S - K exp(-rT) = {S - K * math.exp(-r * T):.6f}")
print(f"with dividend yield q = 2 %: call {bsm(S, K, T, r, sig, 0.02):.4f}")
print("CRR tree, European put: n = 10 50 250 1000 (formula)")
vals = " ".join(f"{crr(S, K, T, r, sig, n):.4f}" for n in (10, 50, 250, 1000))
print(f"{'':26s}{vals} ({p:.4f})")
for days in (7, 30, 90, 365):
t = days / 365
k = S * math.exp(r * t) # at-the-money forward strike
exact = bsm(S, k, t, r, sig)
approx = S * sig * math.sqrt(t) / math.sqrt(2 * math.pi)
print(f"ATM-forward call, {days:3d} days: exact {exact:.4f},"
f" 0.3989*S*sigma*sqrt(T) = {approx:.4f}")
# S = K = 100, 30 days, r = 3 %, sigma = 20 %: call 2.4096, put 2.1633
# parity C - P = 0.246272; S - K exp(-rT) = 0.246272
# with dividend yield q = 2 %: call 2.3237
# CRR tree, European put: n = 10 50 250 1000 (formula)
# 2.1069 2.1519 2.1610 2.1627 (2.1633)
# ATM-forward call, 7 days: exact 1.1049, 0.3989*S*sigma*sqrt(T) = 1.1050
# ATM-forward call, 30 days: exact 2.2872, 0.3989*S*sigma*sqrt(T) = 2.2875
# ATM-forward call, 90 days: exact 3.9604, 0.3989*S*sigma*sqrt(T) = 3.9620
# ATM-forward call, 365 days: exact 7.9656, 0.3989*S*sigma*sqrt(T) = 7.9788For 30 days, at the money and with 20 % volatility, the call is worth 2.4096 and the put 2.1633; their difference equals exactly. That is parity, and it does not depend on any volatility assumption. Adding a 2 % dividend yield lowers the call to 2.3237. As the tree grows from 10 to 1,000 steps the put price climbs from 2.1069 towards the formula’s 2.1633 (a gap of 0.0006 at 1,000 steps). The at-the-money-forward shortcut is almost exact at one week to one month (2.2875 against 2.2872 at 30 days); at one year the error grows to 0.013.
Note
The formula’s assumptions are not facts about markets. Constant volatility, lognormal returns and continuous frictionless trading all fail in practice: volatility changes and clusters, returns have fat tails, and trading carries bid–ask spreads and cannot be adjusted continuously. Chapter 2 shows how markets patch the first two by attaching different implied volatilities to different strikes; Chapter 3 shows how much bid–ask spreads matter for spread trades. The formula’s value is that it provides a common ruler: converting prices into implied volatilities with one formula makes different options comparable (Hull 2018).
Implied volatility: solving backwards
Given a market price , the implied volatility is the at which the formula reproduces it. A call’s price increases monotonically in (its derivative, vega, is ), so as long as the market price lies inside the no-arbitrage bounds a solution exists and is unique; but there is no closed form, so it must be found numerically.
Newton’s method iterates . Near the solution it converges quadratically, in a few steps, but from a poor start it can fail: for deep out-of-the-money options close to expiry, vega is almost zero far from the solution and a single step can throw the iterate out of any sensible range.
The Manaster–Koehler starting value. Manaster and Koehler (1982) noted that price, as a function of , has a unique inflection point , and that Newton’s method started there converges monotonically to the solution (Manaster and Koehler 1982). Two points need stating: this is a starting value, not an approximation formula; and at the money forward , on the boundary of , where is undefined and a limit (or a small positive start) must be used.
The Brenner–Subrahmanyam approximation. In 1988 Brenner and Subrahmanyam expanded around zero to first order and obtained, for an at-the-money-forward option, , and hence
valid when (Brenner and Subrahmanyam 1988). The framework’s version matches the original, but the condition must be stated. Corrado and Miller (1996) gave a quadratic approximation that is more accurate away from the money (Corrado and Miller 1996).
Bisection as a fallback. Halving the interval repeatedly halves the error each step and always converges, at the cost of more steps. A common practice is to run Newton from an approximation or from the Manaster–Koehler start and switch to bisection when it fails (leaves the sensible range or meets too small a vega).
The program below tests these methods on 308 cases (11 strikes × 7 maturities × 4 true volatilities). Cases with less than of time value cannot be inverted reliably (the price is essentially intrinsic value) and are dropped first.
Calculation
# Implied volatility by Newton-Raphson from two starting values (a naive 0.30, and the
# Manaster-Koehler point sigma_c, where the price is an inflection in sigma), with a
# bisection fallback; then the Brenner-Subrahmanyam and Corrado-Miller shortcuts.
import math
def ncdf(x):
return 0.5 * (1.0 + math.erf(x / math.sqrt(2.0)))
def call(S, K, T, r, s):
d1 = (math.log(S / K) + (r + 0.5 * s * s) * T) / (s * math.sqrt(T))
return S * ncdf(d1) - K * math.exp(-r * T) * ncdf(d1 - s * math.sqrt(T))
def vega(S, K, T, r, s):
d1 = (math.log(S / K) + (r + 0.5 * s * s) * T) / (s * math.sqrt(T))
return S * math.sqrt(T) * math.exp(-0.5 * d1 * d1) / math.sqrt(2 * math.pi)
def newton(C, S, K, T, r, s0, tol=1e-8, it=50):
s = s0
for k in range(1, it + 1):
if not 1e-4 < s < 10:
return None, k # left the admissible range
v = vega(S, K, T, r, s)
if v < 1e-12:
return None, k # flat price curve: step undefined
step = (call(S, K, T, r, s) - C) / v
s -= step
if abs(step) < tol:
return s, k
return None, it
def bisect(C, S, K, T, r, lo=1e-4, hi=10.0, tol=1e-8):
k = 0
while hi - lo > tol:
k += 1; mid = 0.5 * (lo + hi)
lo, hi = (mid, hi) if call(S, K, T, r, mid) < C else (lo, mid)
return 0.5 * (lo + hi), k
def sigma_c(S, K, T, r):
return math.sqrt(abs(2 * (math.log(S / K) + r * T) / T))
if __name__ == "__main__":
S, r = 100.0, 0.03
cases = [(K, d / 365, s) for K in (60, 70, 80, 90, 95, 100, 105, 110, 120, 140, 160)
for d in (3, 7, 14, 30, 60, 120, 365) for s in (0.10, 0.20, 0.40, 0.80)]
stats = {"naive": [0, 0, 0], "MK": [0, 0, 0]}
worst, bis_it, skipped, ex = 0.0, [], 0, None
for K, T, s in cases:
C = call(S, K, T, r, s)
if C - max(S - K * math.exp(-r * T), 0) < 1e-6:
skipped += 1; continue # no time value left to invert
for name, s0 in (("naive", 0.30), ("MK", sigma_c(S, K, T, r))):
est, k = newton(C, S, K, T, r, s0)
if est is None or abs(est - s) > 1e-6:
stats[name][1] += 1
if name == "naive" and ex is None and K > 100:
ex = (K, round(T * 365), s, C)
est, kb = bisect(C, S, K, T, r); bis_it.append(kb)
else:
stats[name][0] += 1; stats[name][2] += k
worst = max(worst, abs(est - s))
n = len(cases) - skipped
print(f"{n} invertible cases ({skipped} with no time value skipped)")
for name, (ok, fail, its) in stats.items():
print(f" Newton from {name:5s}: converged {ok:3d}, failed {fail:3d},"
f" mean iterations {its / max(ok, 1):.1f}")
print(f" bisection fallback: {len(bis_it)} calls, {max(bis_it)} iterations each;"
f" largest error {worst:.1e}")
K, d, s, C = ex
print(f" e.g. K = {K}, {d} days, sigma {s}: price {C:.3f}, vega at 0.30 ="
f" {vega(S, K, d / 365, r, 0.30):.4f}: overshoot")
k_atm = S * math.exp(r * 30 / 365); T = 30 / 365
C = call(S, k_atm, T, r, 0.20)
print(f"ATM-forward, 30 days: sigma_c = {sigma_c(S, k_atm, T, r):.1e};"
f" one Newton step from 0 gives {C / (S * math.sqrt(T / (2 * math.pi))):.4f}")
print("shortcuts, 30 days, true sigma 0.20: K B-S 1988 Corrado-Miller")
for K in (90, 95, 100, k_atm, 105, 110):
C = call(S, K, T, r, 0.20); X = K * math.exp(-r * T)
bs = math.sqrt(2 * math.pi / T) * C / S
a = C - 0.5 * (S - X)
cm = math.sqrt(2 * math.pi) / (S + X) * (a + math.sqrt(max(a * a - (S - X) ** 2
/ math.pi, 0)))
print(f"{'':38s}{K:6.2f} {bs:.4f} {cm / math.sqrt(T):.4f}")
# 226 invertible cases (82 with no time value skipped)
# Newton from naive: converged 193, failed 33, mean iterations 5.7
# Newton from MK : converged 226, failed 0, mean iterations 6.7
# bisection fallback: 33 calls, 30 iterations each; largest error 4.1e-09
# e.g. K = 110, 3 days, sigma 0.8: price 0.338, vega at 0.30 = 0.0084: overshoot
# ATM-forward, 30 days: sigma_c = 3.8e-08; one Newton step from 0 gives 0.2000
# shortcuts, 30 days, true sigma 0.20: K B-S 1988 Corrado-Miller
# 90.00 0.8992 0.2384
# 95.00 0.5033 0.1889
# 100.00 0.2107 0.2000
# 100.25 0.2000 0.2000
# 105.00 0.0608 0.1949
# 110.00 0.0117 0.2084Of the 226 invertible cases, Newton’s method from the Manaster–Koehler start converges in all of them, in 6.7 steps on average; from a fixed start of 0.30, 33 fail. An example is the call with strike 110, three days left and a true volatility of 0.8: at its vega is only 0.0084, and the first step leaves the sensible range. Bisection rescues every failed case (30 steps each), and the largest error over all cases is .
At the money forward, is essentially zero (), but the first Newton step from zero is precisely the Brenner–Subrahmanyam formula, and it gives 0.2000, the true value. This explains where the approximation comes from and also its limits: at strikes 95 and 105 it gives 0.503 and 0.061 when the truth is 0.20 in both cases. The Corrado–Miller formula gives 0.189 and 0.195 there, far better, but ten per cent from the money its error is still 0.008 (strike 110) to 0.038 (strike 90). Approximations are useful as starting values or quick checks, not as substitutes for numerical inversion.
Evidence
Implied volatility is not an unbiased forecast of future volatility. As Chapter 2 shows, the implied variance of S&P 500 and other index options has on average exceeded the variance subsequently realised; the gap is the variance risk premium (Carr and Wu 2009; Bollerslev et al. 2009). “Implied volatility” is first of all a unit of quotation, a way of turning a price into a comparable number, not the market’s best estimate of future volatility.
Chapter summary
The Black–Scholes–Merton formula prices European options under
constant volatility, lognormal returns and continuous frictionless
trading, and can be implemented in the standard library with
math.erf; the binomial tree converges to it as the number
of steps grows. Implied volatility is a unique inverse with no closed
form: Newton’s method from the Manaster–Koehler start converges in every
test case, about 15 % of cases fail from a fixed start, and bisection
provides a fallback. The Brenner–Subrahmanyam approximation holds only
at the money forward, where it is the first Newton step from zero. The
next chapter looks at how markets price different strikes with different
implied volatilities.
References
Fan, Y. (2026). Implied Volatility Surfaces, Skew Premia and Quantitative Risk Control of Vertical Spreads: Microstructure Pricing and Time-Stop Dynamics under Non-Gaussian Tails [期权隐含波动率曲面、偏度溢价与垂直价差结构的定量风控] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.23796765 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).