-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrunBarrierOption.m
205 lines (204 loc) · 7.04 KB
/
runBarrierOption.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
% runBarrierOption
% pricing barrier option
% REMARK : the MC approximation strongly depends on the time horizon, if
% it's short (T<1) the approxiamtion is good if it's large the
% approximation is really poor
clc; close all; clear variables;
K=100; S0=100; r=0.3; T=1;
Nsim = 2e5; Nstep = 200;N = 500; M = 552;
rng(1992);
model = 'Kou';
optionType = 'Call';
barrierType = 'DO';
NumMethod = 'implicit';
theta = 1;
barrier = 70;
epsilon = 0.01;
switch optionType
case 'Call'
switch barrierType
case 'DO'
switch model
case 'BS'
param = 0.6;
% 1) closed formula
[ PriceExact] = barrierBS( S0, r, T, param,barrier, K, barrierType);
% 2) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 3) PDE LogPrice implementation short
[pricePDELogPrice] = FDLogPrice1( S0,K,r,T,N,M,param,optionType,NumMethod,theta,...
barrierType,barrier);
% 4) PDE LogPrice implementation full
[pricePDELogPrice2] = FDLogPrice2( S0,K,r,T,N,M,param,optionType,NumMethod,theta,...
barrierType,barrier);
% 5) PDE Price short implementation
[pricePDEPrice] = FDPrice1( S0,K,r,T,N,M,param,optionType,NumMethod,theta,...
barrierType,barrier);
% 6) PDE FEM LopgPrice
[priceFEM] = FEMLogPrice2( S0,K,r,T,N,M,param,optionType,NumMethod,theta,...
barrierType,barrier);
case 'Merton'
% sigma, lambda, mu, delta
param = [0.5;0.6;0.1;0.1];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 2) PIDE logmoneyness --> don't use this with barrier
% option since the barrier is time-dependent
% [pricePIDElogmon] = FDLevyLogMoneyness1( S0,K,r,T,N,M,param,model,optionType,NumMethod,theta,...
% barrierType,barrier);
% 3) PIDE logprice
[pricePIDElogprice] = FDLevyLogPrice1( S0,K,r,T,N,M,param,model,optionType,NumMethod,theta,...
barrierType,barrier);
case 'Kou'
param = [0.6;0.5;9;6;0.3];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 3) PIDE logprice short implementation
[pricePIDElogprice] = FDLevyLogPrice1( S0,K,r,T,N,M,param,model,optionType,NumMethod,theta,...
barrierType,barrier);
case 'VG'
% theta_VG, sigma_VG, kappa
param = [0.03;0.12;0.2;0];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 3) PIDE logpriceFwdPrice
[pricePIDEprice] = FDLevyLogpriceFwdprice1AI( S0,K,r,T,N,M,param,model,optionType,NumMethod,theta,...
epsilon,barrierType,barrier);
case 'NIG'
param = [0.2;0.8];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
otherwise
end
case 'UO'
switch model
case 'BS'
param = 0.6;
% 2) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 5) PDE Price short implementation
[pricePDEPrice] = FDPrice1( S0,K,r,T,N,M,param,optionType,NumMethod,theta,...
barrierType,barrier);
case 'Merton'
param = [0.5;0.6;0.1;0.1];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
case 'Kou'
param = [0.6;0.01;9;6;0.3];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
case 'VG'
% theta_VG, sigma_VG, kappa
param = [0.03;0.12;0.2;0];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
case 'NIG'
param = [0.2;0.8];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
otherwise
end
otherwise
end
case 'Put'
switch barrierType
case 'DO'
switch model
case 'BS'
param = 0.6;
% 2) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 5) PDE Price short implementation
[pricePDEPrice] = FDPrice1( S0,K,r,T,N,M,param,optionType,NumMethod,theta,...
barrierType,barrier);
model = 'Merton'; param = [0.6;0.;0.1;0.1];
case 'Merton'
param = [0.5;0.6;0.1;0.1];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
case 'Kou'
param = [0.6;0.01;9;6;0.3];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
case 'VG'
% theta_VG, sigma_VG, kappa
param = [0.03;0.12;0.2;0];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
case 'NIG'
param = [0.2;0.8];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
otherwise
end
case 'UO'
switch model
case 'BS'
param = 0.6;
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 2) PDE Price short implementation
[pricePDEPrice] = FDPrice1( S0,K,r,T,N,M,param,optionType,NumMethod,theta,...
barrierType,barrier);
% 3) PDE logprice
[pricePDElogprice] = FDLogPrice1( S0,K,r,T,N,M,param,optionType,NumMethod,theta,...
barrierType,barrier);
% check model merton
model = 'Merton'; param = [0.6;0.;0.1;0.1];
case 'Merton'
param = [0.5;0.6;0.1;0.1];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
case 'Kou'
param = [0.6;0.01;9;6;0.3];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
case 'VG'
% theta_VG, sigma_VG, kappa
param = [0.03;0.12;0.2;0.2];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 3) PIDE logpriceFwdPrice
[pricePIDEprice] = FDLevyLogpriceFwdprice1AI( S0,K,r,T,N,M,param,model,optionType,NumMethod,theta,...
epsilon,barrierType,barrier);
case 'NIG'
param = [0.2;0.8];
% 1) MC
[PriceMC, check, IC] = PricingOptionMC( S0,r,T,K,param,Nsim,Nstep,...
model,optionType, barrierType, barrier);
% 4) PIDE
otherwise
end
otherwise
end
end