Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Files | Classes | Functions
Cross Asset Model

Files

file  crossassetanalytics.hpp
 analytics for the cross asset model
 
file  crossassetanalyticsbase.hpp
 basic functions for analytics in the cross asset model
 
file  crossassetmodel.hpp
 cross asset model
 
file  crossassetmodelimpliedeqvoltermstructure.hpp
 dynamic black volatility term structure
 
file  crossassetmodelimpliedfxvoltermstructure.hpp
 dynamic black volatility term structure
 
file  projectedcrossassetmodel.hpp
 cross asset model projection utils
 
file  crossassetstateprocess.hpp
 crossasset model state process
 

Classes

struct  Hz
 
struct  az
 
struct  zetaz
 
struct  sx
 
struct  vx
 
struct  Hy
 INF H component. May relate to real rate portion of JY model or z component of DK model. More...
 
struct  ay
 INF alpha component. May relate to real rate portion of JY model or z component of DK model. More...
 
struct  zetay
 INF zeta component. May relate to real rate portion of JY model or z component of DK model. More...
 
struct  sy
 JY INF index sigma component. More...
 
struct  vy
 JY INF index variance component. More...
 
struct  Hl
 
struct  al
 
struct  zetal
 
struct  ss
 
struct  vs
 
struct  coms
 
struct  rzz
 
struct  rzx
 
struct  rxx
 
struct  ryy
 
struct  rzy
 
struct  rxy
 
struct  rll
 
struct  rzl
 
struct  rxl
 
struct  ryl
 
struct  rss
 
struct  rzs
 
struct  rxs
 
struct  rys
 
struct  rls
 
struct  rcc
 
struct  HTtz
 
struct  rzcrs
 
struct  rxcrs
 
struct  rccrs
 
struct  P2_< E1, E2 >
 
struct  P3_< E1, E2, E3 >
 
struct  P4_< E1, E2, E3, E4 >
 
struct  P5_< E1, E2, E3, E4, E5 >
 
struct  LC1_< E1 >
 
struct  LC2_< E1, E2 >
 
struct  LC3_< E1, E2, E3 >
 
struct  LC4_< E1, E2, E3, E4 >
 
class  CrossAssetModel
 Cross Asset Model. More...
 
class  CrossAssetModelImpliedEqVolTermStructure
 Cross Asset Model Implied EQ Term Structure. More...
 
class  CrossAssetModelImpliedFxVolTermStructure
 Cross Asset Model Implied FX Term Structure. More...
 
class  CrossAssetStateProcess
 Cross Asset Model State Process. More...
 

Functions

Real ir_expectation_1 (const CrossAssetModel &x, const Size i, const Time t0, const Real dt)
 
Real ir_expectation_2 (const CrossAssetModel &, const Size, const Real zi_0)
 
std::pair< QuantLib::Real, QuantLib::Real > inf_jy_expectation_1 (const CrossAssetModel &model, QuantLib::Size i, QuantLib::Time t0, QuantLib::Real dt)
 
std::pair< QuantLib::Real, QuantLib::Real > inf_jy_expectation_2 (const CrossAssetModel &model, QuantLib::Size i, QuantLib::Time t0, const std::pair< QuantLib::Real, QuantLib::Real > &state_0, QuantLib::Real zi_i_0, QuantLib::Real dt)
 
Real fx_expectation_1 (const CrossAssetModel &x, const Size i, const Time t0, const Real dt)
 
Real fx_expectation_2 (const CrossAssetModel &x, const Size i, const Time t0, const Real xi_0, const Real zi_0, const Real z0_0, const Real dt)
 
Real eq_expectation_1 (const CrossAssetModel &x, const Size k, const Time t0, const Real dt)
 
Real eq_expectation_2 (const CrossAssetModel &x, const Size k, const Time t0, const Real sk_0, const Real zi_0, const Real dt)
 
Real ir_ir_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real ir_fx_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real fx_fx_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real infz_infz_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real infz_infy_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real infy_infy_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real ir_infz_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real ir_infy_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real fx_infz_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real fx_infy_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real crz_crz_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real crz_cry_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real cry_cry_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real ir_crz_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real ir_cry_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real fx_crz_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real fx_cry_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real infz_crz_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real infz_cry_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real infy_crz_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real infy_cry_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real ir_eq_covariance (const CrossAssetModel &x, const Size j, const Size k, const Time t0, const Time dt)
 
Real fx_eq_covariance (const CrossAssetModel &x, const Size j, const Size k, const Time t0, const Time dt)
 
Real infz_eq_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real infy_eq_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real crz_eq_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real cry_eq_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real eq_eq_covariance (const CrossAssetModel &x, const Size k, const Size l, const Time t0, const Time dt)
 
Real aux_aux_covariance (const CrossAssetModel &x, const Time t0, const Time dt)
 
Real aux_ir_covariance (const CrossAssetModel &x, const Size j, const Time t0, const Time dt)
 
Real aux_fx_covariance (const CrossAssetModel &x, const Size j, const Time t0, const Time dt)
 
Real com_com_covariance (const CrossAssetModel &x, const Size k, const Size l, const Time t0, const Time dt)
 
Real ir_com_covariance (const CrossAssetModel &model, const Size i, const Size j, const Time t0, const Time dt)
 
Real fx_com_covariance (const CrossAssetModel &model, const Size i, const Size j, const Time t0, const Time dt)
 
Real infz_com_covariance (const CrossAssetModel &model, const Size i, const Size j, const Time t0, const Time dt)
 
Real infy_com_covariance (const CrossAssetModel &model, const Size i, const Size j, const Time t0, const Time dt)
 
Real cry_com_covariance (const CrossAssetModel &model, const Size i, const Size j, const Time t0, const Time dt)
 
Real crz_com_covariance (const CrossAssetModel &model, const Size i, const Size j, const Time t0, const Time dt)
 
Real eq_com_covariance (const CrossAssetModel &model, const Size i, const Size j, const Time t0, const Time dt)
 
Real ir_crstate_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real fx_crstate_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
Real crstate_crstate_covariance (const CrossAssetModel &x, const Size i, const Size j, const Time t0, const Time dt)
 
template<class E >
Real integral_helper (const CrossAssetModel &x, const E &e, const Real t)
 
template<typename E >
Real integral (const CrossAssetModel &model, const E &e, const Real a, const Real b)
 
template<class E1 , class E2 >
const P2_< E1, E2 > P (const E1 &e1, const E2 &e2)
 
template<class E1 , class E2 , class E3 >
const P3_< E1, E2, E3 > P (const E1 &e1, const E2 &e2, const E3 &e3)
 
template<class E1 , class E2 , class E3 , class E4 >
const P4_< E1, E2, E3, E4 > P (const E1 &e1, const E2 &e2, const E3 &e3, const E4 &e4)
 
template<class E1 , class E2 , class E3 , class E4 , class E5 >
const P5_< E1, E2, E3, E4, E5 > P (const E1 &e1, const E2 &e2, const E3 &e3, const E4 &e4, const E5 &e5)
 
template<class E1 >
const LC1_< E1 > LC (QuantLib::Real c, QuantLib::Real c1, const E1 &e1)
 
template<class E1 , class E2 >
const LC2_< E1, E2 > LC (QuantLib::Real c, QuantLib::Real c1, const E1 &e1, QuantLib::Real c2, const E2 &e2)
 
template<class E1 , class E2 , class E3 >
const LC3_< E1, E2, E3 > LC (QuantLib::Real c, QuantLib::Real c1, const E1 &e1, QuantLib::Real c2, const E2 &e2, QuantLib::Real c3, const E3 &e3)
 
template<class E1 , class E2 , class E3 , class E4 >
const LC4_< E1, E2, E3, E4 > LC (QuantLib::Real c, QuantLib::Real c1, const E1 &e1, QuantLib::Real c2, const E2 &e2, QuantLib::Real c3, const E3 &e3, QuantLib::Real c4, const E4 &e4)
 

Detailed Description

Grouping of all cross asset models

Function Documentation

◆ ir_expectation_1()

Real ir_expectation_1 ( const CrossAssetModel model,
const Size  i,
const Time  t0,
const Real  dt 
)

IR state expectation

This function evaluates part of the expectation \( \mathbb{E}_{t_0}[z_i(t_0+dt)]\).

Using the results above for factor moves \(\Delta z\) over time interval \((s,t)\), we have

\begin{eqnarray} \mathbb{E}_{t_0}[z_i(t_0+\Delta t)] &=& z_i(t_0) + \mathbb{E}_{t_0}[\Delta z_i], \qquad\mbox{with}\quad \Delta z_i = z_i(t_0+\Delta t) - z_i(t_0) \\ &=& z_i(t_0) -\int_{t_0}^{t_0+\Delta t} H^z_i\,(\alpha^z_i)^2\,du + \rho^{zz}_{0i} \int_{t_0}^{t_0+\Delta t} H^z_0\,\alpha^z_0\,\alpha^z_i\,du - \epsilon_i \rho^{zx}_{ii}\int_{t_0}^{t_0+\Delta t} \sigma_i^x\,\alpha^z_i\,du \end{eqnarray}

This function covers the latter three integrals, the state-independent part.

Definition at line 29 of file crossassetanalytics.cpp.

29 {
30 Real res = 0.0;
31 if (i == 0) {
32 if (x.measure() == IrModel::Measure::BA)
33 res -= integral(x, P(Hz(i), az(i), az(i)), t0, t0 + dt);
34 } else {
35 res -= integral(x, P(Hz(i), az(i), az(i)), t0, t0 + dt);
36 res -= integral(x, P(az(i), sx(i - 1), rzx(i, i - 1)), t0, t0 + dt);
37 if (x.measure() != IrModel::Measure::BA)
38 res += integral(x, P(Hz(0), az(0), az(i), rzz(0, i)), t0, t0 + dt);
39 }
40 return res;
41}
Real integral(const CrossAssetModel &model, const E &e, const Real a, const Real b)
const P2_< E1, E2 > P(const E1 &e1, const E2 &e2)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ir_expectation_2()

