16
金金金金金金金金金 hw10 金金金金金 金金金

金融商品設計與評價 hw10

Embed Size (px)

DESCRIPTION

金融商品設計與評價 hw10. 計財系大三 林奕全. Outline. 1.CBValue - Putable -Callable - Putable + Callable 2. - Rand+BoxMuller - Halton+BoxMuller:Eur Put. Putable. function [ price,lattice ] = CBValuePut ( s0,r,T,sigma,N,Q,I,P,tau ) deltaT =T/N; u=exp(sigma* sqrt ( deltaT )); d=1/u; - PowerPoint PPT Presentation

Citation preview

Page 1: 金融商品設計與評價 hw10

金融商品設計與評價 hw10

計財系大三 林奕全

Page 2: 金融商品設計與評價 hw10

Outline 1.CBValue -Putable -Callable - Putable+ Callable 2. -Rand+BoxMuller -Halton+BoxMuller:Eur Put

Page 3: 金融商品設計與評價 hw10

Putable function [ price,lattice ] =

CBValuePut( s0,r,T,sigma,N,Q,I,P,tau ) 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)=max(I/Q,s0*(u^j)*(d^(N-

j))); end

Page 4: 金融商品設計與評價 hw10

for i=N-1:-1:0 for j=0:i lattice(i+1,j+1)=max(s0*u^(j)*d^(i-

j),exp(-r*deltaT)*(p*lattice(i+2,j+2)+(1-p)*lattice(i+2,j+1)));

if i==tau-1

lattice(i+1,j+1)=max(lattice(i+1,j+1),P/Q); end end end price=lattice(1,1)*Q;

Page 5: 金融商品設計與評價 hw10

>> CBValue(35, 0.02, 5, 0.3, 100, 2500, 100000)

ans =

1.1234e+05

>> CBValuePut(35, 0.02, 5, 0.3, 100, 2500, 100000,102000,50)

ans =

1.1399e+05

Page 6: 金融商品設計與評價 hw10

Callable function [ price,lattice ] =

CBValueCall( s0,r,T,sigma,N,Q,I,C ) deltaT=T/N; u=exp(sigma*sqrt(deltaT)); d=1/u; p=(exp(r*deltaT)-d)/(u-d); lattice=zeros(N+1,N+1);

Page 7: 金融商品設計與評價 hw10

for j=0:N lattice(N+1,j+1)=max(I/Q,s0*(u^j)*(d^(N-

j))); end for i=N-1:-1:0 for j=0:i lattice(i+1,j+1)=max(s0*u^(j)*d^(i-

j),min(exp(-r*deltaT)*(p*lattice(i+2,j+2)+(1-p)*lattice(i+2,j+1)),C/Q));

end end price=lattice(1,1)*Q;

Page 8: 金融商品設計與評價 hw10

>> CBValue(35, 0.02, 5, 0.3, 100, 2500, 100000)

ans =

1.1234e+05

>> CBValueCall(35, 0.02, 5, 0.3, 100, 2500, 100000,102000)

ans =

9.8619e+04

Page 9: 金融商品設計與評價 hw10

Putable+ Callable function [ price,lattice ] =

CBValueCallPut( s0,r,T,sigma,N,Q,I,C,P,tau ) 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)=max(I/Q,s0*(u^j)*(d^(N-

j))); end

Page 10: 金融商品設計與評價 hw10

for i=N-1:-1:0 for j=0:i lattice(i+1,j+1)=max(s0*u^(j)*d^(i-

j),min(exp(-r*deltaT)*(p*lattice(i+2,j+2)+(1-p)*lattice(i+2,j+1)),C/Q));

if i==tau-1

lattice(i+1,j+1)=max(lattice(i+1,j+1),P/Q); end end end price=lattice(1,1)*Q;

Page 11: 金融商品設計與評價 hw10

>> CBValue(35, 0.02, 5, 0.3, 100, 2500, 100000)

ans = 1.1234e+05=112,340

>> CBValuePut(35, 0.02, 5, 0.3, 100, 2500, 100000,102000,50)

ans = 1.1399e+05=113,990

>> CBValueCall(35, 0.02, 5, 0.3, 100, 2500, 100000,102000)

ans = 9.8619e+04=98,619

>> CBValueCallPut(35, 0.02, 5, 0.3, 100, 2500, 100000,102000,102000,50)

ans = 1.0002e+05=100,020

Page 12: 金融商品設計與評價 hw10

Halton+BoxMuller:Eur Put function Seq = GetHalton( HowMany,Base) Seq=zeros(HowMany,1); NumBits=1+ceil(log(HowMany)/log(Base)); VetBase=Base.^(-(1:NumBits)); WorkVet=zeros(1,NumBits); for i=1:HowMany j=1; ok=0;

Page 13: 金融商品設計與評價 hw10

while ok==0 WorkVet(j)=WorkVet(j)+1; if WorkVet(j)<Base ok=1; else WorkVet(j)=0; j=j+1; end end Seq(i)=dot( WorkVet,VetBase); end

Page 14: 金融商品設計與評價 hw10

function Price = BlshaltonEurPut(s0,X,r,T,sigma,Npoints,Base1,Base2)

nuT=(r-0.5*sigma^2)*T; siT=sigma*sqrt(T); H1=GetHalton(ceil(Npoints/2),Base1); H2=GetHalton(ceil(Npoints/2),Base2); Vlog=sqrt(-2*log(H1)); Norm1=Vlog.*cos(2*pi*H2); Norm2=Vlog.*sin(2*pi*H2); Norm=[Norm1;Norm2]; DiscPayoff=exp(-r*T)*max(0,X-

s0*exp(nuT+siT*Norm)); Price=mean(DiscPayoff);

Page 15: 金融商品設計與評價 hw10

s0=50; X=52; r=0.1; sigma=0.4; Nrepl=5000; T=5/12; Base11=2; Base12=7; [Call,Put]=blsprice(s0,X,r,T,sigma); Halton27=BlshaltonEurPut(s0,X,r,T,sigma,Nrepl,Base11,

Base12); Put Halton27

Page 16: 金融商品設計與評價 hw10