-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathPricingOptionMC.m
36 lines (33 loc) · 947 Bytes
/
PricingOptionMC.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function [Price, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier)
%UNTITLED16 Summary of this function goes here
% Detailed explanation goes here
%% compute the payoff
if nargin == 9
switch optionType
case 'Call'
Payoff = @(x) subplus(x(:,end) - K);
case 'Put'
Payoff = @(x) subplus(K - x(:,end));
otherwise
end
elseif nargin > 9
[ Payoff ] = optionPayoff(K,optionType,barrierType, barrier);
end
%% simulate the underlying
switch model
case 'BS'
[ S, check] = assetBS( S0,r,T,param,Nsim,Nstep);
case 'Merton'
[ S, check ] = assetMerton(S0,r,T,param,Nsim,Nstep);
case 'Kou'
[ S, check ] = assetKou(S0,r,T,param,Nsim,Nstep);
case 'VG'
[ S, check ] = assetVG(S0,r,T,param,Nsim,Nstep);
case 'NIG'
[ S, check ] = assetNIG(S0,r,T,param,Nsim,Nstep);
end
%% discounted payoff
DiscountedPayoff = exp(-r * T) * Payoff(S);
[Price, ~, IC] = normfit(DiscountedPayoff);
end