Real ir_expectation_2 ( const CrossAssetModel model,
const Size  i,
const Real  zi_0 
)

IR state expectation This function evaluates the state-dependent part of the expectation

\begin{eqnarray} \mathbb{E}_{t_0}[z_i(t_0+\Delta t)] &=& z_i(t_0) -\int_{t_0}^{t_0+\Delta t} H^z_i\,(\alpha^z_i)^2\,du + \rho^{zz}_{0i} \int_{t_0}^{t_0+\Delta t} H^z_0\,\alpha^z_0\,\alpha^z_i\,du - \epsilon_i \rho^{zx}_{ii}\int_{t_0}^{t_0+\Delta t} \sigma_i^x\,\alpha^z_i\,du \end{eqnarray}

i.e. simply the first contribution \( z_i(t_0) \).

Definition at line 43 of file crossassetanalytics.cpp.

43{ return zi_0; }
+ Here is the caller graph for this function:

◆ inf_jy_expectation_1()

std::pair< QuantLib::Real, QuantLib::Real > inf_jy_expectation_1 ( const CrossAssetModel model,
QuantLib::Size  i,
QuantLib::Time  t0,
QuantLib::Real  dt 
)

State independent portion of the JY inflation drift. The first element of the pair relates to the real rate process and the second element of the pair relates to the inflation index process.

◆ inf_jy_expectation_2()

std::pair< QuantLib::Real, QuantLib::Real > inf_jy_expectation_2 ( const CrossAssetModel model,
QuantLib::Size  i,
QuantLib::Time  t0,
const std::pair< QuantLib::Real, QuantLib::Real > &  state_0,
QuantLib::Real  zi_i_0,
QuantLib::Real  dt 
)

State dependent portion of the JY inflation drift. The first element of the pair relates to the real rate process and the second element of the pair relates to the inflation index process.

◆ fx_expectation_1()

Real fx_expectation_1 ( const CrossAssetModel model,
const Size  i,
const Time  t0,
const Real  dt 
)

FX state expectation

This function evaluates part of the expectation \( \mathbb{E}_{t_0}[\ln x_i(t_0+dt)]\).

Using the results above for factor moves \(\Delta \ln x\) over time interval \((s,t)\), we have

\begin{eqnarray} \mathbb{E}_{t_0}[\ln x_i(t_0+\Delta t)] &=& \ln x_i(t_0) + \mathbb{E}_{t_0}[\Delta \ln x_i], \qquad\mbox{with}\quad \Delta \ln x_i = \ln x_i(t_0+\Delta t) - \ln x_i(t_0) \\ &=& \ln x_i(t_0) + \left(H^z_0(t)-H^z_0(s)\right) z_0(s) -\left(H^z_i(t)-H^z_i(s)\right)z_i(s)\\ &&+ \ln \left( \frac{P^n_0(0,s)}{P^n_0(0,t)} \frac{P^n_i(0,t)}{P^n_i(0,s)}\right) \\ && - \frac12 \int_s^t (\sigma^x_i)^2\,du \\ &&+\frac12 \left((H^z_0(t))^2 \zeta^z_0(t) - (H^z_0(s))^2 \zeta^z_0(s)- \int_s^t (H^z_0)^2 (\alpha^z_0)^2\,du\right)\\ &&-\frac12 \left((H^z_i(t))^2 \zeta^z_i(t) - (H^z_i(s))^2 \zeta^z_i(s)-\int_s^t (H^z_i)^2 (\alpha^z_i)^2\,du \right)\\ && + \rho^{zx}_{0i} \int_s^t H^z_0\, \alpha^z_0\, \sigma^x_i\,du \\ && - \int_s^t \left(H^z_i(t)-H^z_i\right)\gamma_i \,du, \qquad\mbox{with}\quad s = t_0, \quad t = t_0+\Delta t \end{eqnarray}

where we rearranged terms so that the state-dependent terms are listed on the first line (containing \(\ln x_i(t_0), z_i(t_0), z_0(t_0) \)) and all following terms are state-independent (deterministic, just dependent on initial market data and model parameters).

The last integral above contains \(\gamma_i\) which is (see documentation of the CrossAssetModel)

\[ \gamma_i = -H^z_i\,(\alpha^z_i)^2 + H^z_0\,\alpha^z_0\,\alpha^z_i\,\rho^{zz}_{0i} - \sigma_i^x\,\alpha^z_i\, \rho^{zx}_{ii}. \]

The very last last integral above is therefore broken up into six terms which we do not list here, but which show up in this function's implementation.

This function covers the latter state-independent part of the FX expectation.

Definition at line 124 of file crossassetanalytics.cpp.

124 {
125 bool bam = (x.measure() == IrModel::Measure::BA);
126 Real H0_a = Hz(0).eval(x, t0);
127 Real Hi_a = Hz(i + 1).eval(x, t0);
128 Real H0_b = Hz(0).eval(x, t0 + dt);
129 Real Hi_b = Hz(i + 1).eval(x, t0 + dt);
130 Real zeta0_a = zetaz(0).eval(x, t0);
131 Real zetai_a = zetaz(i + 1).eval(x, t0);
132 Real zeta0_b = zetaz(0).eval(x, t0 + dt);
133 Real zetai_b = zetaz(i + 1).eval(x, t0 + dt);
134 Real res = std::log(x.irlgm1f(i + 1)->termStructure()->discount(t0 + dt) /
135 x.irlgm1f(i + 1)->termStructure()->discount(t0) * x.irlgm1f(0)->termStructure()->discount(t0) /
136 x.irlgm1f(0)->termStructure()->discount(t0 + dt));
137 res -= 0.5 * (vx(i).eval(x, t0 + dt) - vx(i).eval(x, t0));
138 res +=
139 0.5 * (H0_b * H0_b * zeta0_b - H0_a * H0_a * zeta0_a - integral(x, P(Hz(0), Hz(0), az(0), az(0)), t0, t0 + dt));
140 res -= 0.5 * (Hi_b * Hi_b * zetai_b - Hi_a * Hi_a * zetai_a -
141 integral(x, P(Hz(i + 1), Hz(i + 1), az(i + 1), az(i + 1)), t0, t0 + dt));
142 res += (bam ? 0.0 : integral(x, P(Hz(0), az(0), sx(i), rzx(0, i)), t0, t0 + dt));
143 res -= Hi_b * (-integral(x, P(Hz(i + 1), az(i + 1), az(i + 1)), t0, t0 + dt) +
144 (bam ? 0.0 : integral(x, P(Hz(0), az(0), az(i + 1), rzz(0, i + 1)), t0, t0 + dt)) -
145 integral(x, P(az(i + 1), sx(i), rzx(i + 1, i)), t0, t0 + dt));
146 res += -integral(x, P(Hz(i + 1), Hz(i + 1), az(i + 1), az(i + 1)), t0, t0 + dt) +
147 (bam ? 0.0 : integral(x, P(Hz(0), Hz(i + 1), az(0), az(i + 1), rzz(0, i + 1)), t0, t0 + dt)) -
148 integral(x, P(Hz(i + 1), az(i + 1), sx(i), rzx(i + 1, i)), t0, t0 + dt);
149 if (bam) {
150 res -= H0_b * integral(x, P(Hz(0), az(0), az(0)), t0, t0 + dt);
151 res += integral(x, P(Hz(0), Hz(0), az(0), az(0)), t0, t0 + dt);
152 }
153 return res;
154}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fx_expectation_2()

Real fx_expectation_2 ( const CrossAssetModel model,
const Size  i,
const Time  t0,
const Real  xi_0,
const Real  zi_0,
const Real  z0_0,
const Real  dt 
)

FX state expectation.

This function covers the state-dependent part of the FX expectation.

Definition at line 156 of file crossassetanalytics.cpp.

157 {
158 Real res = xi_0 + (Hz(0).eval(x, t0 + dt) - Hz(0).eval(x, t0)) * z0_0 -
159 (Hz(i + 1).eval(x, t0 + dt) - Hz(i + 1).eval(x, t0)) * zi_0;
160 return res;
161}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eq_expectation_1()

Real eq_expectation_1 ( const CrossAssetModel model,
const Size  i,
const Time  t0,
const Real  dt 
)

EQ state expectation

This function covers part of the EQ expectation. The overall expectation formula (taken from the book "Modern Derivatives Pricing and Credit Exposure Analysis" by Lichters, Stamm and Gallagher) is as follows:

\begin{eqnarray} \mathbb{E} \left[\Delta ln[s_k]\right] &=& ln \left[ \frac{P_{\phi(k)}(0,s)}{P_{\phi(k)}(0,t)} \right] - \int_{s}^{t} q_k(u) du - \frac{1}{2} \int_{s}^{t}\sigma_{s_k}^2(u) du\\ && +\rho_{z_0,s_k}\int_{s}^{t}\alpha_0(u) H_0(u) \sigma_{s_k}(u) du - \epsilon_{\phi(k)} \rho_{s_k,x_{\phi(k)}} \int_{s}^{t} \sigma_{s_k}(u)\sigma_{x_{\phi(k)}}(u) du\\ &&+\frac{1}{2} \left( H_{\phi(k)}^2(t) \zeta_{\phi(k)}(t) - H_{\phi(k)}^2(s) \zeta_{\phi(k)}(s) - \int_{s}^{t} H_{\phi(k)}^2(u) \alpha_{\phi(k)}^2(u) du \right)\\ && + (H_{\phi(k)}(t) - H_{\phi(k)}(s)) z_{\phi(k)}(s) +\epsilon_{\phi(k)} \int_{s}^{t} \gamma_{\phi(k)} (u) (H_{\phi(k)}(t) - H_{\phi(k)}(u)) du,\\ && \qquad\mbox{with}\quad s = t_0, \quad t = t_0+\Delta t, \quad \phi(k) = \qquad\mbox{ interest rate for currency of equity k} \end{eqnarray}

