Skip to content

2. Price calculation

With blackscholes you are able to get a fair value estimate of a call or put option according to the Black-Scholes-Merton model and Black-76 model.

Parameters

Reference of symbols that are used in the formulas:

$S$ = Asset price

$F$ = Futures price

$K$ = Strike price

$T$ = Time to maturity (in years)

$r$ = Risk-free rate

$\sigma$ = Volatility

$q$ = Annual dividend yield

$\Phi(.)$ = Cumulative Density Function (CDF) of $\mathcal{N}(0, 1)$

Black-Scholes

$d_1 = \frac{ln(\frac{S}{K}) + (r - q +\frac{1}{2}\sigma^2)T}{\sigma\sqrt{T}}$

$d_2 = d_1 - \sigma\sqrt{T}$

Call

$$ S e^{-qT} \Phi(d_1) - e^{-rT}K\Phi(d_2)$$

from blackscholes import BlackScholesCall
call = BlackScholesCall(S=55, K=50, T=1, r=0.0025, sigma=0.15)
call.price()  ## 6.339408

Fair value of Black-Scholes call option.

Source code in blackscholes/call.py
24
25
26
27
28
29
def price(self) -> float:
    """Fair value of Black-Scholes call option."""
    return (
        self.S * exp(-self.q * self.T) * self._cdf(self._d1)
        - self._cdf(self._d2) * exp(-self.r * self.T) * self.K
    )

Put

$$e^{-rT}K\Phi(-d_2) - S e^{-qT} \Phi(-d_1)$$

from blackscholes import BlackScholesPut
put = BlackScholesPut(S=55, K=50, T=1, r=0.0025, sigma=0.15)
put.price()  ## 1.214564

Fair value of a Black-Scholes put option.

Source code in blackscholes/put.py
24
25
26
27
28
def price(self) -> float:
    """Fair value of a Black-Scholes put option."""
    return self._cdf(-self._d2) * self.K * exp(-self.r * self.T) - self.S * exp(
        -self.q * self.T
    ) * self._cdf(-self._d1)

Black-76

$d_1 = \frac{ln(\frac{F}{K}) + \frac{1}{2}\sigma^2T}{\sigma\sqrt{T}}$

$d_2 = d_1 - \sigma\sqrt{T}$

Call

$$e^{-rT} \bigg[F \Phi(d_1) - K\Phi(d_2) \bigg]$$

from blackscholes import Black76Call
call = Black76Call(F=55, K=50, T=1, r=0.0025, sigma=0.15)
call.price()  ## 6.2345

Fair value of a Black-76 call option.

Source code in blackscholes/call.py
104
105
106
107
108
def price(self) -> float:
    """Fair value of a Black-76 call option."""
    return exp(-self.r * self.T) * (
        self.F * self._cdf(self._d1) - self.K * self._cdf(self._d2)
    )

Put

$$e^{-rT} \bigg[K \Phi(-d_2) - F\Phi(-d_1) \bigg]$$

from blackscholes import Black76Put
F = 55. # Discounted futures price
put = Black76Put(F=55, K=50, T=1, r=0.0025, sigma=0.15)
put.price()  ## 1.2470

Fair value of a Black-76 put option.

Source code in blackscholes/put.py
94
95
96
97
98
def price(self) -> float:
    """Fair value of a Black-76 put option."""
    return exp(-self.r * self.T) * (
        self.K * self._cdf(-self._d2) - self.F * self._cdf(-self._d1)
    )

Binary options

blackscholes supports calculation of the price and the forward (undiscounted price) of binary options. Also called a digital, exotic or bet option.

Call

$$e^{-rT} \Phi(d_2)$$

Formula for forward then is just $$\Phi(d_2)$$

from blackscholes import BinaryCall

call = BinaryCall(S=55, K=50, T=1, r=0.0025, sigma=0.15)
call.price() # 0.7163
call.forward() # 0.7181

Fair value of binary call option.

Source code in blackscholes/call.py
159
160
161
def price(self) -> float:
    """Fair value of binary call option."""
    return exp(-self.r * self.T) * self._cdf(self._d2)

Fair value of binary call option without discounting for interest rates.

Source code in blackscholes/call.py
163
164
165
def forward(self) -> float:
    """Fair value of binary call option without discounting for interest rates."""
    return self._cdf(self._d2)

Put

$$e^{-rT} (1 - \Phi(d_2))$$

Formula for forward then is just $$1 - \Phi(d_2)$$

from blackscholes import BinaryPut

put = BinaryPut(S=55, K=50, T=1, r=0.0025, sigma=0.15)
put.price() # 0.2812
put.forward() # 0.2819

Fair value of binary call option.

Source code in blackscholes/put.py
149
150
151
def price(self) -> float:
    """Fair value of binary call option."""
    return exp(-self.r * self.T) * (1 - self._cdf(self._d2))

Fair value of binary call option without discounting for interest rates.

Source code in blackscholes/put.py
153
154
155
def forward(self) -> float:
    """Fair value of binary call option without discounting for interest rates."""
    return 1 - self._cdf(self._d2)