HW 10

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 7

max{ A X ,0}

ASIA OPTION

function
P=AsiaAssetPaths2(S0,mu,sigma,T,NSteps,
NRepl,x,r)
SPaths = zeros(NRepl, 1+NSteps);
SPaths(:,1) = S0;
dt = T/NSteps;
nudt = (mu-0.5*sigma^2)*dt;
sidt = sigma*sqrt(dt);

Result:

AsiaAssetPaths2(50,0.22,0.2,3,100,1000,50

for i=1:NRepl
for j=1:NSteps
SPaths(i,j+1)=SPaths(i,j)*exp(nudt +
sidt*randn);
end
end
Payoff=max((mean(SPaths'))'-x,0)
P = mean( exp(-r*T) * (Payoff));

ans =
15.8813

ASIA OPTION
max{ S (T ) A,0}
function
P=AsiaAssetPaths1(S0,mu,sigma,T,NSteps,
NRepl,r)

Result:

SPaths = zeros(NRepl, 1+NSteps);


SPaths(:,1) = S0;
dt = T/NSteps;
nudt = (mu-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
Payoff=max(SPaths(:,NSteps+1)(mean(SPaths'))',0)
P = mean( exp(-r*T) * Payoff);

>>
AsiaAssetPaths1(50,0.22,0.2,3,100,10
00,0.02)
ans =
24.9476

LOOKBACK PUT OPTION

function [Price, VarPrice, CI] = lo


okbackputoption(S0,r,T,sigma,NS
teps,NRepl)
Payoff = zeros(1,NRepl);
SPath=AssetPaths(S0,r,sigma,T,N
Steps,NRepl);
for i=1:NRepl
Payoff(i) = max(0, max(SPath
(i,:)-SPath(i,NSteps+1)));
end
[Price, VarPrice, CI] = normfit( ex
p(-r*T) * Payoff)

>>
lookbackcalloption(50,0.01,3,0.2,100,
10)
Price =
13.9150
VarPrice =
8.7873
CI =
7.6289
20.2010

LOOKBACK CALL OPTION

function P = lookbackcalloption(S0
,r,T,sigma,NSteps,NRepl)
Payoff = zeros(1,NRepl);
SPath=AssetPaths(S0,r,sigma,T,NSt
eps,NRepl);
for i=1:NRepl
Payoff(i) = max(0, SPath(i,NSteps
+1)-min(SPath(i,:)));
end
P = normfit( exp(-r*T) * Payoff)

>>
lookbackputoption(50,0.01,3,0.2,100
)
Price =
12.4331
VarPrice =
9.8314
CI =
5.4001
19.4660

AsianHalton

function SPaths=HaltonPaths(S0,mu,sigma,T,NSteps,NRepl)
dt = T/NSteps;
nudt = (mu-0.5*sigma^2)*dt;
sidt = sigma*sqrt(dt);
NRepl = 2*ceil(NRepl/2); % make sure it's even
% Use Box Muller to generate standard normals
RandMat = zeros(NRepl, NSteps);
seeds = myprimes(2*NSteps);
Base1 = seeds(1:NSteps);
Base2 = seeds((NSteps+1):(2*NSteps));
for i=1:NSteps
H1 = GetHalton(NRepl/2,Base1(i));
H2 = GetHalton(NRepl/2,Base2(i));
VLog = sqrt(-2*log(H1));
Norm1 = VLog .* cos(2*pi*H2);
Norm2 = VLog .* sin(2*pi*H2);
RandMat(:,i) = [Norm1 ; Norm2];
end

AsianHalton

Increments = nudt + sidt*RandMat;


LogPaths = cumsum([log(S0)*ones(NRepl,1) , Increments] , 2);
SPaths = exp(LogPaths);
% AsianHalton.m
function P = AsianHalton(S0,X,r,T,sigma,NSamples,NRepl)
Payoff = zeros(NRepl,1);
Path=HaltonPaths(S0,r,sigma,T,NSamples,NRepl);
Payoff = max(0, mean(Path(:,2:(NSamples+1)),2) - X);
P = normfit( exp(-r*T) * Payoff);

function [P,aux,ci]= AsianHalton(S0,X,r,T,sigma,NSamples,NRepl)


Payoff = zeros(NRepl,1);
Path=HaltonPaths(S0,r,sigma,T,NSamples,NRepl);
Payoff = max(0, mean(Path(:,2:(NSamples+1)),2) - X);
[P,aux,ci] = normfit( exp(-r*T) * Payoff)

AsianHalton

>> [P,aux,ci]= AsianHalton(50,50,0.01,2,0.2,100,100)

P=

1.9199e+03

aux =
4.7639e+03

ci =

1.0e+03 *

0.9747
2.8652

P=
1.9199e+03

You might also like