This function covers the state-independent part of the EQ expectation

Definition at line 163 of file crossassetanalytics.cpp.

163 {
164 Size i = x.ccyIndex(x.eqbs(k)->currency());
165 Size eps_i = (i == 0) ? 0 : 1;
166 Real Hi_a = Hz(i).eval(x, t0);
167 Real Hi_b = Hz(i).eval(x, t0 + dt);
168 Real zetai_a = zetaz(i).eval(x, t0);
169 Real zetai_b = zetaz(i).eval(x, t0 + dt);
170 Real res = std::log(
171 x.eqbs(k)->equityDivYieldCurveToday()->discount(t0 + dt) / x.eqbs(k)->equityDivYieldCurveToday()->discount(t0) *
172 x.eqbs(k)->equityIrCurveToday()->discount(t0) / x.eqbs(k)->equityIrCurveToday()->discount(t0 + dt));
173 res -= 0.5 * (vs(k).eval(x, t0 + dt) - vs(k).eval(x, t0));
174 res +=
175 0.5 * (Hi_b * Hi_b * zetai_b - Hi_a * Hi_a * zetai_a - integral(x, P(Hz(i), Hz(i), az(i), az(i)), t0, t0 + dt));
176 res += integral(x, P(rzs(0, k), Hz(0), az(0), ss(k)), t0, t0 + dt);
177 if (eps_i > 0) {
178 res -= integral(x, P(rxs(i - 1, k), sx(i - 1), ss(k)), t0, t0 + dt);
179 }
180 // expand gamma term
181 if (eps_i > 0) {
182 res += Hi_b * (-integral(x, P(Hz(i), az(i), az(i)), t0, t0 + dt) -
183 integral(x, P(rzx(i, i - 1), sx(i - 1), az(i)), t0, t0 + dt) +
184 integral(x, P(rzz(0, i), az(i), az(0), Hz(0)), t0, t0 + dt));
185 res -= (-integral(x, P(Hz(i), Hz(i), az(i), az(i)), t0, t0 + dt) -
186 integral(x, P(Hz(i), rzx(i, i - 1), sx(i - 1), az(i)), t0, t0 + dt) +
187 integral(x, P(Hz(i), rzz(0, i), az(i), az(0), Hz(0)), t0, t0 + dt));
188 }
189 return res;
190}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eq_expectation_2()

Real eq_expectation_2 ( const CrossAssetModel model,
const Size  k,
const Time  t0,
const Real  si_0,
const Real  zi_0,
const Real  dt 
)

EQ state expectation

This function covers the state-dependent part of the EQ expectation (see overall expression above).

Definition at line 192 of file crossassetanalytics.cpp.

193 {
194 Size i = x.ccyIndex(x.eqbs(k)->currency());
195 Real Hi_a = Hz(i).eval(x, t0);
196 Real Hi_b = Hz(i).eval(x, t0 + dt);
197 Real res = sk_0 + (Hi_b - Hi_a) * zi_0;
198 return res;
199}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ir_ir_covariance()

Real ir_ir_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

IR-IR Covariance

This function evaluates the covariance term

\f{eqnarray*}{
\mathrm{Cov}[\Delta z_a, \Delta z_b] &=& \rho^{zz}_{ab} \int_s^t \alpha^z_a\,\alpha^z_b\,du
\f}

on the time interval from \f$ s= t_0\f$ to \f$ t=t_0+\Delta t\f$.

Definition at line 201 of file crossassetanalytics.cpp.

201 {
202 Real res = integral(x, P(az(i), az(j), rzz(i, j)), t0, t0 + dt);
203 return res;
204}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ir_fx_covariance()

Real ir_fx_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

IR-FX Covariance

This function evaluates the covariance term

\begin{eqnarray} \mathrm{Cov} [\Delta z_a, \Delta \ln x_b]) &=& \rho^{zz}_{0a}\int_s^t \left(H^z_0(t)-H^z_0\right) \alpha^z_0\,\alpha^z_a\,du \nonumber\\ &&- \rho^{zz}_{ab}\int_s^t \alpha^z_a \left(H^z_b(t)-H^z_b\right) \alpha^z_b \,du \nonumber\\ &&+\rho^{zx}_{ab}\int_s^t \alpha^z_a \, \sigma^x_b \,du. \end{eqnarray}

on the time interval from \( s= t_0\) to \( t=t_0+\Delta t\).

Definition at line 206 of file crossassetanalytics.cpp.

206 {
207 Real res = Hz(0).eval(x, t0 + dt) * integral(x, P(az(0), az(i), rzz(0, i)), t0, t0 + dt) -
208 integral(x, P(Hz(0), az(0), az(i), rzz(0, i)), t0, t0 + dt) -
209 Hz(j + 1).eval(x, t0 + dt) * integral(x, P(az(j + 1), az(i), rzz(j + 1, i)), t0, t0 + dt) +
210 integral(x, P(Hz(j + 1), az(j + 1), az(i), rzz(j + 1, i)), t0, t0 + dt) +
211 integral(x, P(az(i), sx(j), rzx(i, j)), t0, t0 + dt);
212 return res;
213}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fx_fx_covariance()

Real fx_fx_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

FX-FX covariance

This function evaluates the covariance term

\begin{eqnarray} \mathrm{Cov}[\Delta \ln x_a, \Delta \ln x_b] &=& \int_s^t \left(H^z_0(t)-H^z_0\right)^2 (\alpha_0^z)^2\,du \nonumber\\ && -\rho^{zz}_{0a} \int_s^t \left(H^z_a(t)-H^z_a\right) \alpha_a^z\left(H^z_0(t)-H^z_0\right) \alpha_0^z\,du \nonumber\\ &&- \rho^{zz}_{0b}\int_s^t \left(H^z_0(t)-H^z_0\right)\alpha_0^z \left(H^z_b(t)-H^z_b\right)\alpha_b^z\,du \nonumber\\ &&+ \rho^{zx}_{0b}\int_s^t \left(H^z_0(t)-H^z_0\right)\alpha_0^z \sigma^x_b\,du \nonumber\\ &&+ \rho^{zx}_{0a}\int_s^t \left(H^z_0(t)-H^z_0\right)\alpha_0^z\,\sigma^x_a\,du \nonumber\\ &&- \rho^{zx}_{ab}\int_s^t \left(H^z_a(t)-H^z_a\right)\alpha_a^z \sigma^x_b,du\nonumber\\ &&- \rho^{zx}_{ba}\int_s^t \left(H^z_b(t)-H^z_b\right)\alpha_b^z\,\sigma^x_a\, du \nonumber\\ &&+ \rho^{zz}_{ab}\int_s^t \left(H^z_a(t)-H^z_a\right)\alpha_a^z \left(H^z_b(t)-H^z_b\right)\alpha_b^z\,du \nonumber\\ &&+ \rho^{xx}_{ab}\int_s^t\sigma^x_a\,\sigma^x_b \,du \end{eqnarray}

on the time interval from \( s= t_0\) to \( t=t_0+\Delta t\).

The implementation of this FX-FX covariance in this function further decomposes all terms in order to separate simple and more complex integrations and to allow for tailored efficient numerical integration schemes. Line by line, the covariance above can be written:

\begin{eqnarray} \mathrm{Cov}[\Delta \ln x_a, \Delta \ln x_b] &=& (H^z_0)^2(t)\int_s^t (\alpha_0^z)^2\,du - 2 \,H^z_0(t)\int_s^t H^z_0 (\alpha_0^z)^2\,du + \int_s^t (H^z_0\,\alpha_0^z)^2\,du \\ && - \rho^{zz}_{0a} H^z_0(t) \,H^z_a(t)\int_s^t \alpha_0^z\,\alpha_a^z\,du + \rho^{zz}_{0a} H^z_a(t) \int_s^t H^z_0\,\alpha_0^z\,\alpha_a^z\,du + \rho^{zz}_{0a} H^z_0(t) \int_s^t H^z_a\,\alpha_0^z\,\alpha_a^z\,du - \rho^{zz}_{0a}\int_s^t H^z_0\,H^z_a\,\alpha_0^z\,\alpha_a^z\,du \\ && - \rho^{zz}_{0b} H^z_0(t) \,H^z_b(t)\int_s^t \alpha_0^z\,\alpha_b^z\,du + \rho^{zz}_{0b} H^z_b(t) \int_s^t H^z_0\,\alpha_0^z\,\alpha_b^z\,du + \rho^{zz}_{0b} H^z_0(t) \int_s^t H^z_b\,\alpha_0^z\,\alpha_b^z\,du - \rho^{zz}_{0b}\int_s^t H^z_0\,H^z_b\,\alpha_0^z\,\alpha_b^z\,du \\ && + \rho^{zx}_{0b} H^z_0(t) \int_s^t \alpha_0^z \,\sigma^x_b\,du - \rho^{zx}_{0b} \int_s^t H^z_0 \,\alpha_0^z \,\sigma^x_b\,du \\ && + \rho^{zx}_{0a} H^z_0(t) \int_s^t \alpha_0^z \,\sigma^x_a\,du - \rho^{zx}_{0a} \int_s^t H^z_0 \,\alpha_0^z \,\sigma^x_a\,du \\ && - \rho^{zx}_{ab} H^z_a(t) \int_s^t \alpha_a^z \sigma^x_b,du + \rho^{zx}_{ab} \int_s^t H^z_a\,\alpha_a^z \sigma^x_b,du \\ && - \rho^{zx}_{ba} H^z_b(t) \int_s^t \alpha_b^z \sigma^x_a,du + \rho^{zx}_{ba} \int_s^t H^z_b\,\alpha_b^z \sigma^x_a,du \\ && + \rho^{zz}_{ab} H^z_a(t) H^z_b(t) \int_s^t \alpha_a^z \alpha_b^z \,du - \rho^{zz}_{ab} H^z_b(t) \int_s^t H^z_a \alpha_a^z \alpha_b^z \,du - \rho^{zz}_{ab} H^z_a(t) \int_s^t H^z_b \alpha_a^z \alpha_b^z \,du + \rho^{zz}_{ab} \int_s^t H^z_a H^z_b \alpha_a^z \alpha_b^z \,du \\ && + \rho^{xx}_{ab} \int_s^t\sigma^x_a\,\sigma^x_b \,du \end{eqnarray}

