Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CrossAssetStateProcess Class Reference

Cross Asset Model State Process. More...

#include <qle/processes/crossassetstateprocess.hpp>

+ Inheritance diagram for CrossAssetStateProcess:
+ Collaboration diagram for CrossAssetStateProcess:

Classes

class  ExactDiscretization
 

Public Member Functions

 CrossAssetStateProcess (QuantLib::ext::shared_ptr< const CrossAssetModel > model)
 
Size size () const override
 
Size factors () const override
 
Array initialValues () const override
 
Array drift (Time t, const Array &x) const override
 
Matrix diffusion (Time t, const Array &x) const override
 
Array evolve (Time t0, const Array &x0, Time dt, const Array &dw) const override
 
void resetCache (const Size timeSteps) const
 

Protected Member Functions

virtual Matrix diffusionOnCorrelatedBrownians (Time t, const Array &x) const
 
virtual Matrix diffusionOnCorrelatedBrowniansImpl (Time t, const Array &x) const
 
void updateSqrtCorrelation () const
 

Protected Attributes

QuantLib::ext::shared_ptr< const CrossAssetModelmodel_
 
std::vector< QuantLib::ext::shared_ptr< StochasticProcess > > crCirpp_
 
Size cirppCount_
 
Matrix sqrtCorrelation_
 
bool cacheNotReady_m_ = true
 
bool cacheNotReady_d_ = true
 
Size timeStepsToCache_m_ = 0
 
Size timeStepCache_m_ = 0
 
Size timeStepsToCache_d_ = 0
 
Size timeStepCache_d_ = 0
 
std::vector< Array > cache_m_
 
std::vector< Matrix > cache_d_
 

Detailed Description

Cross Asset Model State Process.

Definition at line 42 of file crossassetstateprocess.hpp.

Constructor & Destructor Documentation

◆ CrossAssetStateProcess()

CrossAssetStateProcess ( QuantLib::ext::shared_ptr< const CrossAssetModel model)

Definition at line 55 of file crossassetstateprocess.cpp.

56 : StochasticProcess(), model_(std::move(model)), cirppCount_(0) {
57
58 if (model_->discretization() == CrossAssetModel::Discretization::Euler) {
59 discretization_ = QuantLib::ext::make_shared<EulerDiscretization>();
60 } else {
61 discretization_ =
62 QuantLib::ext::make_shared<CrossAssetStateProcess::ExactDiscretization>(model_, model_->salvagingAlgorithm());
63 }
64
66
67 // set up CR CIR++ processes, defer the euler discretisation check to evolve()
68 for (Size i = 0; i < model_->components(CrossAssetModel::AssetType::CR); ++i) {
70 crCirpp_.push_back(model_->crcirppModel(i)->stateProcess());
72 } else {
73 crCirpp_.push_back(QuantLib::ext::shared_ptr<CrCirppStateProcess>());
74 }
75 }
76}
std::vector< QuantLib::ext::shared_ptr< StochasticProcess > > crCirpp_
QuantLib::ext::shared_ptr< const CrossAssetModel > model_
+ Here is the call graph for this function:

Member Function Documentation

◆ size()

Size size ( ) const
override

StochasticProcess interface

Definition at line 78 of file crossassetstateprocess.cpp.

78{ return model_->dimension(); }

◆ factors()

Size factors ( ) const
override

Definition at line 80 of file crossassetstateprocess.cpp.

80{ return model_->brownians() + model_->auxBrownians(); }

◆ initialValues()

Array initialValues ( ) const
override

Definition at line 99 of file crossassetstateprocess.cpp.

