Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
infdkvectorised.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
21
22namespace QuantExt {
23
24 InfDkVectorised::InfDkVectorised(const QuantLib::ext::shared_ptr<CrossAssetModel>& cam)
25 : cam_(cam) {
26
27 }
28
29 std::pair<RandomVariable, RandomVariable> InfDkVectorised::infdkI(const Size i, const Time t, const Time T,
30 const RandomVariable& z,
31 const RandomVariable& y,
32 bool indexIsInterpolated) const {
33 //
34
35 Size n_samples = z.size();
36
37 std::pair<Real, Real> Vs = cam_->infdkV(i, t, T);
38 RandomVariable V0(n_samples, Vs.first);
39 RandomVariable V_tilde(n_samples, Vs.second);
40 RandomVariable Hyt(n_samples, cam_->infdk(i)->H(t));
41 RandomVariable HyT(n_samples, cam_->infdk(i)->H(T));
42
43 // TODO account for seasonality ...
44 // compute final results depending on z and y
45 const auto& zts = cam_->infdk(i)->termStructure();
46 auto dc = cam_->irlgm1f(0)->termStructure()->dayCounter();
47 RandomVariable growth_t(n_samples, inflationGrowth(zts, t, dc, indexIsInterpolated));
48 RandomVariable growth_T(n_samples, inflationGrowth(zts, T, dc, indexIsInterpolated));
49 // Vectorize the scalars
50
51
52 RandomVariable It = growth_t * exp(Hyt * z - y - V0);
53 RandomVariable Itilde_t_T = growth_T / growth_t * exp((HyT - Hyt) * z + V_tilde);
54 // concerning interpolation there is an inaccuracy here: if the index
55 // is not interpolated, we still simulate the index value as of t
56 // (and T), although we should go back to t, T which corresponds to
57 // the last actual publication time of the index => is the approximation
58 // here in this sense good enough that we can tolerate this?
59 return std::make_pair(It, Itilde_t_T);
60 }
61
62
63} // namespace QuantExt
const QuantLib::ext::shared_ptr< CrossAssetModel > cam_
InfDkVectorised(const QuantLib::ext::shared_ptr< CrossAssetModel > &cam)
std::pair< RandomVariable, RandomVariable > infdkI(const Size i, const Time t, const Time T, const RandomVariable &z, const RandomVariable &y, bool indexIsInterpolated) const
some inflation related utilities.
CompiledFormula exp(CompiledFormula x)
Real inflationGrowth(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, Size index, Time S, Time T, Real irState, Real rrState, bool indexIsInterpolated)