1 / 3
文档名称:

欧式期权二叉树定价MATLAB代码.doc

格式:doc   大小:15KB   页数:3页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

欧式期权二叉树定价MATLAB代码.doc

上传人:cjl201702 2020/2/20 文件大小:15 KB

下载得到文件列表

欧式期权二叉树定价MATLAB代码.doc

文档介绍

文档介绍:调用函数代码functionPrice=EuroOption(S0,K,T,r,M,type,sigma)dt=T/M;u=exp(sqrt(dt)*sigma);d=1/u;p=(exp(r*dt)-d)/(u-d);S=zeros(M+1,M+1);S(1,1)=S0;forj=1:Mfori=0:jS(i+1,j+1)=S0*u^(j-i)*d^i;endendV=zeros(M+1,M+1);fori=0:Mswitchtypecase'call'V(i+1,M+1)=max(S(i+1,M+1)-K,0);case'put'V(i+1,M+1)=max(K-S(i+1,M+1),0);case'stra'V(i+1,M+1)=max(S(i+1,M+1)-K,0)+max(K-S(i+1,M+1),0);case'bino'V(i+1,M+1)=(S(i+1,M+1)>K);endendforj=M-1:-1:0fori=0:jV(i+1,j+1)=exp(-r*dt)*(p*V(i+1,j+2)+(1-p)*V(i+2,j+2));endendPrice=V(1,1);数据作图S0=6;K=5;T=1;r=;sigma=;forM=1:100type='call';Price=EuroOption(S0,K,T,r,M,type,sigma);Vec(M)=Price;endforM=1:100type='put';Price=EuroOption(S0,K,T,r,M,type,sigma);Vep(M)=Price;endforM=1:100type='call';Price=AmOption(S0,K,T,r,M,type,sigma);Vac(M)=Price;endforM=1:100type='put';Price=AmOption(S0,K,T,r,M,type,sigma);Vap(M)=Price;endfigure(1)plot(Vec,'b');holdonplot(Vac,'r');holdofflegend('Eurocall','Amcall');figure(2)plot(Vep,'b');holdonplot(Vap,'r');legend('Europut','Amput');