import numpy as np
import matplotlib.pyplot as plt
import numpy.random as npr
def gen_sn(M, I, anti_paths=True, mo_match=True):
if anti_paths is True:
sn = npr.standard_normal((M+1, I/2))
sn = np.concatenate((sn,-sn), axis=1)
else:
sn = npr.standard_normal((M+1, I))
if mo_match is True:
sn = (sn-sn.mean())/sn.std()
return sn
def gbm_mcs_amer(K, option='C'):
# set model paramters
S0 = 100 # initial stock level
T = 1.0 # time to maturity
r = 0.05 # risk free rate
vol = 0.20 # volatility
M = 1000 # time stpes
dt = T/M
df = np.exp(-r*dt)
# simulation of stock levels
S = np.zeros((M+1, I))
S[0] = S0
rn = gen_sn(M, I)
for t in range(1, M+1):
S[t] = S[t-1]*np.exp((r-0.5*vol**2)*dt+vol*np.sqrt(dt)*rn[t])
American Option Pricing via Longstaff and Schwartz (2001)
最新推荐文章于 2022-12-18 18:19:12 发布