-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathAbstractPath.jl
270 lines (214 loc) · 6.32 KB
/
AbstractPath.jl
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
"""
abstract type AbstractPath end
An AbstractPath specifies the interface for path implementations.
This aims at providing the flexibility to add other types of paths in
the future.
"""
abstract type AbstractPath end
"""
length(p::AbstractPath)
Return the number of realisations represented by the AbstractPath
object.
We assume that model functions applied to an AbstractPath return a
vector of length(p) where p is the number realisations.
"""
function length(p::AbstractPath)
error("AbstractPath needs to implement length method.")
end
"""
numeraire(p::AbstractPath, t::ModelTime, curve_key::String)
Calculate the numeraire in the domestic currency.
We allow for curve-specific numeraire calculation e.g. to allow
for trade-specific discounting in AMC valuation.
"""
function numeraire(p::AbstractPath, t::ModelTime, curve_key::String)
error("AbstractPath needs to implement numeraire method.")
end
"""
bank_account(p::AbstractPath, t::ModelTime, key::String)
Calculate a continuous compounded bank account value.
"""
function bank_account(p::AbstractPath, t::ModelTime, key::String)
error("AbstractPath needs to implement bank_account method.")
end
"""
zero_bond(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)
Calculate a zero coupon bond price.
"""
function zero_bond(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)
error("AbstractPath needs to implement zero_bond method.")
end
"""
zero_bond(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)
Calculate a zero coupon bond prices.
"""
function zero_bonds(p::AbstractPath, t::ModelTime, T::AbstractVector, key::String)
error("AbstractPath needs to implement zero_bonds method.")
end
"""
compounding_factor(p::AbstractPath, t::ModelTime, T1::ModelTime, T2::ModelTime, key::String)
Calculate a compounding factor P(t,T1) / P(t,T2).
"""
function compounding_factor(p::AbstractPath, t::ModelTime, T1::ModelTime, T2::ModelTime, key::String)
error("AbstractPath needs to implement compounding_factor method.")
end
"""
asset(p::AbstractPath, t::ModelTime, key::String)
Calculate asset price.
"""
function asset(p::AbstractPath, t::ModelTime, key::String)
error("AbstractPath needs to implement asset method.")
end
"""
forward_asset(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)
Calculate forward asset price as expectation in T-forward measure.
"""
function forward_asset(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)
error("AbstractPath needs to implement forward_asset method.")
end
"""
forward_asset_and_zero_bonds(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)
Calculate asset and zero bond components for forward asset price calculation.
"""
function forward_asset_and_zero_bonds(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)
error("AbstractPath needs to implement forward_asset_and_zero_bonds method.")
end
"""
fixing(p::AbstractPath, t::ModelTime, key::String)
Return a fixing from a term structure.
This is used to handle fixings for indices etc.
"""
function fixing(p::AbstractPath, t::ModelTime, key::String)
error("AbstractPath needs to implement fixing method.")
end
"""
asset_convexity_adjustment(
p::AbstractPath,
t::ModelTime,
T0::ModelTime,
T1::ModelTime,
T2::ModelTime,
key::String
)
Return the convexity adjustment for a YoY asset payoff.
"""
function asset_convexity_adjustment(
p::AbstractPath,
t::ModelTime,
T0::ModelTime,
T1::ModelTime,
T2::ModelTime,
key::String
)
error("AbstractPath needs to implement asset_convexity_adjustment method.")
end
"""
forward_index(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)
Expectation E_t^T[S_T] of a tradeable asset.
"""
function forward_index(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)
error("AbstractPath needs to implement forward_index method.")
end
"""
index_convexity_adjustment(
p::AbstractPath,
t::ModelTime,
T0::ModelTime,
T1::ModelTime,
T2::ModelTime,
key::String
)
Return the convexity adjustment for a YoY index payoff.
"""
function index_convexity_adjustment(
p::AbstractPath,
t::ModelTime,
T0::ModelTime,
T1::ModelTime,
T2::ModelTime,
key::String
)
error("AbstractPath needs to implement index_convexity_adjustment method.")
end
"""
future_index(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)
Expectation E_t^Q[F(T,T)] of a Future index/price.
"""
function future_index(p::AbstractPath, t::ModelTime, T::ModelTime, key::String)
error("AbstractPath needs to implement future_index method.")
end
"""
swap_rate_variance(
p::AbstractPath,
t::ModelTime,
T::ModelTime,
swap_times::AbstractVector,
yf_weights::AbstractVector,
key::String,
)
Calculate the normal model variance of a swap rate via Gaussian
swap rate approximation.
"""
function swap_rate_variance(
p::AbstractPath,
t::ModelTime,
T::ModelTime,
swap_times::AbstractVector,
yf_weights::AbstractVector,
key::String,
)
error("AbstractPath needs to implement swap_rate_variance method.")
end
"""
forward_rate_variance(
p::AbstractPath,
t::ModelTime,
T::ModelTime,
T0::ModelTime,
T1::ModelTime,
key::String,
)
Calculate the lognormal variance for a compounding factor of a forward-looking
or backward-looking forward rate.
"""
function forward_rate_variance(
p::AbstractPath,
t::ModelTime,
T::ModelTime,
T0::ModelTime,
T1::ModelTime,
key::String,
)
error("AbstractPath needs to implement forward_rate_variance method.")
end
"""
asset_variance(
p::AbstractPath,
t::ModelTime,
T::ModelTime,
key::String,
)
Calculate the lognormal model variance of an asset spot price
over the time period [t,T].
"""
function asset_variance(
p::AbstractPath,
t::ModelTime,
T::ModelTime,
key::String,
)
error("AbstractPath needs to implement asset_variance method.")
end
"""
@enum(
PathInterpolation,
NoPathInterpolation,
LinearPathInterpolation,
)
PathInterpolation encodes how simulated states can be interpolates.
"""
@enum(
PathInterpolation,
NoPathInterpolation,
LinearPathInterpolation,
)