99 {
100 Array res(model_->dimension(), 0.0);
101 /* irlgm1f / irhw processes have initial value 0 */
102 for (Size i = 0; i < model_->components(CrossAssetModel::AssetType::FX); ++i) {
103 /* fxbs processes are in log spot */
104 res[model_->pIdx(CrossAssetModel::AssetType::FX, i, 0)] = std::log(model_->fxbs(i)->fxSpotToday()->value());
105 }
106 for (Size i = 0; i < model_->components(CrossAssetModel::AssetType::EQ); ++i) {
107 /* eqbs processes are in log spot */
108 res[model_->pIdx(CrossAssetModel::AssetType::EQ, i, 0)] = std::log(model_->eqbs(i)->eqSpotToday()->value());
109 }
110 // CR CIR++ components
111 for (Size i = 0; i < model_->components(CrossAssetModel::AssetType::CR); ++i) {
113 continue;
114 QL_REQUIRE(crCirpp_[i], "crcirpp is null!");
115 Array r = crCirpp_[i]->initialValues();
116 res[model_->pIdx(CrossAssetModel::AssetType::CR, i, 0)] = r[0]; // y0
117 res[model_->pIdx(CrossAssetModel::AssetType::CR, i, 1)] = r[1]; // S(0,0) = 1
118 }
119
120 for (Size i = 0; i < model_->components(CrossAssetModel::AssetType::INF); ++i) {
121 // Second component of JY model is the inflation index process.
123 res[model_->pIdx(CrossAssetModel::AssetType::INF, i, 1)] =
124 std::log(model_->infjy(i)->index()->fxSpotToday()->value());
125 }
126 }
127 /* infdk, crlgm1f, commodity, crstate processes have initial value 0 */
128 return res;
129}

◆ drift()

Array drift ( Time  t,
const Array &  x 
) const
override

Definition at line 131 of file crossassetstateprocess.cpp.

