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

上传人:牧羊曲112 文档编号:3602233 上传时间:2023-03-14 格式:DOCX 页数:2 大小:36.47KB
返回 下载 相关 举报
欧式期权二叉树定价MATLAB代码.docx_第1页
第1页 / 共2页
欧式期权二叉树定价MATLAB代码.docx_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

《欧式期权二叉树定价MATLAB代码.docx》由会员分享,可在线阅读,更多相关《欧式期权二叉树定价MATLAB代码.docx(2页珍藏版)》请在三一办公上搜索。

1、欧式期权二叉树定价MATLAB代码调用函数代码 function Price=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; for j=1:M for i=0:j S(i+1,j+1)= S0*u(j-i)*di; end end V=zeros(M+1,M+1); for i=0:M switch type casecall V(i+1,M+1)=max(S(i+1,M+1)-K,0)

2、; caseput V(i+1,M+1)=max(K-S(i+1,M+1),0); casestra V(i+1,M+1)=max(S(i+1,M+1)-K,0)+max(K-S(i+1,M+1),0); casebino V(i+1,M+1) =(S(i+1,M+1)K); end end for j=M-1:-1:0 for i=0:j V(i+1,j+1)=exp(-r*dt)*(p*V(i+1,j+2)+(1-p)*V(i+2,j+2); end end Price=V(1,1); 数据作图S0 = 6; K = 5; T = 1; r = 0.05; sigma = 0.20; fo

3、r M=1:100 type=call; Price=EuroOption(S0,K,T,r,M,type,sigma); Vec(M)=Price; end for M=1:100 type=put; Price=EuroOption(S0,K,T,r,M,type,sigma); Vep(M)=Price; end for M=1:100 type=call; Price=AmOption(S0,K,T,r,M,type,sigma); Vac(M)=Price; end for M=1:100 type= put; Price=AmOption(S0,K,T,r,M,type,sigma); Vap(M)=Price; end figure(1) plot(Vec,b); holdon plot(Vac,r); holdoff legend (Eurocall,Amcall); figure(2) plot(Vep,b); holdon plot(Vap,r); legend (Europut,Amput);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号