# 金融商品設計與評價hw11 計財系大三 林奕全.

## Presentation on theme: "金融商品設計與評價hw11 計財系大三 林奕全."— Presentation transcript:

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

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 [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,NRe pl); 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)

Price CI NCrossed Down-and-out Put (MC) 1.3600 [1.3303,1.3808] 7392 Down-and-in Put (MC) 1.4912 [1.4574,1.5251] 42608 Total 2.8512 50000 MCEurput 2.8296 [2.7941,2.8652] blsprice 2.8304

UICall formula

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
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 [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 [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);

Price CI NCrossed Up-and-in Call (MC) 0.7034 [ ] 48318 Closed form 0.7103 Up-and-out Call (MC) 2.9359 [2.8976,2.9742] 1694 2.9465 Total 3.6393 50000 MCEurCall 3.6781 [3.6295,3.7267] blsprice 3.6568