131 {
132 Array res(model_->dimension(), 0.0);
133 Size n = model_->components(CrossAssetModel::AssetType::IR);
134 Size n_eq = model_->components(CrossAssetModel::AssetType::EQ);
135 Real H0 = model_->irlgm1f(0)->H(t);
136 Real Hprime0 = model_->irlgm1f(0)->Hprime(t);
137 Real alpha0 = model_->irlgm1f(0)->alpha(t);
138 Real zeta0 = model_->irlgm1f(0)->zeta(t);
139 if (cacheNotReady_m_) {
140 /* z0 has drift 0 in the LGM measure but non-zero drift in the bank account measure, so start loop at i = 0 */
141 for (Size i = 0; i < n; ++i) {
142 Real Hi = model_->irlgm1f(i)->H(t);
143 Real alphai = model_->irlgm1f(i)->alpha(t);
144 if (i == 0 && model_->measure() == IrModel::Measure::BA) {
145 // ADD z0 drift in the BA measure
146 res[model_->pIdx(CrossAssetModel::AssetType::IR, i, 0)] = -Hi * alphai * alphai;
147 // the auxiliary state variable is drift-free
148 res[model_->pIdx(CrossAssetModel::AssetType::IR, i, 1)] = 0.0;
149 }
150 if (i > 0) {
151 Real sigmai = model_->fxbs(i - 1)->sigma(t);
152 // ir-ir
153 Real rhozz0i =
155 // ir-fx
156 Real rhozx0i =
158 Real rhozxii =
160 // ir drifts
161 res[model_->pIdx(CrossAssetModel::AssetType::IR, i, 0)] =
162 -Hi * alphai * alphai + H0 * alpha0 * alphai * rhozz0i - sigmai * alphai * rhozxii;
163 // log spot fx drifts (z0, zi independent parts)
164 res[model_->pIdx(CrossAssetModel::AssetType::FX, i - 1, 0)] =
165 H0 * alpha0 * sigmai * rhozx0i +
166 model_->irlgm1f(0)->termStructure()->forwardRate(t, t, Continuous) -
167 model_->irlgm1f(i)->termStructure()->forwardRate(t, t, Continuous) - 0.5 * sigmai * sigmai;
168 if (model_->measure() == IrModel::Measure::BA) {
169 // REMOVE the LGM measure drift contributions above
170 res[model_->pIdx(CrossAssetModel::AssetType::IR, i, 0)] -= H0 * alpha0 * alphai * rhozz0i;
171 res[model_->pIdx(CrossAssetModel::AssetType::FX, i - 1, 0)] -= H0 * alpha0 * sigmai * rhozx0i;
172 }
173 }
174 }
175 /* log equity spot drifts (the cache-able parts) */
176 for (Size k = 0; k < n_eq; ++k) {
177 Size i = model_->ccyIndex(model_->eqbs(k)->currency());
178 // ir params (for equity currency)
179 Real eps_ccy = (i == 0) ? 0.0 : 1.0;
180 // Real Hi = model_->irlgm1f(i)->H(t);
181 // Real alphai = model_->irlgm1f(i)->alpha(t);
182 // eq vol
183 Real sigmask = model_->eqbs(k)->sigma(t);
184 // fx vol (eq ccy / base ccy)
185 Real sigmaxi = (i == 0) ? 0.0 : model_->fxbs(i - 1)->sigma(t);
186 // ir-eq corr
187 // Real rhozsik = model_->correlation(EQ, k, CrossAssetModel::AssetType::IR, i); // eq cur
188 Real rhozs0k =
190 // fx-eq corr
191 Real rhoxsik =
192 (i == 0) ? 0.0 : // no fx process for base-ccy
194 // ir instantaneous forward rate (from curve used for eq forward projection)
195 Real fr_i = model_->eqbs(k)->equityIrCurveToday()->forwardRate(t, t, Continuous);
196 // div yield instantaneous forward rate
197 Real fq_k = model_->eqbs(k)->equityDivYieldCurveToday()->forwardRate(t, t, Continuous);
198 res[model_->pIdx(CrossAssetModel::AssetType::EQ, k, 0)] = fr_i - fq_k + (rhozs0k * H0 * alpha0 * sigmask) -
199 (eps_ccy * rhoxsik * sigmaxi * sigmask) -
200 (0.5 * sigmask * sigmask);
201 }
202
203 // State independent pieces of JY inflation model, if there is a CAM JY component.
204 for (Size j = 0; j < model_->components(CrossAssetModel::AssetType::INF); ++j) {
205
207
208 auto p = model_->infjy(j);
209 Size i_j = model_->ccyIndex(p->currency());
210
211 // JY inflation parameter values.
212 Real H_y_j = p->realRate()->H(t);
213 Real Hp_y_j = p->realRate()->Hprime(t);
214 Real zeta_y_j = p->realRate()->zeta(t);
215 Real alpha_y_j = p->realRate()->alpha(t);
216 Real sigma_c_j = p->index()->sigma(t);
217
218 // Inflation nominal currency parameter values
219 Real H_i_j = model_->irlgm1f(i_j)->H(t);
220 Real Hp_i_j = model_->irlgm1f(i_j)->Hprime(t);
221 Real zeta_i_j = model_->irlgm1f(i_j)->zeta(t);
222
223 // Correlations
224 Real rho_zy_0j =
226 Real rho_yc_ij =
228 Real rho_zc_0j =
230
231 // JY real rate drift. It is state independent
232 auto rrDrift = -alpha_y_j * alpha_y_j * H_y_j + rho_zy_0j * alpha0 * alpha_y_j * H_y_j -
233 rho_yc_ij * alpha_y_j * sigma_c_j;
234
235 if (i_j > 0) {
236 Real sigma_x_i_j = model_->fxbs(i_j - 1)->sigma(t);
237 Real rho_yx_j_i_j = model_->correlation(CrossAssetModel::AssetType::INF, j,
238 CrossAssetModel::AssetType::FX, i_j - 1, 0, 0);
239 rrDrift -= rho_yx_j_i_j * alpha_y_j * sigma_x_i_j;
240 }
241
242 res[model_->pIdx(CrossAssetModel::AssetType::INF, j, 0)] = rrDrift;
243
244 // JY log inflation index drift (state independent piece).
245 auto indexDrift = rho_zc_0j * alpha0 * sigma_c_j * H0 - 0.5 * sigma_c_j * sigma_c_j +
246 zeta_i_j * Hp_i_j * H_i_j - zeta_y_j * Hp_y_j * H_y_j;
247
248 // Add on the f_n(0, t) - f_r(0, t) piece using the initial zero inflation term structure.
249 // Use the same dt below that is used in yield forward rate calculations.
250 auto ts = p->realRate()->termStructure();
251 Time dt = 0.0001;
252 Time t1 = std::max(t - dt / 2.0, 0.0);
253 Time t2 = t1 + dt;
254 auto z_t = ts->zeroRate(t);
255 auto z_t1 = ts->zeroRate(t1);
256 auto z_t2 = ts->zeroRate(t2);
257 indexDrift += std::log(1 + z_t) + (t / (1 + z_t)) * ((z_t2 - z_t1) / dt);
258
259 if (i_j > 0) {
260 Real sigma_x_i_j = model_->fxbs(i_j - 1)->sigma(t);
261 Real rho_cx_j_i_j = model_->correlation(CrossAssetModel::AssetType::INF, j,
262 CrossAssetModel::AssetType::FX, i_j - 1, 1, 0);
263 indexDrift -= rho_cx_j_i_j * sigma_c_j * sigma_x_i_j;
264 }
265
266 res[model_->pIdx(CrossAssetModel::AssetType::INF, j, 1)] = indexDrift;
267 }
268 }
269
270 if (timeStepsToCache_m_ > 0) {
271 cache_m_.push_back(res);
272 if (cache_m_.size() == timeStepsToCache_m_)
273 cacheNotReady_m_ = false;
274 }
275 } else {
276 res = cache_m_[timeStepCache_m_++];
279 }
280 // non-cacheable sections of drifts
281 for (Size i = 1; i < n; ++i) {
282 // log spot fx drifts (z0, zi dependent parts)
283 Real Hi = model_->irlgm1f(i)->H(t);
284 Real Hprimei = model_->irlgm1f(i)->Hprime(t);
285 Real zetai = model_->irlgm1f(i)->zeta(t);
286 res[model_->pIdx(CrossAssetModel::AssetType::FX, i - 1, 0)] +=
287 x[model_->pIdx(CrossAssetModel::AssetType::IR, 0, 0)] * Hprime0 + zeta0 * Hprime0 * H0 -
288 x[model_->pIdx(CrossAssetModel::AssetType::IR, i, 0)] * Hprimei - zetai * Hprimei * Hi;
289 }
290 for (Size k = 0; k < n_eq; ++k) {
291 // log equity spot drifts (path-dependent parts)
292 // notice the assumption in below that dividend yield curve is static
293 Size i = model_->ccyIndex(model_->eqbs(k)->currency());
294 // ir params (for equity currency)
295 Real Hi = model_->irlgm1f(i)->H(t);
296 Real Hprimei = model_->irlgm1f(i)->Hprime(t);
297 Real zetai = model_->irlgm1f(i)->zeta(t);
298 res[model_->pIdx(CrossAssetModel::AssetType::EQ, k, 0)] +=
299 (x[model_->pIdx(CrossAssetModel::AssetType::IR, i, 0)] * Hprimei) + (zetai * Hprimei * Hi);
300 }
301
302 // Non-cacheable portion of inflation JY drift, if there is a CAM JY component.
303 for (Size j = 0; j < model_->components(CrossAssetModel::AssetType::INF); ++j) {
305
306 auto p = model_->infjy(j);
307 Size i_j = model_->ccyIndex(p->currency());
308
309 // JY inflation parameter values.
310 Real Hp_y_j = p->realRate()->Hprime(t);
311
312 // Inflation nominal currency parameter values
313 Real Hp_i_j = model_->irlgm1f(i_j)->Hprime(t);
314
315 res[model_->pIdx(CrossAssetModel::AssetType::INF, j, 1)] +=
316 x[model_->pIdx(CrossAssetModel::AssetType::IR, i_j, 0)] * Hp_i_j -
317 x[model_->pIdx(CrossAssetModel::AssetType::INF, j, 0)] * Hp_y_j;
318 }
319 }
320
321 // COM drift
322 Size n_com = model_->components(CrossAssetModel::AssetType::COM);
323 for (Size k = 0; k < n_com; ++k) {
324 auto cm = QuantLib::ext::dynamic_pointer_cast<CommoditySchwartzModel>(model_->comModel(k));
325 QL_REQUIRE(cm, "CommoditySchwartzModel not set");
326 if (!cm->parametrization()->driftFreeState()) {
327 // Ornstein-Uhlenbeck drift
328 Real kap = cm->parametrization()->kappaParameter();
329 res[model_->pIdx(CrossAssetModel::AssetType::COM, k, 0)] -=
330 kap * x[model_->pIdx(CrossAssetModel::AssetType::COM, k, 0)];
331 } else {
332 // zero drift
333 }
334 }
335
336 /* no drift for infdk, crlgm1f, crstate components */
337 return res;
338}

