Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
yoyinflationmodeltermstructure.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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 qle/models/yoyinflationmodeltermstructure.hpp
20 \brief year-on-year inflation term structure implied by a cross asset model
21 \ingroup models
22*/
23
24#ifndef quantext_yoy_inflation_model_term_structure_hpp
25#define quantext_yoy_inflation_model_term_structure_hpp
26
28#include <ql/termstructures/inflationtermstructure.hpp>
29
30namespace QuantExt {
31
32/*! Base class for cross asset model implied year on year inflation term structures.
33
34 The termstructure has the reference date of the model's term structure at construction, but you can vary this as
35 well as the state. Note that this term structure does not implement the full YoYInflationTermStructure interface.
36 It is questionable whether it should derive from YoYInflationTermStructure at all.
37
38 \ingroup models
39*/
40
41class YoYInflationModelTermStructure : public QuantLib::YoYInflationTermStructure {
42public:
43 /*! Constructor taking the cross asset model, \p model, and the index of the relevant inflation component within
44 the model, \p index.
45 */
46 YoYInflationModelTermStructure(const QuantLib::ext::shared_ptr<CrossAssetModel>& model, QuantLib::Size index, bool indexIsInterpolated);
47
48 //! \name Observer interface
49 //@{
50 void update() override;
51 //@}
52
53 //! \name TermStructure interface
54 //@{
55 QuantLib::Date maxDate() const override;
56 QuantLib::Time maxTime() const override;
57 const QuantLib::Date& referenceDate() const override;
58 //@}
59
60 //! \name InflationTermStructure interface
61 //@{
62 QuantLib::Date baseDate() const override;
63 //@}
64
65 //! Set the reference date
66 virtual void referenceDate(const QuantLib::Date& d);
67
68 //! Set the current state variables
69 void state(const QuantLib::Array& s);
70
71 //! Set the current state and move the reference date to date \p d
72 void move(const QuantLib::Date& d, const QuantLib::Array& s);
73
74 /*! Hides the YoYInflationTermStructure::yoyRate method. The parameters \p forceLinearInterpolation and
75 \p extrapolate are ignored.
76 */
77 QuantLib::Real yoyRate(const QuantLib::Date& d, const QuantLib::Period& obsLag = -1 * QuantLib::Days,
78 bool forceLinearInterpolation = false, bool extrapolate = false) const;
79
80 /*! Return the year-on-year rates for the maturities associated with \p dates. If an \p obsLag is explicitly
81 provided and not set to <code>-1 * QuantLib::Days</code>, it is used as the observation lag. Otherwise, the
82 term structure's observation lag is used.
83 */
84 virtual std::map<QuantLib::Date, QuantLib::Real> yoyRates(const std::vector<QuantLib::Date>& dates,
85 const QuantLib::Period& obsLag = -1 * QuantLib::Days) const = 0;
86
87protected:
88 QuantLib::ext::shared_ptr<CrossAssetModel> model_;
89 QuantLib::Size index_;
91 // Hides referenceDate_ in TermStructure.
92 QuantLib::Date referenceDate_;
93 QuantLib::Time relativeTime_;
94 QuantLib::Array state_;
95
96 //! \name YoYInflationTermStructure interface
97 //@{
98 //! This cannot be called. The implementation is set to throw an exception.
99 QuantLib::Real yoyRateImpl(QuantLib::Time t) const override;
100 //@}
101
102 /*! Override this method to perform checks on the state variable array when the \c state and \c move methods are
103 called.
104 */
105 virtual void checkState() const {}
106};
107
108}
109
110#endif
QuantLib::Real yoyRateImpl(QuantLib::Time t) const override
This cannot be called. The implementation is set to throw an exception.
virtual void referenceDate(const QuantLib::Date &d)
Set the reference date.
virtual std::map< QuantLib::Date, QuantLib::Real > yoyRates(const std::vector< QuantLib::Date > &dates, const QuantLib::Period &obsLag=-1 *QuantLib::Days) const =0
const QuantLib::Date & referenceDate() const override
void state(const QuantLib::Array &s)
Set the current state variables.
void move(const QuantLib::Date &d, const QuantLib::Array &s)
Set the current state and move the reference date to date d.
QuantLib::ext::shared_ptr< CrossAssetModel > model_
QuantLib::Real yoyRate(const QuantLib::Date &d, const QuantLib::Period &obsLag=-1 *QuantLib::Days, bool forceLinearInterpolation=false, bool extrapolate=false) const
cross asset model