Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
gaussian1dcrossassetadaptor.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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
19/*! \file gaussian1dcrossassetadaptor.hpp
20 \brief adaptor class that extracts one irlgm1f component
21 \ingroup models
22*/
23
24#ifndef quantext_gaussian1d_crossasset_adaptor_hpp
25#define quantext_gaussian1d_crossasset_adaptor_hpp
26
27#include <ql/models/shortrate/onefactormodels/gaussian1dmodel.hpp>
30
31namespace QuantExt {
32
33//! Gaussian 1d Cross Asset adaptor
34/*! \ingroup models
35 */
37public:
38 Gaussian1dCrossAssetAdaptor(const QuantLib::ext::shared_ptr<LinearGaussMarkovModel>& model);
39 Gaussian1dCrossAssetAdaptor(const Size ccy, const QuantLib::ext::shared_ptr<CrossAssetModel>& model);
40
41private:
42 /*! Gaussian1dModel interface */
43 Real numeraireImpl(const Time t, const Real y, const Handle<YieldTermStructure>& yts) const override;
44 Real zerobondImpl(const Time T, const Time t, const Real y, const Handle<YieldTermStructure>& yts) const override;
45
46 // add this when the preferdDeflatedZerobond is available in QuantLib
47
48 // const Real
49 // deflatedZerobondImpl(const Time T, const Time t, const Real y,
50 // const Handle<YieldTermStructure> &yts,
51 // const Handle<YieldTermStructure> &ytsNumeraire,
52 // const bool adjusted) const;
53
54 // add this when available in QuantLib
55
56 // bool preferDeflatedZerobond() const { return true; }
57
58 /* helper functions */
59 void initialize();
60
61 /* members */
62 const QuantLib::ext::shared_ptr<LinearGaussMarkovModel> x_;
63};
64
65// inline
66
67inline Real Gaussian1dCrossAssetAdaptor::numeraireImpl(const Time t, const Real y,
68 const Handle<YieldTermStructure>& yts) const {
69 Real d = yts.empty() ? 1.0 : x_->parametrization()->termStructure()->discount(t) / yts->discount(t);
70 Real x = y * std::sqrt(x_->parametrization()->zeta(t));
71 return d * x_->numeraire(t, x);
72}
73
74inline Real Gaussian1dCrossAssetAdaptor::zerobondImpl(const Time T, const Time t, const Real y,
75 const Handle<YieldTermStructure>& yts) const {
76 Real d = yts.empty()
77 ? 1.0
78 : x_->parametrization()->termStructure()->discount(t) /
79 x_->parametrization()->termStructure()->discount(T) * yts->discount(T) / yts->discount(t);
80 Real x = y * std::sqrt(x_->parametrization()->zeta(t));
81 return d * x_->discountBond(t, T, x);
82}
83
84// see above in the declaration
85
86// inline const Real
87// Gaussian1dCrossAssetAdaptor::deflatedZerobondImpl(const Time T, const Time t,
88// const Real y,
89// const Handle<YieldTermStructure> &yts,
90// const Handle<YieldTermStructure> &,
91// const bool) const {
92// Real d = yts.empty()
93// ? 1.0
94// : x_->parametrization()->termStructure()->discount(t) /
95// x_->parametrization()->termStructure()->discount(T) *
96// yts->discount(T) / yts->discount(t);
97// Real x = y * std::sqrt(x_->parametrization()->zeta(t));
98// return d * x_->reducedDiscountBond(t, T, x);
99// }
100
101} // namespace QuantExt
102
103#endif
Real zerobondImpl(const Time T, const Time t, const Real y, const Handle< YieldTermStructure > &yts) const override
const QuantLib::ext::shared_ptr< LinearGaussMarkovModel > x_
Real numeraireImpl(const Time t, const Real y, const Handle< YieldTermStructure > &yts) const override
cross asset model
adaptor class that extracts one irlgm1f component