◆ diffusion()

Matrix diffusion ( Time  t,
const Array &  x 
) const
override

Definition at line 340 of file crossassetstateprocess.cpp.

340 {
342}
virtual Matrix diffusionOnCorrelatedBrownians(Time t, const Array &x) const
+ Here is the call graph for this function:

◆ evolve()

Array evolve ( Time  t0,
const Array &  x0,
Time  dt,
const Array &  dw 
) const
override

Definition at line 472 of file crossassetstateprocess.cpp.

472 {
473
474 Array res;
475
476 // handle HW based model
477
479
480 QL_REQUIRE(model_->discretization() == CrossAssetModel::Discretization::Euler,
481 "CrossAssetStateProcess::evolve(): hw-based model only supports Euler discretization.");
482
483 const Array dz = sqrtCorrelation_ * dw;
484
485 res = Array(model_->dimension());
486
487 // eolve ir processes and store current short rates which are needed to evolve the fx components below
488
489 Array shortRates(model_->components(CrossAssetModel::AssetType::IR));
490 for (Size i = 0; i < model_->components(CrossAssetModel::AssetType::IR); ++i) {
491 auto p = model_->irModel(i)->stateProcess();
492 auto r = p->evolve(t0,
493 getProjectedArray(x0, model_->pIdx(CrossAssetModel::AssetType::IR, i, 0),
494 model_->irModel(i)->n() + model_->irModel(i)->n_aux()),
495 dt,
496 getProjectedArray(dz, model_->wIdx(CrossAssetModel::AssetType::IR, i, 0),
497 model_->irModel(i)->m() + model_->irModel(i)->m_aux()));
498 std::copy(r.begin(), r.end(), std::next(res.begin(), model_->pIdx(CrossAssetModel::AssetType::IR, i, 0)));
499 shortRates[i] = model_->irModel(i)->shortRate(
500 t0, getProjectedArray(x0, model_->pIdx(CrossAssetModel::AssetType::IR, i, 0), model_->irModel(i)->n()));
501 }
502
503 // apply drift adjustment to ir processes in non-domestic currency
504
505 for (Size i = 1; i < model_->components(CrossAssetModel::AssetType::IR); ++i) {
506 applyFxDriftAdjustment(res, model_, i, t0, dt);
507 }
508
509 // eolve fx processes
510
511 for (Size i = 0; i < model_->components(CrossAssetModel::AssetType::FX); ++i) {
512 auto r = model_->fxModel(i)->eulerStep(
513 t0, getProjectedArray(x0, model_->pIdx(CrossAssetModel::AssetType::FX, i, 0), model_->fxModel(i)->n()),
514 dt, getProjectedArray(dz, model_->wIdx(CrossAssetModel::AssetType::FX, i, 0), model_->fxModel(i)->m()),
515 shortRates[0], shortRates[i + 1]);
516 std::copy(r.begin(), r.end(), std::next(res.begin(), model_->pIdx(CrossAssetModel::AssetType::FX, i, 0)));
517 }
518
519 // evolve com processes
520
521 for (Size i = 0; i < model_->components(CrossAssetModel::AssetType::COM); ++i) {
522 auto p = model_->comModel(i)->stateProcess();
523 auto r = p->evolve(
524 t0,
525 getProjectedArray(x0, model_->pIdx(CrossAssetModel::AssetType::COM, i, 0), model_->comModel(i)->n()),
526 dt,
527 getProjectedArray(dz, model_->wIdx(CrossAssetModel::AssetType::COM, i, 0), model_->comModel(i)->m()));
528 std::copy(r.begin(), r.end(), std::next(res.begin(), model_->pIdx(CrossAssetModel::AssetType::COM, i, 0)));
529 }
530
531 // TODO other components ...
532 QL_REQUIRE(model_->components(CrossAssetModel::AssetType::IR) +
535 model_->parametrizations().size(),
536 "CrossAssetStateProcess::evolve(): currently only IR, FX, COM supported.");
537
538 return res;
539 }
540
541 // handle LGM1F based model
542
543 if (model_->discretization() == CrossAssetModel::Discretization::Euler) {
544 const Array dz = sqrtCorrelation_ * dw;
545 const Matrix df = diffusionOnCorrelatedBrownians(t0, x0);
546 res = apply(expectation(t0, x0, dt), df * dz * std::sqrt(dt));
547
548 // CR CIRPP components
549 if (cirppCount_ > 0) {
550 for (Size i = 0; i < model_->components(CrossAssetModel::AssetType::CR); ++i) {
551 if (!crCirpp_[i])
552 continue; // ignore non-cir cr model
553 Size idx1 = model_->pIdx(CrossAssetModel::AssetType::CR, i, 0);
554 Size idx2 = model_->pIdx(CrossAssetModel::AssetType::CR, i, 1);
555 Size idxw = model_->wIdx(CrossAssetModel::AssetType::CR, i, 0);
556 Array x0Tmp(2), dwTmp(2);
557 x0Tmp[0] = x0[idx1];
558 x0Tmp[1] = x0[idx2];
559 dwTmp[0] = dz[idxw];
560 dwTmp[1] = 0.0; // not used
561 // evolve original process
562 auto r = crCirpp_[i]->evolve(t0, x0Tmp, dt, dwTmp);
563
564 // set result
565 res[idx1] = r[0]; // y
566 res[idx2] = r[1]; // S(0,T)
567 }
568 }
569 } else {
570 QL_REQUIRE(cirppCount_ == 0, "only euler discretization is supported for CIR++");
571 res = StochasticProcess::evolve(t0, x0, dt, dw);
572 }
573
574 return res;
575}
RandomVariable expectation(const RandomVariable &r)
+ Here is the call graph for this function:

