190 likes | 404 Views
金融商品設計與評價 hw7. 計財系大三 林奕全. Outline. 1.TriEurPut vs.TriAmcPut 2.Oilbond 3. Index Currency Option Notes. TriEurPut. function [ price,lattice ] = TriEurPut ( s0,X,r,T,sigma,N,lamda ) deltaT =T/N; u=exp( lamda *sigma* sqrt ( deltaT )); d=1/u;
E N D
金融商品設計與評價hw7 計財系大三 林奕全
Outline • 1.TriEurPut vs.TriAmcPut • 2.Oilbond • 3. Index Currency Option Notes
TriEurPut • function [ price,lattice ] = TriEurPut( s0,X,r,T,sigma,N,lamda ) • deltaT=T/N; • u=exp(lamda*sigma*sqrt(deltaT)); • d=1/u; • pu=1/(2*lamda^2)+(r-(sigma^2/2))*sqrt(deltaT)/(2*lamda*sigma); • pm=1-1/(lamda^2); • pd=1-pu-pm; • lattice=zeros(N+1,2*N+1);
for i=N-1:-1:0 • for j=1:2*i+1 • lattice(i+1,j)=exp(-r*deltaT)*(pd*lattice(i+2,j)+pm*lattice(i+2,j+1)+pu*lattice(i+2,j+2)); • end • end • price=lattice(1,1);
TriAmcPut • function [ price,lattice ] = TriAmcPut( s0,X,r,T,sigma,N,lamda ) • deltaT=T/N; • u=exp(lamda*sigma*sqrt(deltaT)); • d=1/u; • pu=1/(2*lamda^2)+(r-(sigma^2/2))*sqrt(deltaT)/(2*lamda*sigma); • pm=1-1/(lamda^2); • pd=1-pu-pm; • lattice=zeros(N+1,2*N+1);
for j=1:2*N+1 • lattice(N+1,j)=max(0,X-s0*(d^(N-j+1))); • end • for i=N-1:-1:0 • for j=1:2*i+1 • lattice(i+1,j)=max(X-s0*(d^(i-j+2)),exp(-r*deltaT)*(pd*lattice(i+2,j)+pm*lattice(i+2,j+1)+pu*lattice(i+2,j+2))); • end • end • price=lattice(1,1);
ComTriAmc/Eur/Bls Put • s0=50; • X=50; • r=0.04879; • sigma=0.2; • T=7/12; • N=20; • lamda=1.41421; • LatticeC1=zeros(1,N); • LatticeC2=zeros(1,N); • BlsC=blsprice(s0,X,r,T,sigma);
for i=(1:N) • [LatticeC1(i),tree1]=TriEurPut(s0,X,r,T,sigma,i,lamda); [LatticeC2(i),tree2]=TriAmcPut(s0,X,r,T,sigma,i,lamda); • end • plot(1:N,ones(1,N)*BlsC,'k'); • hold on; • plot(1:N,LatticeC2,'g'); • plot(1:N,LatticeC1,'b'); • xlabel('partition'); • ylabel('price'); • title('Compare BlsAmcEur option'); • legend('Bls','Amc','Eur');
Oilbond • function [ price,lattice ] = Oilbond( initial,r,T,sigma,N ) • deltaT=T/N; • u=exp(sigma*sqrt(deltaT)); • d=1/u; • p=(exp(r*deltaT)-d)/(u-d); • lattice=zeros(N+1,N+1); • for j=0:N • lattice(N+1,j+1)=initial*(u^j)*(d^(N-j));
if lattice(N+1,j+1)>=40 • lattice(N+1,j+1)=3550; • elseif lattice(N+1,j+1)<40&&lattice(N+1,j+1)>=25 • lattice(N+1,j+1)=(1000+(lattice(N+1,j+1)-25)*170); • else • lattice(N+1,j+1)=1000; • end • end
for i=N-1:-1:0 • for j=0:i • lattice(i+1,j+1)=exp(-r*deltaT)*(p*lattice(i+2,j+2)+(1-p)*lattice(i+2,j+1)); • end • end • price=lattice(1,1);
Compoilbond • Initial=20; • r=0.1; • T=1; • sigma=0.2; • N=80; • OilbondPic=zeros(1,N-45); • for(i=1:N-44) • OilbondPic(i)=Oilbond(i+19,r,T,sigma,N); • end • plot(20:55,OilbondPic);
Currbond • function [ price,lattice ] = Currbond( initial,r,T,sigma,N ) • deltaT=T/N; • u=exp(sigma*sqrt(deltaT)); • d=1/u; • p=(exp(r*deltaT)-d)/(u-d); • lattice=zeros(N+1,N+1); • for j=0:N • lattice(N+1,j+1)=initial*(u^j)*(d^(N-j));
if lattice(N+1,j+1)>=169 • lattice(N+1,j+1)=1000; • elseif lattice(N+1,j+1)<169&&lattice(N+1,j+1)>=84.5 • lattice(N+1,j+1)=1000-(((169/lattice(N+1,j+1)-1)*1000)); • else • lattice(N+1,j+1)=0; • end • end
for i=N-1:-1:0 • for j=0:i • lattice(i+1,j+1)=exp(-r*deltaT)*(p*lattice(i+2,j+2)+(1-p)*lattice(i+2,j+1)); • end • End • price=lattice(1,1);
CompCurrbond • r=0.1; • T=1; • sigma=0.2; • N=80; • CurrbondPic=zeros(1,N+150); • for(i=1:N+150) • CurrbondPic(i)=Currbond(i,r,T,sigma,N); • end • plot(1:230,CurrbondPic); • xlabel('initial'); • ylabel('price'); • title('Currbond price');