When comparing with the code, also note that the integral on line one can be simplified to

\[ \int_s^t (\alpha_0^z)^2\,du = \zeta_0(t) - \zeta_0(s) \]

Definition at line 215 of file crossassetanalytics.cpp.

215 {
216 Real H0 = Hz(0).eval(x, t0 + dt);
217 Real Hi = Hz(i + 1).eval(x, t0 + dt);
218 Real Hj = Hz(j + 1).eval(x, t0 + dt);
219 Real res =
220 // row 1
221 H0 * H0 * (zetaz(0).eval(x, t0 + dt) - zetaz(0).eval(x, t0)) -
222 2.0 * H0 * integral(x, P(Hz(0), az(0), az(0)), t0, t0 + dt) +
223 integral(x, P(Hz(0), Hz(0), az(0), az(0)), t0, t0 + dt) -
224 // row 2
225 H0 * Hj * integral(x, P(az(0), az(j + 1), rzz(0, j + 1)), t0, t0 + dt) +
226 Hj * integral(x, P(Hz(0), az(0), az(j + 1), rzz(0, j + 1)), t0, t0 + dt) +
227 H0 * integral(x, P(Hz(j + 1), az(j + 1), az(0), rzz(j + 1, 0)), t0, t0 + dt) -
228 integral(x, P(Hz(0), Hz(j + 1), az(0), az(j + 1), rzz(0, j + 1)), t0, t0 + dt) -
229 // row 3
230 H0 * Hi * integral(x, P(az(0), az(i + 1), rzz(0, i + 1)), t0, t0 + dt) +
231 Hi * integral(x, P(Hz(0), az(0), az(i + 1), rzz(0, i + 1)), t0, t0 + dt) +
232 H0 * integral(x, P(Hz(i + 1), az(i + 1), az(0), rzz(i + 1, 0)), t0, t0 + dt) -
233 integral(x, P(Hz(0), Hz(i + 1), az(0), az(i + 1), rzz(0, i + 1)), t0, t0 + dt) +
234 // row 4
235 H0 * integral(x, P(az(0), sx(j), rzx(0, j)), t0, t0 + dt) -
236 integral(x, P(Hz(0), az(0), sx(j), rzx(0, j)), t0, t0 + dt) +
237 // row 5
238 H0 * integral(x, P(az(0), sx(i), rzx(0, i)), t0, t0 + dt) -
239 integral(x, P(Hz(0), az(0), sx(i), rzx(0, i)), t0, t0 + dt) -
240 // row 6
241 Hi * integral(x, P(az(i + 1), sx(j), rzx(i + 1, j)), t0, t0 + dt) +
242 integral(x, P(Hz(i + 1), az(i + 1), sx(j), rzx(i + 1, j)), t0, t0 + dt) -
243 // row 7
244 Hj * integral(x, P(az(j + 1), sx(i), rzx(j + 1, i)), t0, t0 + dt) +
245 integral(x, P(Hz(j + 1), az(j + 1), sx(i), rzx(j + 1, i)), t0, t0 + dt) +
246 // row 8
247 Hi * Hj * integral(x, P(az(i + 1), az(j + 1), rzz(i + 1, j + 1)), t0, t0 + dt) -
248 Hj * integral(x, P(Hz(i + 1), az(i + 1), az(j + 1), rzz(i + 1, j + 1)), t0, t0 + dt) -
249 Hi * integral(x, P(Hz(j + 1), az(j + 1), az(i + 1), rzz(j + 1, i + 1)), t0, t0 + dt) +
250 integral(x, P(Hz(i + 1), Hz(j + 1), az(i + 1), az(j + 1), rzz(i + 1, j + 1)), t0, t0 + dt) +
251 // row 9
252 integral(x, P(sx(i), sx(j), rxx(i, j)), t0, t0 + dt);
253 return res;
254}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infz_infz_covariance()

Real infz_infz_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

infz-infz covariance

Definition at line 256 of file crossassetanalytics.cpp.

256 {
257 return integral(x, P(ryy(i, j), ay(i), ay(j)), t0, t0 + dt);
258 ;
259}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infz_infy_covariance()

Real infz_infy_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

infz-infy covariance

Definition at line 261 of file crossassetanalytics.cpp.

261 {
262
263 Real res = 0.0;
264
265 // Assumption that INF is either JY or DK. j-th inflation model's y component depends on model type.
266 if (x.modelType(CrossAssetModel::AssetType::INF, j) == CrossAssetModel::ModelType::DK) {
267 res = integral(x, P(ryy(i, j), ay(i), Hy(j), ay(j)), t0, t0 + dt);
268 } else {
269 // i_j - index of j-th inflation component's currency.
270 Size i_j = x.ccyIndex(x.infjy(j)->currency());
271 // H_{i_j}^{z}(t_0 + dt)
272 Real Hi_j = Hz(i_j).eval(x, t0 + dt);
273 // H_{j}^{y}(t_0 + dt)
274 Real Hj = Hy(j).eval(x, t0 + dt);
275
276 res = integral(x, P(rzy(i_j, i), az(i_j), ay(i), LC(Hi_j, -1.0, Hz(i_j))), t0, t0 + dt);
277 res -= integral(x, P(ryy(i, j), ay(i), ay(j), LC(Hj, -1.0, Hy(j))), t0, t0 + dt);
278 res += integral(x, P(ryy(i, j, 0, 1), ay(i), sy(j)), t0, t0 + dt);
279 }
280
281 return res;
282}
const LC1_< E1 > LC(QuantLib::Real c, QuantLib::Real c1, const E1 &e1)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infy_infy_covariance()

Real infy_infy_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

infy-infy covariance

Definition at line 284 of file crossassetanalytics.cpp.

284 {
285
286 Real res = 0.0;
287
288 // Assumption that INF is either JY or DK. Four possibilities.
289 auto mti = x.modelType(CrossAssetModel::AssetType::INF, i);
290 auto mtj = x.modelType(CrossAssetModel::AssetType::INF, j);
291 if (mti == CrossAssetModel::ModelType::DK && mtj == CrossAssetModel::ModelType::DK) {
292 res = integral(x, P(ryy(i, j), Hy(i), ay(i), Hy(j), ay(j)), t0, t0 + dt);
293 } else if (mti == CrossAssetModel::ModelType::JY && mtj == CrossAssetModel::ModelType::DK) {
294
295 // i_i - index of i-th inflation component's currency.
296 Size i_i = x.ccyIndex(x.infjy(i)->currency());
297 // H_{i_i}^{z}(t_0 + dt)
298 Real Hi_i = Hz(i_i).eval(x, t0 + dt);
299 // H_{i}^{y}(t_0 + dt)
300 Real Hi = Hy(i).eval(x, t0 + dt);
301
302 // 3 terms in the covariance.
303 res = integral(x, P(rzy(i_i, j), Hy(j), ay(j), az(i_i), LC(Hi_i, -1.0, Hz(i_i))), t0, t0 + dt);
304 res -= integral(x, P(ryy(i, j, 0, 0), Hy(j), ay(j), ay(i), LC(Hi, -1.0, Hy(i))), t0, t0 + dt);
305 res += integral(x, P(ryy(i, j, 1, 0), Hy(j), ay(j), sy(i)), t0, t0 + dt);
306
307 } else if (mti == CrossAssetModel::ModelType::DK && mtj == CrossAssetModel::ModelType::JY) {
308
309 // i_j - index of j-th inflation component's currency.
310 Size i_j = x.ccyIndex(x.infjy(j)->currency());
311 // H_{i_j}^{z}(t_0 + dt)
312 Real Hi_j = Hz(i_j).eval(x, t0 + dt);
313 // H_{j}^{y}(t_0 + dt)
314 Real Hj = Hy(j).eval(x, t0 + dt);
315
316 // 3 terms in the covariance.
317 res = integral(x, P(rzy(i_j, i), Hy(i), ay(i), az(i_j), LC(Hi_j, -1.0, Hz(i_j))), t0, t0 + dt);
318 res -= integral(x, P(ryy(i, j, 0, 0), Hy(i), ay(i), ay(j), LC(Hj, -1.0, Hy(j))), t0, t0 + dt);
319 res += integral(x, P(ryy(i, j, 0, 1), Hy(i), ay(i), sy(j)), t0, t0 + dt);
320
321 } else {
322
323 // index of each inflation component's currency.
324 Size i_i = x.ccyIndex(x.infjy(i)->currency());
325 Size i_j = x.ccyIndex(x.infjy(j)->currency());
326 // H_{i_\cdot}^{z}(t_0 + dt)
327 Real Hi_i = Hz(i_i).eval(x, t0 + dt);
328 Real Hi_j = Hz(i_j).eval(x, t0 + dt);
329 // H_{\cdot}^{y}(t_0 + dt)
330 Real Hi = Hy(i).eval(x, t0 + dt);
331 Real Hj = Hy(j).eval(x, t0 + dt);
332
333 res = integral(x, P(rzz(i_i, i_j), az(i_i), LC(Hi_i, -1.0, Hz(i_i)), az(i_j), LC(Hi_j, -1.0, Hz(i_j))), t0,
334 t0 + dt);
335 res -=
336 integral(x, P(rzy(i_i, j, 0), az(i_i), LC(Hi_i, -1.0, Hz(i_i)), ay(j), LC(Hj, -1.0, Hy(j))), t0, t0 + dt);
337 res += integral(x, P(rzy(i_i, j, 1), az(i_i), LC(Hi_i, -1.0, Hz(i_i)), sy(j)), t0, t0 + dt);
338 res -=
339 integral(x, P(rzy(i_j, i, 0), ay(i), LC(Hi, -1.0, Hy(i)), az(i_j), LC(Hi_j, -1.0, Hz(i_j))), t0, t0 + dt);
340 res += integral(x, P(ryy(i, j), ay(i), LC(Hi, -1.0, Hy(i)), ay(j), LC(Hj, -1.0, Hy(j))), t0, t0 + dt);
341 res -= integral(x, P(ryy(i, j, 0, 1), ay(i), LC(Hi, -1.0, Hy(i)), sy(j)), t0, t0 + dt);
342 res += integral(x, P(rzy(i_j, i, 1), sy(i), az(i_j), LC(Hi_j, -1.0, Hz(i_j))), t0, t0 + dt);
343 res -= integral(x, P(ryy(i, j, 1, 0), sy(i), ay(j), LC(Hj, -1.0, Hy(j))), t0, t0 + dt);
344 res += integral(x, P(ryy(i, j, 1, 1), sy(i), sy(j)), t0, t0 + dt);
345 }
346
347 return res;
348}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ir_infz_covariance()

