Option Pricing, Numerical Methods, Monte Carlo, Monte Carlo Simulation.
(in years) N: number of time periods in the binomial model option_type: "call" or "put" """ dt = T/N u = np.exp(sigma * np.sqrt(dt)) d = 1/u p = (np.exp(r*dt) - d)/(u - d) values = np.zeros((N+1, N+1)) for j in range(N+1): values[N][j] = max(0, (S*u**j*d**(N-j) - X)) for i in range(N-1, -1, -1):