Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
infjybuilder.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 ored/model/inflation/infjybuilder.hpp
20 \brief Builder for a Jarrow Yildrim inflation model component
21 \ingroup models
22*/
23
24#pragma once
25
31
32namespace ore {
33namespace data {
34
35/*! Builder for a Jarrow Yildrim inflation model component
36
37 This class is a utility to turn a Jarrow Yildrim inflation model component description into an inflation model
38 parameterization which can be used to instantiate a CrossAssetModel.
39
40 \ingroup models
41*/
43public:
44 /*! Constructor
45 \param market Market object
46 \param data Jarrow Yildrim inflation model description
47 \param configuration Market configuration to use
48 \param referenceCalibrationGrid The reference calibration grid
49 */
50 InfJyBuilder(const QuantLib::ext::shared_ptr<Market>& market, const QuantLib::ext::shared_ptr<InfJyData>& data,
51 const std::string& configuration = Market::defaultConfiguration,
52 const std::string& referenceCalibrationGrid = "", const bool donCalibrate = false);
53
54 using Helpers = std::vector<QuantLib::ext::shared_ptr<QuantLib::CalibrationHelper>>;
55
56 //! \name Inspectors
57 //@{
58 std::string inflationIndex() const;
59 QuantLib::ext::shared_ptr<QuantExt::InfJyParameterization> parameterization() const;
60 Helpers realRateBasket() const;
61 Helpers indexBasket() const;
62 //@}
63
64 //! \name ModelBuilder interface
65 //@{
66 void forceRecalculate() override;
67 bool requiresRecalibration() const override;
68 //@}
69
70 void setCalibrationDone() const;
71
72private:
73 QuantLib::ext::shared_ptr<Market> market_;
74 std::string configuration_;
75 QuantLib::ext::shared_ptr<InfJyData> data_;
78
79 QuantLib::ext::shared_ptr<QuantExt::InfJyParameterization> parameterization_;
80 QuantLib::ext::shared_ptr<QuantExt::MarketObserver> marketObserver_;
81
82 // The rate curve to use
83 Handle<YieldTermStructure> rateCurve_;
84
85 // We always need a ZeroInflationIndex to build the JY model.
86 QuantLib::ext::shared_ptr<QuantLib::ZeroInflationIndex> zeroInflationIndex_;
87
88 // We may need these depending on the calibration instrument types.
89 QuantLib::Handle<QuantLib::CPIVolatilitySurface> cpiVolatility_;
90 QuantLib::ext::shared_ptr<QuantLib::YoYInflationIndex> yoyInflationIndex_;
91 QuantLib::Handle<QuantLib::YoYOptionletVolatilitySurface> yoyVolatility_;
92
93 // Helper flag used in the forceRecalculate() method.
94 bool forceCalibration_ = false;
95
96 /*! Calibration instruments to use for calibrating the real rate portion of the JY model. The basket is
97 empty if we are not calibrating the real rate portion of the JY model. Depending on the calibration
98 configuration, either the real rate reversion parameter or the real rate volatility parameter will be
99 adjusted in order to match these instruments.
100 */
102 mutable std::vector<bool> rrInstActive_;
103 mutable QuantLib::Array rrInstExpiries_;
104
105 /*! Calibration instruments to use for calibrating the inflation index portion of the JY model. The basket is
106 empty if we are not calibrating the inflation index portion of the JY model.
107 */
109 mutable std::vector<bool> indexInstActive_;
110 mutable QuantLib::Array indexInstExpiries_;
111
112 //! Cache the prices of all of the active calibration helper instruments.
113 mutable std::vector<QuantLib::Real> priceCache_;
114
115 //! \name LazyObject interface
116 //@{
117 void performCalculations() const override;
118 //@}
119
120 //! Build any calibration baskets requested by the configuration i.e. via the \c data_ member.
121 void buildCalibrationBaskets() const;
122
123 //! Build the calibration basket.
124 Helpers buildCalibrationBasket(const CalibrationBasket& cb, std::vector<bool>& active,
125 QuantLib::Array& expiries, bool forRealRateReversion = false) const;
126
127 //! Build a CPI cap floor calibration basket.
128 Helpers buildCpiCapFloorBasket(const CalibrationBasket& cb, std::vector<bool>& active,
129 QuantLib::Array& expiries) const;
130
131 //! Build a YoY cap floor calibration basket.
132 Helpers buildYoYCapFloorBasket(const CalibrationBasket& cb, std::vector<bool>& active,
133 QuantLib::Array& expiries) const;
134
135 //! Build a YoY swap calibration basket.
136 Helpers buildYoYSwapBasket(const CalibrationBasket& cb, std::vector<bool>& active,
137 QuantLib::Array& expiries, bool forRealRateReversion = false) const;
138
139 //! Find calibration basket with parameter value equal to \p parameter
140 const CalibrationBasket& calibrationBasket(const std::string& parameter) const;
141
142 //! Create the real rate parameterisation.
143 QuantLib::ext::shared_ptr<QuantExt::Lgm1fParametrization<ZeroInflationTermStructure>> createRealRateParam() const;
144
145 //! Create the inflation index parameterisation.
146 QuantLib::ext::shared_ptr<QuantExt::FxBsParametrization> createIndexParam() const;
147
148 /*! Perform checks and possibly adjust the \p times and \p values array depending on calibration configuration.
149 */
150 void setupParams(const ModelParameter& param, QuantLib::Array& times, QuantLib::Array& values,
151 const QuantLib::Array& expiries, const std::string& paramName) const;
152
153 //! Create the reference calibration dates.
154 std::vector<QuantLib::Date> referenceCalibrationDates() const;
155
156 //! Attempt to initialise market data members that may be needed for building calibration instruments.
157 void initialiseMarket();
158
159 /*! Returns \c true if the market value of any of the calibration helpers has changed. If \p updateCache is
160 \c true, the cached prices are updated if they have changed.
161 */
162 bool pricesChanged(bool updateCache) const;
163
164 //! Return the market value of the given calibration helper
165 QuantLib::Real marketPrice(const QuantLib::ext::shared_ptr<QuantLib::CalibrationHelper>& helper) const;
166};
167
168}
169}
Helpers buildCalibrationBasket(const CalibrationBasket &cb, std::vector< bool > &active, QuantLib::Array &expiries, bool forRealRateReversion=false) const
Build the calibration basket.
QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex > zeroInflationIndex_
std::vector< QuantLib::ext::shared_ptr< QuantLib::CalibrationHelper > > Helpers
std::string referenceCalibrationGrid_
void forceRecalculate() override
QuantLib::ext::shared_ptr< Market > market_
void performCalculations() const override
Helpers indexBasket() const
Helpers buildYoYSwapBasket(const CalibrationBasket &cb, std::vector< bool > &active, QuantLib::Array &expiries, bool forRealRateReversion=false) const
Build a YoY swap calibration basket.
QuantLib::ext::shared_ptr< QuantExt::MarketObserver > marketObserver_
QuantLib::Handle< QuantLib::YoYOptionletVolatilitySurface > yoyVolatility_
const CalibrationBasket & calibrationBasket(const std::string &parameter) const
Find calibration basket with parameter value equal to parameter.
void setCalibrationDone() const
Helpers buildYoYCapFloorBasket(const CalibrationBasket &cb, std::vector< bool > &active, QuantLib::Array &expiries) const
Build a YoY cap floor calibration basket.
void initialiseMarket()
Attempt to initialise market data members that may be needed for building calibration instruments.
QuantLib::ext::shared_ptr< QuantLib::YoYInflationIndex > yoyInflationIndex_
Helpers buildCpiCapFloorBasket(const CalibrationBasket &cb, std::vector< bool > &active, QuantLib::Array &expiries) const
Build a CPI cap floor calibration basket.
QuantLib::ext::shared_ptr< InfJyData > data_
QuantLib::ext::shared_ptr< QuantExt::InfJyParameterization > parameterization() const
bool requiresRecalibration() const override
QuantLib::ext::shared_ptr< QuantExt::Lgm1fParametrization< ZeroInflationTermStructure > > createRealRateParam() const
Create the real rate parameterisation.
Handle< YieldTermStructure > rateCurve_
void buildCalibrationBaskets() const
Build any calibration baskets requested by the configuration i.e. via the data_ member.
bool pricesChanged(bool updateCache) const
void setupParams(const ModelParameter &param, QuantLib::Array &times, QuantLib::Array &values, const QuantLib::Array &expiries, const std::string &paramName) const
QuantLib::Array indexInstExpiries_
std::vector< bool > rrInstActive_
QuantLib::ext::shared_ptr< QuantExt::FxBsParametrization > createIndexParam() const
Create the inflation index parameterisation.
std::vector< QuantLib::Date > referenceCalibrationDates() const
Create the reference calibration dates.
std::string inflationIndex() const
QuantLib::ext::shared_ptr< QuantExt::InfJyParameterization > parameterization_
QuantLib::Array rrInstExpiries_
std::vector< QuantLib::Real > priceCache_
Cache the prices of all of the active calibration helper instruments.
Helpers realRateBasket() const
QuantLib::Real marketPrice(const QuantLib::ext::shared_ptr< QuantLib::CalibrationHelper > &helper) const
Return the market value of the given calibration helper.
std::vector< bool > indexInstActive_
QuantLib::Handle< QuantLib::CPIVolatilitySurface > cpiVolatility_
static const string defaultConfiguration
Default configuration label.
Definition: market.hpp:296
Jarrow Yildirim inflation model component data for the cross asset model.
@ data
Definition: log.hpp:77
Base Market class.
Serializable Credit Default Swap.
Definition: namespaces.docs:23
QuantLib::BootstrapHelper< QuantLib::OptionletVolatilityStructure > helper