Real ir_infz_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

ir-infz covariance

Definition at line 350 of file crossassetanalytics.cpp.

350 {
351 return integral(x, P(rzy(i, j), az(i), ay(j)), t0, t0 + dt);
352}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ir_infy_covariance()

Real ir_infy_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

ir-infy covariance

Definition at line 354 of file crossassetanalytics.cpp.

354 {
355 // Assumption that INF is either JY or DK.
356 if (x.modelType(CrossAssetModel::AssetType::INF, j) == CrossAssetModel::ModelType::DK) {
357 return integral(x, P(rzy(i, j), az(i), Hy(j), ay(j)), t0, t0 + dt);
358 } else {
359 // i_j - index of j-th inflation component's currency.
360 Size i_j = x.ccyIndex(x.infjy(j)->currency());
361 // H_{i_j}^{z}(t_0 + dt)
362 Real Hi_j = Hz(i_j).eval(x, t0 + dt);
363 // H_{j}^{y}(t_0 + dt)
364 Real Hj = Hy(j).eval(x, t0 + dt);
365
366 Real res = integral(x, P(rzz(i, i_j), az(i), az(i_j), LC(Hi_j, -1.0, Hz(i_j))), t0, t0 + dt);
367 res -= integral(x, P(rzy(i, j, 0), az(i), ay(j), LC(Hj, -1.0, Hy(j))), t0, t0 + dt);
368 res += integral(x, P(rzy(i, j, 1), az(i), sy(j)), t0, t0 + dt);
369
370 return res;
371 }
372}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fx_infz_covariance()

Real fx_infz_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

fx-infz covariance

Definition at line 374 of file crossassetanalytics.cpp.

374 {
375 Real H0 = Hz(0).eval(x, t0 + dt);
376 Real Hi = Hz(i + 1).eval(x, t0 + dt);
377 Real res = -integral(x, P(rzy(0, j), Hz(0), az(0), ay(j)), t0, t0 + dt) +
378 H0 * integral(x, P(rzy(0, j), az(0), ay(j)), t0, t0 + dt) +
379 integral(x, P(rzy(i + 1, j), Hz(i + 1), az(i + 1), ay(j)), t0, t0 + dt) -
380 Hi * integral(x, P(rzy(i + 1, j), az(i + 1), ay(j)), t0, t0 + dt) +
381 integral(x, P(rxy(i, j), sx(i), ay(j)), t0, t0 + dt);
382 return res;
383}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fx_infy_covariance()

Real fx_infy_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

fx-infy covariance

Definition at line 385 of file crossassetanalytics.cpp.

385 {
386
387 Real res = 0.0;
388 Real H0 = Hz(0).eval(x, t0 + dt);
389 Real Hi = Hz(i + 1).eval(x, t0 + dt);
390
391 if (x.modelType(CrossAssetModel::AssetType::INF, j) == CrossAssetModel::ModelType::DK) {
392 res = -integral(x, P(rzy(0, j), Hz(0), az(0), Hy(j), ay(j)), t0, t0 + dt) +
393 H0 * integral(x, P(rzy(0, j), az(0), Hy(j), ay(j)), t0, t0 + dt) +
394 integral(x, P(rzy(i + 1, j), Hz(i + 1), az(i + 1), Hy(j), ay(j)), t0, t0 + dt) -
395 Hi * integral(x, P(rzy(i + 1, j), az(i + 1), Hy(j), ay(j)), t0, t0 + dt) +
396 integral(x, P(rxy(i, j), sx(i), Hy(j), ay(j)), t0, t0 + dt);
397 } else {
398
399 // i_j - index of j-th inflation component's currency.
400 Size i_j = x.ccyIndex(x.infjy(j)->currency());
401 // H_{i_j}^{z}(t_0 + dt)
402 Real Hi_j = Hz(i_j).eval(x, t0 + dt);
403 // H_{j}^{y}(t_0 + dt)
404 Real Hj = Hy(j).eval(x, t0 + dt);
405
406 res = integral(x, P(rzz(i_j, 0), az(i_j), LC(Hi_j, -1.0, Hz(i_j)), az(0), LC(H0, -1.0, Hz(0))), t0, t0 + dt);
407 res -= integral(x, P(rzz(i_j, i + 1), az(i_j), LC(Hi_j, -1.0, Hz(i_j)), az(i + 1), LC(Hi, -1.0, Hz(i + 1))), t0,
408 t0 + dt);
409 res += integral(x, P(rzx(i_j, i), az(i_j), LC(Hi_j, -1.0, Hz(i_j)), sx(i)), t0, t0 + dt);
410 res -= integral(x, P(rzy(0, j, 0), ay(j), LC(Hj, -1.0, Hy(j)), az(0), LC(H0, -1.0, Hz(0))), t0, t0 + dt);
411 res += integral(x, P(rzy(i + 1, j, 0), ay(j), LC(Hj, -1.0, Hy(j)), az(i + 1), LC(Hi, -1.0, Hz(i + 1))), t0,
412 t0 + dt);
413 res -= integral(x, P(rxy(i, j), ay(j), LC(Hj, -1.0, Hy(j)), sx(i)), t0, t0 + dt);
414 res += integral(x, P(rzy(0, j, 1), sy(j), az(0), LC(H0, -1.0, Hz(0))), t0, t0 + dt);
415 res -= integral(x, P(rzy(i + 1, j, 1), sy(j), az(i + 1), LC(Hi, -1.0, Hz(i + 1))), t0, t0 + dt);
416 res += integral(x, P(rxy(i, j, 1), sx(i), sy(j)), t0, t0 + dt);
417 }
418
419 return res;
420}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crz_crz_covariance()

Real crz_crz_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

crz-crz covariance

Definition at line 422 of file crossassetanalytics.cpp.

422 {
423 Real res = integral(x, P(rll(i, j), al(i), al(j)), t0, t0 + dt);
424 return res;
425}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crz_cry_covariance()

Real crz_cry_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

crz-cry covariance

Definition at line 427 of file crossassetanalytics.cpp.

427 {
428 Real res = integral(x, P(rll(i, j), al(i), Hl(j), al(j)), t0, t0 + dt);
429 return res;
430}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cry_cry_covariance()

Real cry_cry_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

cry-cry covariance

Definition at line 432 of file crossassetanalytics.cpp.

432 {
433 Real res = integral(x, P(rll(i, j), Hl(i), al(i), Hl(j), al(j)), t0, t0 + dt);
434 return res;
435}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ir_crz_covariance()

Real ir_crz_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

ir-crz covariance

Definition at line 437 of file crossassetanalytics.cpp.

437 {
438 Real res = integral(x, P(rzl(i, j), az(i), al(j)), t0, t0 + dt);
439 return res;
440}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ir_cry_covariance()

Real ir_cry_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

ir-cry covariance

Definition at line 442 of file crossassetanalytics.cpp.

442 {
443 Real res = integral(x, P(rzl(i, j), az(i), Hl(j), al(j)), t0, t0 + dt);
444 return res;
445}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fx_crz_covariance()

Real fx_crz_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

fx-crz covariance

Definition at line 447 of file crossassetanalytics.cpp.

447 {
448 Real H0 = Hz(0).eval(x, t0 + dt);
449 Real Hi = Hz(i + 1).eval(x, t0 + dt);
450 Real res = -integral(x, P(rzl(0, j), Hz(0), az(0), al(j)), t0, t0 + dt) +
451 H0 * integral(x, P(rzl(0, j), az(0), al(j)), t0, t0 + dt) +
452 integral(x, P(rzl(i + 1, j), Hz(i + 1), az(i + 1), al(j)), t0, t0 + dt) -
453 Hi * integral(x, P(rzl(i + 1, j), az(i + 1), al(j)), t0, t0 + dt) +
454 integral(x, P(rxl(i, j), sx(i), al(j)), t0, t0 + dt);
455 return res;
456}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fx_cry_covariance()

Real fx_cry_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

fx-cry covariance

Definition at line 458 of file crossassetanalytics.cpp.

