Lesson 4 of 15

Black-Scholes Formula

Black-Scholes Formula

The Black-Scholes model (1973) gives a closed-form price for European options under the assumption that the stock follows geometric Brownian motion.

Inputs

SymbolMeaning
SCurrent stock price
KStrike price
TTime to expiry (years)
rRisk-free rate (continuously compounded)
σVolatility (annualized standard deviation of log-returns). Note: in finance, σ denotes volatility/standard deviation — not the sigmoid function used in ML.

Formula

First compute d1d_1 and d2d_2:

d1=ln(S/K)+(r+σ2/2)TσTd_1 = \frac{\ln(S/K) + (r + \sigma^2/2)T}{\sigma\sqrt{T}}

d2=d1σTd_2 = d_1 - \sigma\sqrt{T}

Then the call and put prices are:

C=SN(d1)KerTN(d2)C = S \cdot N(d_1) - K e^{-rT} \cdot N(d_2)

P=KerTN(d2)SN(d1)P = K e^{-rT} \cdot N(-d_2) - S \cdot N(-d_1)

where N(x)N(x) is the standard normal CDF.

Normal CDF via erfc

Python's math.erfc gives the complementary error function. We can compute:

N(x)=12erfc ⁣(x2)N(x) = \frac{1}{2} \operatorname{erfc}\!\left(\frac{-x}{\sqrt{2}}\right)

Example Verification

For S=K=100, T=1, r=0.05, σ=0.2:

  • d₁ = (ln(1) + 0.07) / 0.2 = 0.35
  • d₂ = 0.35 - 0.2 = 0.15
  • C ≈ 10.4506
Python runtime loading...
Loading...
Click "Run" to execute your code.