Professional Documents
Culture Documents
hw6 101071010
hw6 101071010
101071010
LatticeOilBond.m
CompLatticeOilBond.m
r=0.02;T=1;sigma=0.2;N=200;
i=1;
for s=20:1:60
Oilbond (i) = LatticeOilBond(s,r,T,sigma,N);
i=i+1;
end
plot(20:1:60, Oilbond);
xlabel('S0')
ylabel('price')
title('Oilbond Price')
Oilbond Price
3500
3000
price
2500
2000
1500
1000
20
25
30
35
40
S0
45
50
55
S0
60
LatticeCurrencyBond.m
CompLatticeCurrencyBond.m
r=0.02;T=1;sigma=0.5;N=200;
CurrencyBond=zeros(1,300);
for i=1:300
CurrencyBond (i) = LatticeCurrencyBond(i,r,T,sigma,N);
end
plot(1:300, CurrencyBond);
xlabel('S0')
ylabel('price')
title('CurrencyBond Price')
CurrencyBond Price
1000
900
800
700
price
600
500
400
300
200
100
50
100
150
S0
200
250
S0
300
BlsMCPut.m
BlsMCAVPut.m
CompBlsMCAVPut.m
S0=50;
X=52;
r=0.1;
T=5/12;
sigma=0.4;
NRepl1=100000;
NRepl2=200000;
[BlsC,BlsP]=blsprice(S0,X,r,T,sigma);
randn('seed',0);
[MCPut200000, CI1] = BlsMCPut(S0,X,r,T,sigma,NRepl2);
randn('seed',0);
[MCAVPut100000, CI2] = BlsMCAVPut(S0,X,r,T,sigma,NRepl1);
BlsP
MCPut200000
CI1
MCAVPut100000
CI2
Monte Carlo
BlsPut
MCPi
1
=1
1/4=Pi/4
Monte CarloNC
Pi/4:1=C:N
Pi=4C/N
MCPi.m
function pi=MCpi(n)
x=rand(1,n);
y=rand(1,n);
c=x.^2+y.^2;
K=logical(c<=1);
S=sum(K);
pi=4*S/n;
Monte Carlo
Pi3.1416