458 {
459 Real H0 = Hz(0).eval(x, t0 + dt);
460 Real Hi = Hz(i + 1).eval(x, t0 + dt);
461 Real res = -integral(x, P(rzl(0, j), Hz(0), az(0), Hl(j), al(j)), t0, t0 + dt) +
462 H0 * integral(x, P(rzl(0, j), az(0), Hl(j), al(j)), t0, t0 + dt) +
463 integral(x, P(rzl(i + 1, j), Hz(i + 1), az(i + 1), Hl(j), al(j)), t0, t0 + dt) -
464 Hi * integral(x, P(rzl(i + 1, j), az(i + 1), Hl(j), al(j)), t0, t0 + dt) +
465 integral(x, P(rxl(i, j), sx(i), Hl(j), al(j)), t0, t0 + dt);
466 return res;
467}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infz_crz_covariance()

Real infz_crz_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

infz-crz covariance

Definition at line 469 of file crossassetanalytics.cpp.

469 {
470 Real res = integral(x, P(ryl(i, j), ay(i), al(j)), t0, t0 + dt);
471 return res;
472}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infz_cry_covariance()

Real infz_cry_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

infz-cry covariance

Definition at line 474 of file crossassetanalytics.cpp.

474 {
475 Real res = integral(x, P(ryl(i, j), ay(i), Hl(j), al(j)), t0, t0 + dt);
476 return res;
477}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infy_crz_covariance()

Real infy_crz_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

infy-crz covariance

Definition at line 479 of file crossassetanalytics.cpp.

479 {
480
481 Real res = 0.0;
482 if (x.modelType(CrossAssetModel::AssetType::INF, i) == CrossAssetModel::ModelType::DK) {
483 res = integral(x, P(ryl(i, j), Hy(i), ay(i), al(j)), t0, t0 + dt);
484 } else {
485
486 // i_i - index of i-th inflation component's currency.
487 Size i_i = x.ccyIndex(x.infjy(i)->currency());
488 // H_{i_i}^{z}(t_0 + dt)
489 Real Hi_i = Hz(i_i).eval(x, t0 + dt);
490 // H_{i}^{y}(t_0 + dt)
491 Real Hi = Hy(i).eval(x, t0 + dt);
492
493 res = integral(x, P(rzl(i_i, j), az(i_i), LC(Hi_i, -1.0, Hz(i_i)), al(j)), t0, t0 + dt);
494 res -= integral(x, P(ryl(i, j, 0), ay(i), LC(Hi, -1.0, Hy(i)), al(j)), t0, t0 + dt);
495 res += integral(x, P(ryl(i, j, 1), sy(i), al(j)), t0, t0 + dt);
496 }
497
498 return res;
499}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infy_cry_covariance()

Real infy_cry_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

infy-cry covariance

Definition at line 501 of file crossassetanalytics.cpp.

501 {
502
503 Real res = 0.0;
504 if (x.modelType(CrossAssetModel::AssetType::INF, i) == CrossAssetModel::ModelType::DK) {
505 res = integral(x, P(ryl(i, j), Hy(i), ay(i), Hl(j), al(j)), t0, t0 + dt);
506 } else {
507
508 // i_i - index of i-th inflation component's currency.
509 Size i_i = x.ccyIndex(x.infjy(i)->currency());
510 // H_{i_i}^{z}(t_0 + dt)
511 Real Hi_i = Hz(i_i).eval(x, t0 + dt);
512 // H_{i}^{y}(t_0 + dt)
513 Real Hi = Hy(i).eval(x, t0 + dt);
514
515 res = integral(x, P(rzl(i_i, j), az(i_i), LC(Hi_i, -1.0, Hz(i_i)), Hl(j), al(j)), t0, t0 + dt);
516 res -= integral(x, P(ryl(i, j, 0), ay(i), LC(Hi, -1.0, Hy(i)), Hl(j), al(j)), t0, t0 + dt);
517 res += integral(x, P(ryl(i, j, 1), sy(i), Hl(j), al(j)), t0, t0 + dt);
518 }
519
520 return res;
521}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ir_eq_covariance()

Real ir_eq_covariance ( const CrossAssetModel model,
const Size  irIdx,
const Size  eqIdx,
const Time  t0,
const Time  dt 
)

IR-EQ Covariance

\begin{eqnarray} Cov \left[\Delta ln[s_i], \Delta z_j \right] &=& \rho_{z_{\phi(i)},z_j} \int_{s}^{t} (H_{\phi(i)} (t) - H_{\phi(i)} (u)) \alpha_{\phi(i)} (u) \alpha_j (u) du\\ &&+ \rho_{s_i,z_j} \int_{s}^{t} \sigma_{s_i} (u) \alpha_j (u) du\\ \end{eqnarray}

Definition at line 523 of file crossassetanalytics.cpp.

523 {
524 Size i = x.ccyIndex(x.eqbs(k)->currency()); // the equity underlying currency
525 Real Hi_b = Hz(i).eval(x, t0 + dt);
526 Real res = Hi_b * integral(x, P(rzz(i, j), az(i), az(j)), t0, t0 + dt);
527 res -= integral(x, P(Hz(i), rzz(i, j), az(i), az(j)), t0, t0 + dt);
528 res += integral(x, P(rzs(j, k), az(j), ss(k)), t0, t0 + dt);
529 return res;
530}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fx_eq_covariance()

Real fx_eq_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

FX-EQ Covariance

\begin{eqnarray} Cov \left[\Delta ln[s_i], \Delta ln[x_j] \right] &=& \rho_{z_{\phi(i)},z_0} \int_{s}^{t} (H_{\phi(i)} (t) - H_{\phi(i)} (u)) (H_0 (t) - H_0 (u)) \alpha_{\phi(i)}(u) \alpha_0(u) du\\ && - \rho_{z_{\phi(i)},z_j} \int_{s}^{t} (H_{\phi(i)} (t) - H_{\phi(i)} (u)) (H_j (t) - H_j (u)) \alpha_{\phi(i)} (u)\alpha_j(u) du\\ && + \rho_{z_{\phi(i)},x_j} \int_{s}^{t} (H_{\phi(i)} (t) - H_{\phi(i)} (u)) \alpha_{\phi(i)} (u) \sigma_{x_j}(u) du\\ &&+ \rho_{s_i,z_0} \int_{s}^{t} (H_0 (t) - H_0 (u)) \alpha_0 (u) \sigma_{s_i}(u) du\\ &&- \rho_{s_i,z_j} \int_{s}^{t} (H_j (t) - H_j (u)) \alpha_j (u) \sigma_{s_i}(u) du\\ &&+ \rho_{s_i,x_j} \int_{s}^{t} \sigma_{s_i}(u) \sigma_{x_j}(u) du\\ \end{eqnarray}

Definition at line 532 of file crossassetanalytics.cpp.

532 {
533 Size i = x.ccyIndex(x.eqbs(k)->currency()); // the equity underlying currency
534 const Size& j_lgm = j + 1; // indexing of the FX currency for extracting the LGM terms
535 Real Hi_b = Hz(i).eval(x, t0 + dt);
536 Real Hj_b = Hz(j_lgm).eval(x, t0 + dt);
537 Real H0_b = Hz(0).eval(x, t0 + dt);
538 Real res = 0.;
539 res += Hi_b * H0_b * integral(x, P(rzz(0, i), az(0), az(i)), t0, t0 + dt);
540 res -= Hi_b * integral(x, P(Hz(0), rzz(0, i), az(0), az(i)), t0, t0 + dt);
541 res -= H0_b * integral(x, P(Hz(i), rzz(0, i), az(0), az(i)), t0, t0 + dt);
542 res += integral(x, P(Hz(0), Hz(i), rzz(0, i), az(0), az(i)), t0, t0 + dt);
543 res -= Hi_b * Hj_b * integral(x, P(rzz(j_lgm, i), az(j_lgm), az(i)), t0, t0 + dt);
544 res += Hi_b * integral(x, P(Hz(j_lgm), rzz(j_lgm, i), az(j_lgm), az(i)), t0, t0 + dt);
545 res += Hj_b * integral(x, P(Hz(i), rzz(j_lgm, i), az(j_lgm), az(i)), t0, t0 + dt);
546 res -= integral(x, P(Hz(j_lgm), Hz(i), rzz(j_lgm, i), az(j_lgm), az(i)), t0, t0 + dt);
547
548 res += Hi_b * integral(x, P(rzx(i, j), sx(j), az(i)), t0, t0 + dt);
549 res -= integral(x, P(Hz(i), rzx(i, j), sx(j), az(i)), t0, t0 + dt);
550
551 res += H0_b * integral(x, P(rzs(0, k), az(0), ss(k)), t0, t0 + dt);
552 res -= integral(x, P(Hz(0), rzs(0, k), az(0), ss(k)), t0, t0 + dt);
553 res -= Hj_b * integral(x, P(rzs(j_lgm, k), az(j_lgm), ss(k)), t0, t0 + dt);
554 res += integral(x, P(Hz(j_lgm), rzs(j_lgm, k), az(j_lgm), ss(k)), t0, t0 + dt);
555
556 res += integral(x, P(rxs(j, k), sx(j), ss(k)), t0, t0 + dt);
557 return res;
558}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infz_eq_covariance()

Real infz_eq_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

infz-eq covariance

Definition at line 560 of file crossassetanalytics.cpp.

560 {
561 Size k = x.ccyIndex(x.eqbs(j)->currency());
562 Real Hk = Hz(k).eval(x, t0 + dt);
563 Real res = Hk * integral(x, P(rzy(k, i), az(k), ay(i)), t0, t0 + dt) -
564 integral(x, P(rzy(k, i), Hz(k), az(k), ay(i)), t0, t0 + dt) +
565 integral(x, P(rys(i, j), ay(i), ss(j)), t0, t0 + dt);
566 return res;
567}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infy_eq_covariance()

Real infy_eq_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

infy-eq covariance

Definition at line 569 of file crossassetanalytics.cpp.