◆ resetCache()

void resetCache ( const Size  timeSteps) const

Definition at line 82 of file crossassetstateprocess.cpp.

82 {
86 cache_m_.clear();
87 cache_d_.clear();
88 if (auto tmp = QuantLib::ext::dynamic_pointer_cast<CrossAssetStateProcess::ExactDiscretization>(discretization_))
89 tmp->resetCache(timeSteps);
91}
+ Here is the call graph for this function:

◆ diffusionOnCorrelatedBrownians()

Matrix diffusionOnCorrelatedBrownians ( Time  t,
const Array &  x 
) const
protectedvirtual

Definition at line 344 of file crossassetstateprocess.cpp.

344 {
345 if (cacheNotReady_d_) {
346 Matrix tmp = diffusionOnCorrelatedBrowniansImpl(t, x);
347 if (timeStepsToCache_d_ > 0) {
348 cache_d_.push_back(tmp);
349 if (cache_d_.size() == timeStepsToCache_d_)
350 cacheNotReady_d_ = false;
351 }
352 return tmp;
353 } else {
354 Matrix tmp = cache_d_[timeStepCache_d_++];
357 return tmp;
358 }
359}
virtual Matrix diffusionOnCorrelatedBrowniansImpl(Time t, const Array &x) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ diffusionOnCorrelatedBrowniansImpl()

