'Pricing Barrier Option with Down and In
trying to price a Put Down In option, but i keep getting all my options values to 0. I'm trying to implement this model from a working Put Up Out model.
I feel like the problem is in the logic at the last part, where i define which values should be zero and which i need to bring back to present value.
I know this option should have a aprox. value of 0,277
Ty
Bellow is the code that I'm using
interest_rate_0 = 0.01
volatility_0 = 0.2
ref_0 = 5
DI_0 = 4
N = 252
M = 10000
T_0 = 1
dt = T_0/N
nudt = (interest_rate_0 - 0.5*volatility_0**2)*dt
volsdt = volatility_0*np.sqrt(dt)
erdt = np.exp(interest_rate_0*dt)
Z = np.random.normal(size=(N,M))
delta_St = nudt + volsdt*Z
ST = ref_0*np.cumprod(np.exp(delta_St), axis=0)
ST = np.concatenate((np.full(shape=(1,M), fill_value=ref_0),ST))
mask = np.any(ST <= DI_0, axis=0)
ST [:,mask] = 0
CT = np.maximum(0,strike_0 -ST[-1][ST[-1]!=0])
C0 = np.exp(-interest_rate_0*T_0)*np.sum(CT)/M
print(C0)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|