569 {
570
571 Size k = x.ccyIndex(x.eqbs(j)->currency());
572 Real Hk = Hz(k).eval(x, t0 + dt);
573
574 Real res = 0.0;
575 if (x.modelType(CrossAssetModel::AssetType::INF, i) == CrossAssetModel::ModelType::DK) {
576 res = Hk * integral(x, P(rzy(k, i), az(k), Hy(i), ay(i)), t0, t0 + dt) -
577 integral(x, P(rzy(k, i), Hz(k), az(k), Hy(i), ay(i)), t0, t0 + dt) +
578 integral(x, P(rys(i, j), Hy(i), ay(i), ss(j)), t0, t0 + dt);
579 } else {
580
581 // i_i - index of i-th inflation component's currency.
582 Size i_i = x.ccyIndex(x.infjy(i)->currency());
583 // H_{i_i}^{z}(t_0 + dt)
584 Real Hi_i = Hz(i_i).eval(x, t0 + dt);
585 // H_{i}^{y}(t_0 + dt)
586 Real Hi = Hy(i).eval(x, t0 + dt);
587
588 res = integral(x, P(rzz(i_i, k), az(i_i), LC(Hi_i, -1.0, Hz(i_i)), az(k), LC(Hk, -1.0, Hz(k))), t0, t0 + dt);
589 res += integral(x, P(rzs(i_i, j), az(i_i), LC(Hi_i, -1.0, Hz(i_i)), ss(j)), t0, t0 + dt);
590 res -= integral(x, P(rzy(k, i, 0), ay(i), LC(Hi, -1.0, Hy(i)), az(k), LC(Hk, -1.0, Hz(k))), t0, t0 + dt);
591 res -= integral(x, P(rys(i, j, 0), ay(i), LC(Hi, -1.0, Hy(i)), ss(j)), t0, t0 + dt);
592 res += integral(x, P(rzy(k, i, 1), sy(i), az(k), LC(Hk, -1.0, Hz(k))), t0, t0 + dt);
593 res += integral(x, P(rys(i, j, 1), sy(i), ss(j)), t0, t0 + dt);
594 }
595
596 return res;
597}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crz_eq_covariance()

Real crz_eq_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

crz-eq covariance

Definition at line 599 of file crossassetanalytics.cpp.

599 {
600 Size k = x.ccyIndex(x.eqbs(j)->currency());
601 Real Hk_b = Hz(k).eval(x, t0 + dt);
602 Real res = Hk_b * integral(x, P(rzl(k, i), az(k), al(i)), t0, t0 + dt) -
603 integral(x, P(rzl(k, i), Hz(k), az(k), al(i)), t0, t0 + dt) +
604 integral(x, P(rls(i, j), al(i), ss(j)), t0, t0 + dt);
605 return res;
606}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cry_eq_covariance()

Real cry_eq_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

cry-eq covariance

Definition at line 608 of file crossassetanalytics.cpp.

608 {
609 Size k = x.ccyIndex(x.eqbs(j)->currency());
610 Real Hk_b = Hz(k).eval(x, t0 + dt);
611 Real res = Hk_b * integral(x, P(rzl(k, i), az(k), Hl(i), al(i)), t0, t0 + dt) -
612 integral(x, P(rzl(k, i), Hz(k), az(k), Hl(i), al(i)), t0, t0 + dt) +
613 integral(x, P(rls(i, j), Hl(i), al(i), ss(j)), t0, t0 + dt);
614 return res;
615}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eq_eq_covariance()

Real eq_eq_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

EQ-EQ Covariance

\begin{eqnarray} Cov \left[\Delta ln[s_i], \Delta ln[s_j] \right] &=& \rho_{z_{\phi(i)},z_{\phi(j)}} \int_{s}^{t} (H_{\phi(i)} (t) - H_{\phi(i)} (u)) (H_{\phi(j)} (t)\\ && - H_{\phi(j)} (u)) \alpha_{\phi(i)}(u) \alpha_{\phi(j)}(u) du\\ &&+ \rho_{z_{\phi(i)},s_j} \int_{s}^{t} (H_{\phi(i)} (t) - H_{\phi(i)} (u)) \alpha_{\phi(i)}(u) \sigma_{s_j}(u) du\\ &&+ \rho_{z_{\phi(j)},s_i} \int_{s}^{t} (H_{\phi(j)} (t) - H_{\phi(j)} (u)) \alpha_{\phi(j)}(u) \sigma_{s_i}(u) du\\ &&+ \rho_{s_i,s_j} \int_{s}^{t} \sigma_{s_i}(u) \sigma_{s_j}(u) du\\ \end{eqnarray}

Definition at line 617 of file crossassetanalytics.cpp.

617 {
618 Size i = x.ccyIndex(x.eqbs(k)->currency()); // ccy underlying equity k
619 Size j = x.ccyIndex(x.eqbs(l)->currency()); // ccy underlying equity l
620 Real Hi_b = Hz(i).eval(x, t0 + dt);
621 Real Hj_b = Hz(j).eval(x, t0 + dt);
622 Real res = integral(x, P(rss(k, l), ss(k), ss(l)), t0, t0 + dt);
623 res += Hj_b * integral(x, P(rzs(j, k), az(j), ss(k)), t0, t0 + dt);
624 res -= integral(x, P(Hz(j), rzs(j, k), az(j), ss(k)), t0, t0 + dt);
625 res += Hi_b * integral(x, P(rzs(i, l), az(i), ss(l)), t0, t0 + dt);
626 res -= integral(x, P(Hz(i), rzs(i, l), az(i), ss(l)), t0, t0 + dt);
627 res += Hi_b * Hj_b * integral(x, P(rzz(i, j), az(i), az(j)), t0, t0 + dt);
628 res -= Hi_b * integral(x, P(Hz(j), rzz(i, j), az(i), az(j)), t0, t0 + dt);
629 res -= Hj_b * integral(x, P(Hz(i), rzz(i, j), az(i), az(j)), t0, t0 + dt);
630 res += integral(x, P(Hz(i), Hz(j), rzz(i, j), az(i), az(j)), t0, t0 + dt);
631 return res;
632}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ aux_aux_covariance()

Real aux_aux_covariance ( const CrossAssetModel model,
const Time  t0,
const Time  dt 
)

AUX-AUX Covariance

This function evaluates the covariance term for the domestic auxiliary state variable in the bank account measure

\f{eqnarray*}{
\mathrm{Cov}[\Delta y_0, \Delta y_0] &=& \int_s^t (\alpha^z_0)^2 \,(H^z_0)^2\,du
\f}

on the time interval from \f$ s= t_0\f$ to \f$ t=t_0+\Delta t\f$.

Definition at line 634 of file crossassetanalytics.cpp.

634 {
635 Real res = integral(x, P(az(0), az(0), Hz(0), Hz(0)), t0, t0 + dt);
636 return res;
637}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ aux_ir_covariance()

Real aux_ir_covariance ( const CrossAssetModel model,
const Size  j,
const Time  t0,
const Time  dt 
)

AUX-IR Covariance

This function evaluates the covariance term for the domestic auxiliary state variable in the bank account measure with any other LGM state variable

\f{eqnarray*}{
\mathrm{Cov}[\Delta y_0, \Delta z_b] &=& \rho^{zz}_{0b} \int_s^t H^z_0\,\alpha^z_0\,\alpha^z_b\,du
\f}

on the time interval from \f$ s= t_0\f$ to \f$ t=t_0+\Delta t\f$.

Definition at line 639 of file crossassetanalytics.cpp.

639 {
640 Real res = integral(x, P(az(0), Hz(0), az(j), rzz(0, j)), t0, t0 + dt);
641 return res;
642}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ aux_fx_covariance()

Real aux_fx_covariance ( const CrossAssetModel model,
const Size  j,
const Time  t0,
const Time  dt 
)

AUX-FX Covariance

This function evaluates the covariance term

\begin{eqnarray} \mathrm{Cov} [\Delta y_0, \Delta \ln x_b]) &=& \int_s^t \left(H^z_0(t)-H^z_0\right) (\alpha^z_0)^2\,H^z_0\,du \nonumber\\ &&- \rho^{zz}_{0b}\int_s^t \alpha^z_0\,H^z_0 \left(H^z_b(t)-H^z_b\right) \alpha^z_b \,du \nonumber\\ &&+\rho^{zx}_{0b}\int_s^t \alpha^z_0\,H^z_0 \, \sigma^x_b \,du. \end{eqnarray}

on the time interval from \( s= t_0\) to \( t=t_0+\Delta t\).

Definition at line 644 of file crossassetanalytics.cpp.

644 {
645 Real res = Hz(0).eval(x, t0 + dt) * integral(x, P(az(0), az(0), Hz(0)), t0, t0 + dt) -
646 integral(x, P(Hz(0), Hz(0), az(0), az(0)), t0, t0 + dt) -
647 Hz(j + 1).eval(x, t0 + dt) * integral(x, P(az(j + 1), az(0), Hz(0), rzz(j + 1, 0)), t0, t0 + dt) +
648 integral(x, P(Hz(j + 1), az(j + 1), az(0), Hz(0), rzz(j + 1, 0)), t0, t0 + dt) +
649 integral(x, P(az(0), Hz(0), sx(j), rzx(0, j)), t0, t0 + dt);
650 return res;
651}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ com_com_covariance()

Real com_com_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

COM-COM state variable covariance, mean-reverting single-factor case

\begin{eqnarray} Cov \left[\Delta Y_i, \Delta Y_j] \right] &=& \rho_{Y_i,Y_j} \int_{s}^{t} \sigma_{Y_i}(u) \exp(\kappa_i u) \sigma_{Y_j}(u) \exp(\kappa_j u) du\\ \end{eqnarray}

Definition at line 653 of file crossassetanalytics.cpp.