Matrix diffusionOnCorrelatedBrowniansImpl ( Time  t,
const Array &  x 
) const
protectedvirtual

Definition at line 361 of file crossassetstateprocess.cpp.

361 {
362 Matrix res(model_->dimension(), model_->brownians(), 0.0);
363 Size n = model_->components(CrossAssetModel::AssetType::IR);
364 Size m = model_->components(CrossAssetModel::AssetType::FX);
365 Size d = model_->components(CrossAssetModel::AssetType::INF);
366 Size c = model_->components(CrossAssetModel::AssetType::CR);
367 Size e = model_->components(CrossAssetModel::AssetType::EQ);
368 Size com = model_->components(CrossAssetModel::AssetType::COM);
369 Size crstates = model_->components(CrossAssetModel::AssetType::CrState);
370 // ir-ir
371 for (Size i = 0; i < n; ++i) {
372 Real alphai = model_->irlgm1f(i)->alpha(t);
373 setValue2(res, alphai, model_, CrossAssetModel::AssetType::IR, i, CrossAssetModel::AssetType::IR, i, 0, 0);
374 }
375 // fx-fx
376 for (Size i = 0; i < m; ++i) {
377 Real sigmai = model_->fxbs(i)->sigma(t);
378 setValue2(res, sigmai, model_, CrossAssetModel::AssetType::FX, i, CrossAssetModel::AssetType::FX, i, 0, 0);
379 }
380 // inf-inf
381 for (Size i = 0; i < d; ++i) {
383 Real alphai = model_->infdk(i)->alpha(t);
384 Real Hi = model_->infdk(i)->H(t);
385 // DK z diffusion coefficient
387 0);
388 // DK y diffusion coefficient
390 1, 0);
391 } else {
392 auto p = model_->infjy(i);
393 // JY z diffusion coefficient
394 setValue2(res, p->realRate()->alpha(t), model_, CrossAssetModel::AssetType::INF, i,
396 // JY I diffusion coefficient
397 setValue2(res, p->index()->sigma(t), model_, CrossAssetModel::AssetType::INF, i,
399 }
400 }
401 for (Size i = 0; i < c; ++i) {
402 // Skip CR components that are not LGM
404 continue;
405 Real alphai = model_->crlgm1f(i)->alpha(t);
406 Real Hi = model_->crlgm1f(i)->H(t);
407 // crz-crz
408 setValue2(res, alphai, model_, CrossAssetModel::AssetType::CR, i, CrossAssetModel::AssetType::CR, i, 0, 0);
409 // cry-cry
410 setValue2(res, alphai * Hi, model_, CrossAssetModel::AssetType::CR, i, CrossAssetModel::AssetType::CR, i, 1, 0);
411 }
412 // eq-eq
413 for (Size i = 0; i < e; ++i) {
414 Real sigmai = model_->eqbs(i)->sigma(t);
415 setValue2(res, sigmai, model_, CrossAssetModel::AssetType::EQ, i, CrossAssetModel::AssetType::EQ, i, 0, 0);
416 }
417 // com-com
418 for (Size i = 0; i < com; ++i) {
419 Real sigmai = model_->combs(i)->sigma(t);
420 setValue2(res, sigmai, model_, CrossAssetModel::AssetType::COM, i, CrossAssetModel::AssetType::COM, i, 0, 0);
421 }
422 // creditstate-creditstate
423 for (Size i = 0; i < crstates; ++i) {
425 0);
426 }
427
428 if (model_->measure() == IrModel::Measure::BA) {
429 // aux-aux
430 Real H0 = model_->irlgm1f(0)->H(t);
431 Real alpha0 = model_->irlgm1f(0)->alpha(t);
432 setValue2(res, alpha0 * H0, model_, CrossAssetModel::AssetType::IR, 0, CrossAssetModel::AssetType::IR, 0, 1, 0);
433 }
434
435 return res;
436}
+ Here is the caller graph for this function:

