200 likes | 281 Views
金融商品設計與評價 hw11. 計財系大三 林奕全. Outline. 1. Down-and-in put 2.closed-form for other barrier option ( 以 Up-and-in/out call 為例 ) - 解析解 -MC (Up-and-in/out call) -MC( BlsEurCall ). AssetPaths1. function SPaths = AssetPaths1( s0,r,sigma,T,NSteps,NRepl )
E N D
金融商品設計與評價hw11 計財系大三 林奕全
Outline • 1. Down-and-in put • 2.closed-form for other barrier option (以 Up-and-in/out call為例) -解析解 -MC(Up-and-in/out call) -MC(BlsEurCall)
AssetPaths1 • function SPaths = AssetPaths1( s0,r,sigma,T,NSteps,NRepl ) • SPaths=zeros(NRepl,1+NSteps); • SPaths(:,1)=s0; • dt=T/NSteps; • nudt=(r-0.5*sigma^2)*dt; • sidt=sigma*sqrt(dt); • for i=1:NRepl • for j=1:NSteps • SPaths(i,j+1)= SPaths(i,j)*exp(nudt+sidt*randn); • end • end
DOPutMC(Down-and-in put) • function [P,CI,NCrossed ] =DOPutMC( s0,X,r,T,sigma,sb,NSteps,NRepl) • Payoff=zeros(NRepl,1); • NCrossed=0; • for i=1:NRepl • Path=AssetPaths1(s0,r,sigma,T,NSteps,1); • crossed=any(Path<=sb);
if crossed==0 • Payoff(i)=0; • NCrossed=NCrossed+1; • else • Payoff(i)=max(0,X-Path(NSteps+1)); • end • end • [P,aux,CI]=normfit(exp(-r*T)*Payoff)
s0=50; • X=50; • r=0.1; • T=2/12; • sigma=0.4; • sb=40; • NSteps=60; • NRepl=50000; • randn('seed',0); • [D0PutMC,CI,NCrossed]=DOPutMC(s0,X,r,T,sigma,sb,NSteps,NRepl); • D0PutMC • CI • NCrossed
BlsMcEurPut • function[Price,CI]=BlsMcEurPut(s0,X,r,T,sigma,NRepl) • nuT=(r-0.5*sigma^2)*T; • siT=sigma*sqrt(T); • DiscPayoff=exp(-r*T)*max(X-s0*exp(nuT+siT*randn(NRepl,1)),0); • [Price,Varprice,CI]=normfit(DiscPayoff);
s0=50; • X=50; • r=0.1; • T=2/12; • sigma=0.4; • NRepl1=50000; • randn('seed',0); • [MC50000,CI50000]=BlsMcEurPut(s0,X,r,T,sigma,NRepl)
UICall • function [UICallprice, UOCallprice]=UICall (s0,X,r,T,sigma,sb ) • lamda=(r/(sigma^2))+1/2; • y1=(log(sb/s0)+lamda*(sigma^2)*T)/(sigma*sqrt(T)); • x1=(log(s0/sb)+lamda*(sigma^2)*T)/(sigma*sqrt(T)); • y=(log(sb^2/(s0*X))+lamda*(sigma^2)*T)/(sigma*sqrt(T));
UICallprice=max(0,s0*normcdf(x1)-X*exp(-r*T)*normcdf(x1-sigma*sqrt(T))-s0*((sb/s0)^(2*lamda))*(normcdf(-y)-normcdf(-y1))+X*exp(-r*T)*((sb/s0)^(2*lamda-2))*(normcdf(-y+sigma*sqrt(T))-normcdf(-y1+sigma*sqrt(T))));UICallprice=max(0,s0*normcdf(x1)-X*exp(-r*T)*normcdf(x1-sigma*sqrt(T))-s0*((sb/s0)^(2*lamda))*(normcdf(-y)-normcdf(-y1))+X*exp(-r*T)*((sb/s0)^(2*lamda-2))*(normcdf(-y+sigma*sqrt(T))-normcdf(-y1+sigma*sqrt(T)))); • UOCallprice=blsprice(s0,X,r,T,sigma)-UICallprice; • end
s0=50; • X=50; • r=0.1; • T=2/12; • sigma=0.4; • sb=70; • NStep=60; • NRepl=50000; • sb1=sb*exp(0.5826*0.4*sqrt(1/12/30)); • [UICallprice, UOCallprice]=UICall (s0,X,r,T,sigma,sb1 )
UICallprice = • 0.7103 • UOCallprice = • 2.9465
UICallMC • function [P,CI,NCrossed ] =UICallMC( s0,X,r,T,sigma,sb,NSteps,NRepl) • Payoff=zeros(NRepl,1); • NCrossed=0; • for i=1:NRepl • Path=AssetPaths1(s0,r,sigma,T,NSteps,1); • crossed=any(Path>=sb); • if crossed==0 • Payoff(i)=0; • NCrossed=NCrossed+1; • else • Payoff(i)=max(0,Path(NSteps+1)-X); • end • end • [P,aux,CI]=normfit(exp(-r*T)*Payoff)
s0=50; • X=50; • r=0.1; • T=2/12; • sigma=0.4; • sb=70; • NRepl=50000; • NSteps=60; • randn('seed',0); • [P,CI,NCrossed ] =UICallMC( s0,X,r,T,sigma,sb,NSteps,NRepl)
UOCallMC • function [P,CI,NCrossed ] =UOCallMC( s0,X,r,T,sigma,sb,NSteps,NRepl) • Payoff=zeros(NRepl,1); • NCrossed=0; • for i=1:NRepl • Path=AssetPaths1(s0,r,sigma,T,NSteps,1); • crossed=any(Path>=sb); • if crossed==0 • Payoff(i)=max(0,Path(NSteps+1)-X); • else • Payoff(i)=0; • NCrossed=NCrossed+1; • end • end • [P,aux,CI]=normfit(exp(-r*T)*Payoff)
s0=50; • X=50; • r=0.1; • T=2/12; • sigma=0.4; • sb=70; • NRepl=50000; • NSteps=60; • randn('seed',0); • [P,CI,NCrossed ] =UOCallMC( s0,X,r,T,sigma,sb,NSteps,NRepl)
BlsMcEurCall( • function[Price,CI]=BlsMcEurCall(s0,X,r,T,sigma,NRepl) • nuT=(r-0.5*sigma^2)*T; • siT=sigma*sqrt(T); • DiscPayoff=exp(-r*T)*max(s0*exp(nuT+siT*randn(NRepl,1))-X,0); • [Price,Varprice,CI]=normfit(DiscPayoff);