Options Trading, Call, Put, Monte Carlo, Tejapi Quant.
refer to the specific code below: def mc_options(CallOrPut, K, S0, r, sigma, T, Nsteps, Nrep): SPATH = mc_asset(S0, r, sigma, T, Nsteps, Nrep) if CallOrPut == 'call': payoffs = np.maximum(SPATH[:,-1] - K, 0) return np.mean(payoffs)*np.exp(-r*T) else: payoffs = np.maximum(K - SPATH[:,-1], 0) return