◆ updateSqrtCorrelation()

void updateSqrtCorrelation ( ) const
protected

Definition at line 93 of file crossassetstateprocess.cpp.

93 {
94 if (model_->discretization() != CrossAssetModel::Discretization::Euler)
95 return;
96 sqrtCorrelation_ = pseudoSqrt(model_->correlation(), model_->salvagingAlgorithm());
97}
+ Here is the caller graph for this function:

Member Data Documentation

◆ model_

QuantLib::ext::shared_ptr<const CrossAssetModel> model_
protected

Definition at line 62 of file crossassetstateprocess.hpp.

◆ crCirpp_

std::vector<QuantLib::ext::shared_ptr<StochasticProcess> > crCirpp_
protected

Definition at line 64 of file crossassetstateprocess.hpp.

◆ cirppCount_

Size cirppCount_
protected

Definition at line 65 of file crossassetstateprocess.hpp.

◆ sqrtCorrelation_

Matrix sqrtCorrelation_
mutableprotected

Definition at line 67 of file crossassetstateprocess.hpp.

◆ cacheNotReady_m_

bool cacheNotReady_m_ = true
mutableprotected

Definition at line 99 of file crossassetstateprocess.hpp.

◆ cacheNotReady_d_

bool cacheNotReady_d_ = true
mutableprotected

Definition at line 100 of file crossassetstateprocess.hpp.

◆ timeStepsToCache_m_

Size timeStepsToCache_m_ = 0
mutableprotected

Definition at line 101 of file crossassetstateprocess.hpp.

◆ timeStepCache_m_

Size timeStepCache_m_ = 0
mutableprotected

Definition at line 102 of file crossassetstateprocess.hpp.

◆ timeStepsToCache_d_

Size timeStepsToCache_d_ = 0
mutableprotected

Definition at line 103 of file crossassetstateprocess.hpp.

◆ timeStepCache_d_

Size timeStepCache_d_ = 0
mutableprotected

Definition at line 104 of file crossassetstateprocess.hpp.

◆ cache_m_

std::vector<Array> cache_m_
mutableprotected

Definition at line 105 of file crossassetstateprocess.hpp.

◆ cache_d_

std::vector<Matrix> cache_d_
mutableprotected

Definition at line 106 of file crossassetstateprocess.hpp.