Recall that CRR (Cox-Ross-Rubinstein) model for option pricing is the usual binomial tree model with $u$ (up-factor) and $p$ (one of the risk-neutral probabilities) defined as follows: $$u = e^{\sigma\sqrt{\Delta t}},$$ $$p = \frac{e^{r\Delta t} - e^{-\sigma\sqrt{\Delta t}}}{e^{\sigma\sqrt{\Delta t}} - e^{-\sigma\sqrt{\Delta t}}},$$ where $\sigma$ is volatility, $r$ is interest rate, $\Delta t = \frac{T}{M}$ (time step), then $d = \frac{1}{u}$ (down-factor) and $q = 1- p$, everything else as usual.
Below is my implementation of CRR model using Python 3:
# Implementation of Cox-Ross-Rubenstein option's pricing model.
import math
T = 0.25 # time horizon
M = 2 # quantity of steps
t = T/M # step
sigma = 0.1391*math.sqrt(0.25) # volatility
r = 0.0214*0.25 # interest rate
u = math.exp(sigma*math.sqrt(t)) # up-factor
d = 1.0/u # down-factor
S0 = 2890.30 # initial underlying stock price
K = 2850 # strike
# compute risk-neutral probabilities
p = (math.exp(r*t)-math.exp(-sigma*math.sqrt(t)))/(math.exp(sigma*math.sqrt(t))-math.exp(-sigma*math.sqrt(t))) # up
q = 1 - p # down
# profit from call option
def call(stock_price, K):
price = max(stock_price - K, 0)
return price
# profit from put option
def put(stock_price, K):
price = max(K - stock_price, 0)
return price
# price for European style
def european():
price = 1.0/(1+r)*(p*option_prices[i+1][j+1]+q*option_prices[i+1][j])
return price
# price for American style, specify call or put in argument
def american(style):
price = max(style, european())
return price
stock_final_prices = []
option_final_prices = []
# create dictionary, containing lists of options prices at every time step
option_prices = {}
for i in range(0,M+1):
option_prices[i] = [None] * (i + 1)
# calculate possible final stock prices
for i in range(0,M+1):
stock_final_prices.append(S0*math.pow(u,i)*math.pow(d,M-i))
# calculate possible option final prices -- choose call or put function
for i in range(0,M+1):
option_final_prices.append(put(stock_final_prices[i], K))
option_prices[M] = option_final_prices
# going backwards -- uncomment european or american function, choose call or put for american style
for i in range(M-1,-1,-1):
for j in range(0,i+1):
option_prices[i][j] = european()
#option_prices[i][j] = american(call(S0*math.pow(u,j)*math.pow(d,i-j), K))
print('The price is ${0} for {1} steps.'.format(option_prices[0][0], M))
You can try to play with number of time steps variable $M$ and see that when $M$ grows option's price goes to zero, that does not make any sense. However, if you assign numerical values of $p$ and $u$ manually with $M = T$, it will become the usual binomial tree model (Black-Scholes-Merton) which works perfectly.
So, why my implementation of CRR does not converge to some meaningful non-zero price? Where I made a mistake? I'm really stuck and couldn't find it. Any help with code review will be very appreciated.