Dear All,
I am trying to run some Monte Carlo simulations, for the following strike levels in each case: a) 85, b) 90, c) 95, d) 105, e) 110, f) 115.
Instead of running the code one by one, I want to use a for loop, so it will loop through the strike levels and finally, I want to put them in a table of 7 rows that shows the strike, and the option price.
I will share the code I have so far
Any help is appreciated.
Thanks in advance.
Ben
Hi Mart
I am unable to access your code file. Please grant permissions for the same.
In the meanwhile, this article on Monte Carlo Simulation might help. In this, we are running 1000 simulations. You can modify the code parameters to incorporate the same for your testing.
Hi Rishabh,
Thank you for your reply. You should be able to access the code now.
Hi Mart
Please try the below in place of the last code cell:
strikes = [85, 90, 95, 105, 110, 115]
df = pd.DataFrame(columns = ["strike", "price"])
df["strike"] = strikes
price = []
for index, strike in enumerate(strikes):
for i in range(1, 51):
mc_upout_price = [None]*50
K = strike #Strike
norm_martix = norm.rvs(size=[12, 2, i*1000])
corr_norm_martix = np.array([np.matmul(L, x) for x in norm_martix])
mc_price_path = np.array([share_path(S_0, risk_free_rate, sigma, Z_share, dT) for Z_share in corr_norm_martix[:,0,:].T])
mc_upout_payoff = np.array([upout_call_payoff(path, K, risk_free_rate, T) for path in mc_price_path])
#call option price
mc_upout_price[i-1] = np.mean(mc_upout_payoff)
price.append(mc_upout_price[-1])
df["price"] = [i for i in price if i]
Hope this helps.
Yes, thank you it is very helpful!