Black-Scholes Formula

Can't derive it (lmao), but we can totally code it up — walking through the Black-Scholes pricing formula and computing actual call and put prices.

OK real talk — the title was a little misleading. Let me just come out and say it up front.

I cannot derive Black-Scholes. lmao

If you’re here for that, close the tab lmao

What I am going to do is code up the Black-Scholes Model. That’s the whole point. That’s all this is.

So first, let me throw the Black-Scholes PDE (Partial Differential Equation) at you. The related derivative-valuation work earned Merton and Scholes the 1997 Economics Prize, building on their work with Fischer Black.

Equation from the original notes

That right there is the Black-Scholes partial differential equation.

But here’s the thing — we’re not actually using that one directly.

What we will use is the option pricing formula you get when you take that PDE and grind through it with some seriously heavy-duty math. That result is the Black-Scholes option pricing formula — more math than I’m going to derive here, heh.

Anyway, here it is:

Equation from the original notes

Equation from the original notes

These formulas price European calls and puts on a stock with no dividends, with positive time to expiry and volatility. Before plugging numbers in, let me walk through the other Black-Scholes assumptions.

i) There is no arbitrage opportunity

(no way to make a riskless profit)

······· ’no arbitrage opportunity'

ii) It is possible to borrow and lend any amount

(even fractional amounts) of cash at the riskless rate

······· you can borrow or lend any amount of cash

iii) It is possible to buy and sell any amount

(even fractional amounts) of stock

······· you can also buy or sell any amount of stock

iv) None of these transactions incur any fees or costs

······· no transaction costs, no commissions — perfectly frictionless market

v) The rate of return on the riskless asset is constant

······· the riskless rate is just a fixed number, always

vi) The stock price follows geometric Brownian motion,

and we assume its drift and volatility are both constant

······· stock price follows Brownian motion with constant drift and constant volatility

(What’s the right way to think about “drift” here — like, the general prevailing direction of the stock price? I’m honestly not totally sure.)

Oh and — one thing that’s apparently a huge deal about BS: you only need the volatility of the stock. Not the expected return of the stock. That’s the key insight, supposedly… heh

Anyway. Let’s just use it.

Sub BS_Formula_Example()
Dim S As Double, k As Double, r As Double, T As Double, v As Double
Dim d_1 As Double, d_2 As Double, c As Double, p As Double
S = 800: k = 850: r = 0.05: T = 0.5: v = 0.2:

d_1 = (log( s / k ) + (r + 0.5*v*v)*T) / (v*sqr(T))
d_2 = d_1 - v*sqr(T)

with worksheetfunction

c = S*.NormSDist(d_1) - k*exp(-r*T)*.NormSDist(d_2)

p = k*exp(-r*T)*.NormSDist(-d_2) - S*.NormSDist(-d_1)

End with

debug.print "call option price is : " & c

debug.print "put option price is : " & p

End sub

The derivation behind the formula is brutal, sure. But actually coding it up from the formula? Not that bad at all.

Let me at least think through the $N(d_1)$ piece a little.

What $N(x)$ means is:

Equation from the original notes

So it’s the probability that a value drawn from the standard normal $N(0,1)$ comes out below $x$.

And $N(d_1)$ is, weirdly enough:

Equation from the original notes

So $N(d_1)$ is the cumulative probability of getting a value below $d_1$ from the standard normal distribution.

But then what? T_T Because I genuinely don’t know what $d_1$ and $d_2$ are actually supposed to represent T_T

For now I just have to hold onto it and remember it like this… T_T T_T T_T

Equation from the original notes

Heads-up. This screenshot uses VBA and predates the d1 denominator fix. Its ... / v * Sqr(T) is evaluated left to right; the denominator should be (v * Sqr(T)). That multiplies the wrong d1 by an extra factor of T, but it does not multiply both option prices by one common factor. With the shown inputs, the corrected code gives call ≈ 32.8552 and put ≈ 61.8686. Trust the corrected code, not the old output. T_T

Equation from the original notes

Equation from the original notes

The Python charts are saved in the directory where you run the script; the author’s private Desktop folder is not required.

import numpy as np
import scipy as sp
import scipy.stats
import math
import matplotlib.pyplot as plt
def BS_Formula(S=800, k=850, r=0.05, T=0.5, v=0.2):
    d1 = math.log(S/k) + (r + (v*v)*0.5)*T
    d1 = d1 / (v*math.sqrt(T))
    d2 = d1 - v*math.sqrt(T)
    norm = sp.stats.norm(loc=0, scale=1)
    c = S*norm.cdf(d1) - k*math.exp(-r*T)*norm.cdf(d2)
    p = k*math.exp(-r*T)*norm.cdf(-d2) - S*norm.cdf(-d1)
    return c, p
SS = np.linspace(700, 900, 1000)
C = np.zeros(len(SS))
P = np.zeros(len(SS))
for i in range(len(SS)):
    C[i], P[i] = BS_Formula(S=SS[i])
plt.figure(figsize=(6, 4))
plt.plot(SS, C)
plt.xlabel('S')
plt.ylabel('Price')
plt.title('BS_Formula_c')
plt.savefig('BS_Formula_c', dpi=200)
plt.figure(figsize=(6, 4))
plt.plot(SS, P)
plt.xlabel('S')
plt.ylabel('Price')
plt.title('BS_Formula_p')
plt.savefig('BS_Formula_p', dpi=200)

Questions or corrections?

Did a step lose you, or does a number look off? Email me or use the contact page. Include the note title and the step or figure you mean.

Feedback goes to me privately by email; it is not posted as a public comment.