653 {
654 Real res = integral(x, P(rcc(k, l), coms(k), coms(l)), t0, t0 + dt);
655 // FIXME: cover the Ornsrein-Uhlenbeck case in the integral framework
656 auto cmk = QuantLib::ext::dynamic_pointer_cast<CommoditySchwartzModel>(x.comModel(k));
657 auto cml = QuantLib::ext::dynamic_pointer_cast<CommoditySchwartzModel>(x.comModel(l));
658 QL_REQUIRE(cmk && cml, "CommoditySchwartzModel expected in com-com covariance calculation");
659 QL_REQUIRE(cmk->parametrization()->driftFreeState() == cml->parametrization()->driftFreeState(),
660 "commodity state types do not match");
661 if (!cmk->parametrization()->driftFreeState()) {
662 Real kk = cmk->parametrization()->kappaParameter();
663 Real kl = cml->parametrization()->kappaParameter();
664 Real sk = cmk->parametrization()->sigmaParameter();
665 Real sl = cml->parametrization()->sigmaParameter();
666 Real rho = x.correlation(CrossAssetModel::AssetType::COM, k, CrossAssetModel::AssetType::COM, l, 0, 0);
667 if (fabs((kk + kl) * dt) < QL_EPSILON)
668 res = rho * sk * sl * dt;
669 else
670 res = rho * sk * sl / (kk + kl) * (1.0 - std::exp(-(kk + kl) * dt));
671 }
672 return res;
673}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ir_com_covariance()

Real ir_com_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

TODO: COM covariance with all other risk factors

Definition at line 675 of file crossassetanalytics.cpp.

675 {
676 Real corr = model.correlation(CrossAssetModel::AssetType::IR, i, CrossAssetModel::AssetType::COM, j, 0, 0);
677 // FIXME
678 QL_REQUIRE(close_enough(corr, 0.0), "non-zero IR-COM correlation not implemented yet");
679 return 0.0;
680}
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fx_com_covariance()

Real fx_com_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

Definition at line 682 of file crossassetanalytics.cpp.

682 {
683 Real corr = model.correlation(CrossAssetModel::AssetType::FX, i, CrossAssetModel::AssetType::COM, j, 0, 0);
684 // FIXME
685 QL_REQUIRE(close_enough(corr, 0.0), "non-zero FX-COM correlation not implemented yet");
686 return 0.0;
687}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infz_com_covariance()

Real infz_com_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

Definition at line 689 of file crossassetanalytics.cpp.

689 {
690 Real corr = model.correlation(CrossAssetModel::AssetType::INF, i, CrossAssetModel::AssetType::COM, j, 0, 0);
691 // FIXME
692 QL_REQUIRE(close_enough(corr, 0.0), "non-zero INF-COM correlation not implemented yet");
693 return 0.0;
694}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ infy_com_covariance()

Real infy_com_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

Definition at line 696 of file crossassetanalytics.cpp.

696 {
697 Real corr = model.correlation(CrossAssetModel::AssetType::INF, i, CrossAssetModel::AssetType::COM, j, 0, 0);
698 // FIXME
699 QL_REQUIRE(close_enough(corr, 0.0), "non-zero INF-COM correlation not implemented yet");
700 return 0.0;
701}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cry_com_covariance()

Real cry_com_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

Definition at line 703 of file crossassetanalytics.cpp.

703 {
704 Real corr = model.correlation(CrossAssetModel::AssetType::CR, i, CrossAssetModel::AssetType::COM, j, 0, 0);
705 // FIXME
706 QL_REQUIRE(close_enough(corr, 0.0), "non-zero CR-COM correlation not implemented yet");
707 return 0.0;
708}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crz_com_covariance()

Real crz_com_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

Definition at line 710 of file crossassetanalytics.cpp.

710 {
711 Real corr = model.correlation(CrossAssetModel::AssetType::CR, i, CrossAssetModel::AssetType::COM, j, 0, 0);
712 // FIXME
713 QL_REQUIRE(close_enough(corr, 0.0), "non-zero CR-COM correlation not implemented yet");
714 return 0.0;
715}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eq_com_covariance()

Real eq_com_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

Definition at line 717 of file crossassetanalytics.cpp.

717 {
718 Real corr = model.correlation(CrossAssetModel::AssetType::EQ, i, CrossAssetModel::AssetType::COM, j, 0, 0);
719 // FIXME
720 QL_REQUIRE(close_enough(corr, 0.0), "non-zero EQ-COM correlation not implemented yet");
721 return 0.0;
722}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ir_crstate_covariance()

Real ir_crstate_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

IR_CrState Covariance

Definition at line 724 of file crossassetanalytics.cpp.

724 {
725 Real res = integral(x, P(az(i), rzcrs(i, j)), t0, t0 + dt);
726 return res;
727}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fx_crstate_covariance()

Real fx_crstate_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

FX_CrState Covariance

Definition at line 729 of file crossassetanalytics.cpp.

729 {
730 Real res = Hz(0).eval(x, t0 + dt) * integral(x, P(az(0), rzcrs(0, j)), t0, t0 + dt) -
731 integral(x, P(Hz(0), az(0), rzcrs(0, j)), t0, t0 + dt) -
732 Hz(i + 1).eval(x, t0 + dt) * integral(x, P(az(i + 1), rzcrs(i + 1, j)), t0, t0 + dt) +
733 integral(x, P(Hz(i + 1), az(i + 1), rzcrs(i + 1, j)), t0, t0 + dt) +
734 integral(x, P(sx(i), rxcrs(i, j)), t0, t0 + dt);
735 return res;
736}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ crstate_crstate_covariance()

Real crstate_crstate_covariance ( const CrossAssetModel model,
const Size  i,
const Size  j,
const Time  t0,
const Time  dt 
)

CrState_CrState Covariance

Definition at line 738 of file crossassetanalytics.cpp.

738 {
739 Real res = integral(x, rccrs(i, j), t0, t0 + dt);
740 return res;
741}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ integral_helper()

Real integral_helper ( const CrossAssetModel x,
const E &  e,
const Real  t 
)

generic integrand

Definition at line 212 of file crossassetanalyticsbase.hpp.

212 {
213 return e.eval(x, t);
214}

◆ integral()

Real integral ( const CrossAssetModel model,
const E &  e,
const Real  a,
const Real  b 
)

generic integral calculation

Definition at line 217 of file crossassetanalyticsbase.hpp.

217 {
218 return x.integrator()->operator()(QuantLib::ext::bind(&integral_helper<E>, x, e, QuantLib::ext::placeholders::_1), a, b);
219}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ P() [1/4]

const P2_< E1, E2 > P ( const E1 &  e1,
const E2 &  e2 
)

creator function for product expression, 2 factors

Definition at line 97 of file crossassetanalyticsbase.hpp.

97{ return P2_<E1, E2>(e1, e2); }
+ Here is the caller graph for this function:

◆ P() [2/4]

const P3_< E1, E2, E3 > P ( const E1 &  e1,
const E2 &  e2,
const E3 &  e3 
)

creator function for product expression, 3 factors

Definition at line 100 of file crossassetanalyticsbase.hpp.

100 {
101 return P3_<E1, E2, E3>(e1, e2, e3);
102}

◆ P() [3/4]

const P4_< E1, E2, E3, E4 > P ( const E1 &  e1,
const E2 &  e2,
const E3 &  e3,
const E4 &  e4 
)

creator function for product expression, 4 factors

Definition at line 106 of file crossassetanalyticsbase.hpp.

106 {
107 return P4_<E1, E2, E3, E4>(e1, e2, e3, e4);
108}

◆ P() [4/4]

const P5_< E1, E2, E3, E4, E5 > P ( const E1 &  e1,
const E2 &  e2,
const E3 &  e3,
const E4 &  e4,
const E5 &  e5 
)

creator function for product expression, 5 factors

Definition at line 112 of file crossassetanalyticsbase.hpp.

112 {
113 return P5_<E1, E2, E3, E4, E5>(e1, e2, e3, e4, e5);
114}

◆ LC() [1/4]

const LC1_< E1 > LC ( QuantLib::Real  c,
QuantLib::Real  c1,
const E1 &  e1 
)

creator function for linear combination, 1 factor

Definition at line 188 of file crossassetanalyticsbase.hpp.

188{ return LC1_<E1>(c, c1, e1); }
+ Here is the caller graph for this function:

◆ LC() [2/4]

const LC2_< E1, E2 > LC ( QuantLib::Real  c,
QuantLib::Real  c1,
const E1 &  e1,
QuantLib::Real  c2,
const E2 &  e2 
)

creator function for linear combination, 2 factors

Definition at line 192 of file crossassetanalyticsbase.hpp.

192 {
193 return LC2_<E1, E2>(c, c1, e1, c2, e2);
194}

◆ LC() [3/4]

const LC3_< E1, E2, E3 > LC ( QuantLib::Real  c,
QuantLib::Real  c1,
const E1 &  e1,
QuantLib::Real  c2,
const E2 &  e2,
QuantLib::Real  c3,
const E3 &  e3 
)

creator function for linear combination, 3 factors

Definition at line 198 of file crossassetanalyticsbase.hpp.

199 {
200 return LC3_<E1, E2, E3>(c, c1, e1, c2, e2, c3, e3);
201}

◆ LC() [4/4]

const LC4_< E1, E2, E3, E4 > LC ( QuantLib::Real  c,
QuantLib::Real  c1,
const E1 &  e1,
QuantLib::Real  c2,
const E2 &  e2,
QuantLib::Real  c3,
const E3 &  e3,
QuantLib::Real  c4,
const E4 &  e4 
)

creator function for linear combination, 4 factors

Definition at line 205 of file crossassetanalyticsbase.hpp.

206 {
207 return LC4_<E1, E2, E3, E4>(c, c1, e1, c2, e2, c3, e3, c4, e4);
208}