How can I plot Put option Prices in Python

Viewed 85

How can I plot an American put option prices with 50 steps, Like this Plot. Here is the code i used to price an American Put option with Binomial Model. The results are corrected, but I am stuck at the plot.


put_prices  = np.zeros( (N+1, N+1) )
t = T / (N)
u =  np.exp(sigma * np.sqrt(t))
d = 1/u
p = (np.exp(r * t) - d) / (u - d)
put_prices  = np.zeros( (N+1, N+1) )
put_prices[-1,:] =  intrinsic_values_p

for i in range(N - 1,-1,-1):
   for j in range(i + 1):
      put_prices[i,j] = np.maximum(K - stock_prices[i,j], np.exp(-r * t) * ((1-p) * put_prices[i+1,j] + p * put_prices[i+1,j+1]))
put_prices
0 Answers
Related