@@ -7,25 +7,7 @@ dW_1 dW_2 = ρ dt
7
7
```
8
8
9
9
"""
10
- mutable struct HestonProblem{uType,tType,tupType,isinplace,NP,F,F2,C,ND,MM} <: DiffEqBase.AbstractSDEProblem{uType,tType,isinplace,ND}
11
- μ:: tType
12
- κ:: tType
13
- Θ:: tType
14
- σ:: tType
15
- ρ:: tType
16
- u0:: uType
17
- tspan:: tupType
18
- p:: Nothing
19
- f:: F
20
- g:: F2
21
- noise:: NP
22
- callback:: C
23
- noise_rate_prototype:: ND
24
- mass_matrix:: MM
25
- seed:: UInt64
26
- end
27
-
28
- function HestonProblem (μ,κ,Θ,σ,ρ,u0,tspan;callback = CallbackSet (),seed= UInt64 (0 ))
10
+ function HestonProblem (μ,κ,Θ,σ,ρ,u0,tspan;seed= UInt64 (0 ),kwargs... )
29
11
f = function (du,u,p,t)
30
12
du[1 ] = μ* u[1 ]
31
13
du[2 ] = κ* (Θ- u[2 ])
@@ -35,19 +17,16 @@ function HestonProblem(μ,κ,Θ,σ,ρ,u0,tspan;callback = CallbackSet(),seed=UIn
35
17
du[2 ] = Θ*√ u[2 ]
36
18
end
37
19
Γ = [1 ρ;ρ 1 ] # Covariance Matrix
38
- mass_matrix= I
39
20
noise_rate_prototype = nothing
21
+
40
22
if seed == 0
41
23
seed = rand (UInt64)
42
24
end
43
- noise = CorrelatedWienerProcess! (Γ,tspan[1 ],zeros (2 ),zeros (2 ),rng = Xorshifts. Xoroshiro128Plus (seed))
44
- isinplace = true
45
- HestonProblem{typeof (u0),eltype (tspan),typeof (tspan),isinplace,
46
- typeof (noise),
47
- typeof (f),typeof (g),
48
- typeof (callback),typeof (noise_rate_prototype),
49
- typeof (mass_matrix)}(μ,κ,Θ,σ,ρ,u0,tspan,nothing ,
50
- f,g,noise,callback,noise_rate_prototype,mass_matrix,seed)
25
+ noise = CorrelatedWienerProcess! (Γ,tspan[1 ],zeros (2 ),zeros (2 ),
26
+ rng = Xorshifts. Xoroshiro128Plus (seed))
27
+
28
+ sde_f = SDEFunction {true} (f,g)
29
+ SDEProblem (sde_f,g,u0,tspan,noise= noise,seed= seed,kwargs... )
51
30
end
52
31
53
32
@doc doc"""
56
35
57
36
Solves for ``log S(t)``.
58
37
"""
59
- mutable struct GeneralizedBlackScholesProblem{uType,tType,tupType,isinplace,NP,F,F2,thetaType,qType,rType,C,ND,MM} <: DiffEqBase.AbstractSDEProblem{uType,tType,isinplace,ND}
60
- r:: rType
61
- q:: qType
62
- Θ:: thetaType
63
- σ:: tType
64
- u0:: uType
65
- tspan:: tupType
66
- p:: Nothing
67
- f:: F
68
- g:: F2
69
- noise:: NP
70
- callback:: C
71
- noise_rate_prototype:: ND
72
- mass_matrix:: MM
73
- seed:: UInt64
74
- end
75
-
76
- function GeneralizedBlackScholesProblem (r,q,Θ,σ,u0,tspan;callback = CallbackSet (),seed= UInt64 (0 ))
38
+ function GeneralizedBlackScholesProblem (r,q,Θ,σ,u0,tspan;kwargs... )
77
39
f = function (u,p,t)
78
40
r (t) - q (t) - Θ (t,exp (u))^ 2 / 2
79
41
end
80
42
g = function (u,p,t)
81
43
σ
82
44
end
83
- noise_rate_prototype = nothing
84
- noise = nothing
85
- isinplace = false
86
- mass_matrix= I
87
- GeneralizedBlackScholesProblem{typeof (u0),eltype (tspan),typeof (tspan),isinplace,
88
- typeof (noise),
89
- typeof (f),typeof (g),
90
- typeof (Θ),typeof (q),typeof (r),
91
- typeof (callback),typeof (noise_rate_prototype),typeof (mass_matrix)}(
92
- r,q,Θ,σ,u0,tspan,nothing ,f,g,noise,callback,
93
- noise_rate_prototype,mass_matrix,seed)
45
+ SDEProblem {false} (f,g,u0,tspan;kwargs... )
94
46
end
95
47
96
48
@doc doc"""
@@ -124,79 +76,29 @@ BlackScholesProblem(r,Θ,σ,u0,tspan;callback = CallbackSet(),
124
76
``dx = a(b(t)-x)dt + σ dW_t``
125
77
126
78
"""
127
- mutable struct ExtendedOrnsteinUhlenbeckProblem{uType,tType,tupType,isinplace,NP,F,F2,C,ND,MM} <: DiffEqBase.AbstractSDEProblem{uType,tType,isinplace,ND}
128
- a:: tType
129
- b:: tType
130
- σ:: tType
131
- u0:: uType
132
- tspan:: tupType
133
- p:: Nothing
134
- f:: F
135
- g:: F2
136
- noise:: NP
137
- callback:: C
138
- noise_rate_prototype:: ND
139
- mass_matrix:: MM
140
- seed:: UInt64
141
- end
142
-
143
- function ExtendedOrnsteinUhlenbeckProblem (a,b,σ,u0,tspan;callback = CallbackSet (),seed= UInt64 (0 ))
79
+ function ExtendedOrnsteinUhlenbeckProblem (a,b,σ,u0,tspan;kwargs... )
144
80
f = function (u,p,t)
145
81
a* (b (t)- u)
146
82
end
147
83
g = function (u,p,t)
148
84
σ
149
85
end
150
- noise_rate_prototype = nothing
151
- noise = nothing
152
- isinplace = false
153
- mass_matrix= I
154
- ExtendedOrnsteinUhlenbeckProblem{typeof (u0),eltype (tspan),typeof (tspan),isinplace,
155
- typeof (noise),
156
- typeof (f),typeof (g),
157
- typeof (callback),typeof (noise_rate_prototype),
158
- typeof (mass_matrix)}(a,b,σ,u0,tspan,nothing ,f,g,noise,
159
- callback,noise_rate_prototype,mass_matrix,seed)
86
+ SDEProblem {false} (f,g,u0,tspan;kwargs... )
160
87
end
161
88
162
89
@doc doc"""
163
90
164
91
``dx = a(r-x)dt + σ dW_t``
165
92
166
93
"""
167
- mutable struct OrnsteinUhlenbeckProblem{uType,tType,tupType,isinplace,NP,F,F2,C,ND,MM} <: DiffEqBase.AbstractSDEProblem{uType,tType,isinplace,ND}
168
- a:: tType
169
- r:: tType
170
- σ:: tType
171
- u0:: uType
172
- tspan:: tupType
173
- p:: Nothing
174
- f:: F
175
- g:: F2
176
- noise:: NP
177
- callback:: C
178
- noise_rate_prototype:: ND
179
- mass_matrix:: MM
180
- seed:: UInt64
181
- end
182
-
183
- function OrnsteinUhlenbeckProblem (a,r,σ,u0,tspan;callback = CallbackSet (),seed= UInt64 (0 ))
94
+ function OrnsteinUhlenbeckProblem (a,r,σ,u0,tspan;kwargs... )
184
95
f = function (u,p,t)
185
96
a* (r- u)
186
97
end
187
98
g = function (u,p,t)
188
99
σ
189
100
end
190
- noise = nothing
191
- isinplace = false
192
- noise_rate_prototype = nothing
193
- mass_matrix= I
194
- OrnsteinUhlenbeckProblem{typeof (u0),eltype (tspan),typeof (tspan),isinplace,
195
- typeof (noise),
196
- typeof (f),typeof (g),
197
- typeof (callback),typeof (noise_rate_prototype),
198
- typeof (mass_matrix)}(a,r,σ,u0,tspan,nothing ,f,g,noise,callback,
199
- noise_rate_prototype,mass_matrix,seed)
101
+ SDEProblem {false} (f,g,u0,tspan;kwargs... )
200
102
end
201
103
202
104
@@ -205,74 +107,27 @@ end
205
107
``dx = μ dt + σ dW_t``
206
108
207
109
"""
208
- mutable struct GeometricBrownianMotionProblem{uType,tType,tupType,isinplace,NP,F,F2,C,ND,MM} <: DiffEqBase.AbstractSDEProblem{uType,tType,isinplace,ND}
209
- μ:: tType
210
- σ:: tType
211
- u0:: uType
212
- tspan:: tupType
213
- p:: Nothing
214
- f:: F
215
- g:: F2
216
- noise:: NP
217
- callback:: C
218
- noise_rate_prototype:: ND
219
- mass_matrix:: MM
220
- seed:: UInt64
221
- end
222
-
223
- function OrnsteinUhlenbeckProblem (μ,σ,u0,tspan;callback = CallbackSet (),seed= UInt64 (0 ))
110
+ function GeometricBrownianMotionProblem (μ,σ,u0,tspan;kwargs... )
224
111
f = function (u,p,t)
225
112
μ
226
113
end
227
114
g = function (u,p,t)
228
115
σ
229
116
end
230
- noise = nothing
231
- isinplace = false
232
- mass_matrix= I
233
- noise_rate_prototype = nothing
234
- OrnsteinUhlenbeckProblem{typeof (u0),eltype (tspan),typeof (tspan),isinplace,
235
- typeof (noise),
236
- typeof (f),typeof (g),
237
- typeof (callback),typeof (noise_rate_prototype),
238
- typeof (mass_matrix)}(a,r,σ,u0,tspan,nothing ,f,g,noise,callback,
239
- noise_rate_prototype,mass_matrix,seed)
117
+ SDEProblem {false} (f,g,u0,tspan;kwargs... )
240
118
end
241
119
242
120
@doc doc"""
243
121
244
122
``dx = σ(t)e^{at} dW_t``
245
123
246
124
"""
247
- mutable struct MfStateProblem{uType,tType,tupType,isinplace,NP,F,F2,C,ND,MM} <: DiffEqBase.AbstractSDEProblem{uType,tType,isinplace,ND}
248
- a:: tType
249
- σ:: tType
250
- u0:: uType
251
- tspan:: tupType
252
- p:: Nothing
253
- f:: F
254
- g:: F2
255
- noise:: NP
256
- callback:: C
257
- noise_rate_prototype:: ND
258
- mass_matrix:: MM
259
- seed:: UInt64
260
- end
261
-
262
- function MfStateProblem (a,σ,u0,tspan;callback = CallbackSet (),noise_rate_prototype = nothing ,seed= UInt64 (0 ))
125
+ function MfStateProblem (a,σ,u0,tspan;kwargs... )
263
126
f = function (u,p,t)
264
127
0
265
128
end
266
129
g = function (u,p,t)
267
130
σ (t)* exp (a* t)
268
131
end
269
- noise = nothing
270
- isinplace = false
271
- mass_matrix= I
272
- MfStateProblem{typeof (u0),eltype (tspan),typeof (tspan),isinplace,
273
- typeof (noise),
274
- typeof (f),typeof (g),
275
- typeof (callback),typeof (noise_rate_prototype),typeof (mass_matrix)}(
276
- a,σ,u0,tspan,nothing ,f,g,noise,callback,
277
- noise_rate_prototype,mass_matrix,seed)
132
+ SDEProblem {false} (f,g,u0,tspan;kwargs... )
278
133
end
0 commit comments