⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regressionnowdefault1.m

📁 几何布朗运动的Monte Carlo模拟以及美式期权定价
💻 M
字号:
function [prices,exercisetime]=regressionnowdefault1(St,k,r,theta,T,sigma,m,b,seed)

% Output:
% prices: the value of defual option
% exercisetime: termination time of mortgage

% Input:
% St: price of underlying asset at time zero
% k:  exercise price
% r:  interest rate in year
% theta: the growth rate of the price of underlying asset in year
% T: contract maturity
% sigma: volitility of price of underlying asset
% m: number of time steps
% b: paths of underlying asset


r=log(1+r/12);
theta=log(1+theta/12);
sigma=sqrt(sigma/12);

dt=T/m;
discount=exp(-r*dt);
discountvector=exp(-r*dt*(1:m)');
a=zeros(3,1);
spaths=genpaths(St,theta,sigma,T,m,b,seed);
spaths(:,1)=[];
cashflows=max(0,k(m)-spaths(:,m));
exercisetime=m*ones(b,1);
for step=m-1:-1:1;
    inmoney=find(spaths(:,step)<k(step));
    if ~isempty(inmoney)
        xdata=spaths(inmoney,step);
        regrmat=[ones(length(xdata),1),xdata,xdata.^2];
        ydata=cashflows(inmoney).*discountvector(exercisetime(inmoney)-step);
        a=regrmat\ydata;
        intrinsicvalue=k(step)-xdata;
        continuationvalue=regrmat*a;
        exercise=find(intrinsicvalue>continuationvalue);
        g=inmoney(exercise);
        cashflows(g)=intrinsicvalue(exercise);
        exercisetime(g)=step;
    end
end
prices=cashflows.*discountvector(exercisetime);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -