本文主要Matlab代码:
产品通过蒙特卡洛模拟进行定价:
SFProduct = 50000;
part_rate = 1.25;
S0 = 6525.80; 指数价格
barrier_r=1.08; 利率
barrier_price = S0*barrier_r;
Br=0.06;
mu = 0.0252;
sigma = 0.246;
T = 1;
NSteps = 120;
NRepl = 100000;
paths=AssetPaths(S0,mu,sigma,T,NSteps,NRepl);
a = length(paths);
out_flag=zeros(NRepl,1);
out_c=0;
Price=0;
PriceNR = zeros(NRepl,1);
for i =1:NRepl
if any(paths(i,:)>barrier_price)
out_flag(i)=1;
out_c=out_c+1;
Price = Price + S0*Br;
PriceNR(i)=S0*Br;
else
PriceNR(i)=max(0,paths(i,NSteps+1)-S0)*part_rate;
Price = Price+max(0,paths(i,NSteps+1)-S0)*part_rate;
end
end