Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
inflationindexwrapper.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 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 inflationindexwrapper.hpp
20 \brief wrapper classes for inflation yoy and interpolation
21 \ingroup indexes
22*/
23
24#ifndef quantext_inflation_index_wrapper_hpp
25#define quantext_inflation_index_wrapper_hpp
26
27#include <ql/cashflows/cpicoupon.hpp>
28#include <ql/cashflows/inflationcouponpricer.hpp>
29#include <ql/indexes/inflationindex.hpp>
30
31namespace QuantExt {
32using namespace QuantLib;
33
34//! Wrapper that changes the interpolation of an underlying ZC inflation index
35/*! The (possible) change in the interpolation is _not_ reflected in the index class itself,
36 only the fixing methods behave consistently
37 \ingroup indexes
38 */
39class ZeroInflationIndexWrapper : public ZeroInflationIndex {
40public:
41
42 ZeroInflationIndexWrapper(const QuantLib::ext::shared_ptr<ZeroInflationIndex> source);
43
44 QL_DEPRECATED ZeroInflationIndexWrapper(const QuantLib::ext::shared_ptr<ZeroInflationIndex> source,
45 const CPI::InterpolationType interpolation);
46 /*! \warning the forecastTodaysFixing parameter (required by the Index interface) is currently ignored. */
47 Rate fixing(const Date& fixingDate, bool forecastTodaysFixing = false) const override;
48
49private:
50 Rate forecastFixing(const Date& fixingDate) const;
51 const QuantLib::ext::shared_ptr<ZeroInflationIndex> source_;
52 QL_DEPRECATED const CPI::InterpolationType interpolation_;
53};
54
55//! Wrapper that creates a yoy from a zc index
56/*! This creates a "ratio" - type YoYInflationIndex with the same family name as the zero
57 index so that historical fixings can be reused. If a yoy ts is given, this is used to
58 forecast fixings. If the ts is not given, the forecast falls back on the zero index, i.e.
59 if the zero index has a curve attached a plain yoy rate without convexity adjustment
60 is estimated using this index.
61 The interpolation follows
62 - the interpolated flag for historical fixings
63 - the interpolated flag for forecasted fixings if a yoy ts is given
64 - the underlying zero index behaviour for forecasted fixings if no yoy ts is given
65\ingroup indexes
66*/
67class YoYInflationIndexWrapper : public YoYInflationIndex {
68public:
69 YoYInflationIndexWrapper(const QuantLib::ext::shared_ptr<ZeroInflationIndex> zeroIndex, const bool interpolated,
70 const Handle<YoYInflationTermStructure>& ts = Handle<YoYInflationTermStructure>());
71 /*! \warning the forecastTodaysFixing parameter (required by the Index interface) is currently ignored. */
72 Rate fixing(const Date& fixingDate, bool forecastTodaysFixing = false) const override;
73 const QuantLib::ext::shared_ptr<ZeroInflationIndex> zeroIndex() const { return zeroIndex_; }
74
75private:
76 Rate forecastFixing(const Date& fixingDate) const;
77 const QuantLib::ext::shared_ptr<ZeroInflationIndex> zeroIndex_;
78};
79
80} // namespace QuantExt
81
82#endif
Wrapper that creates a yoy from a zc index.
const QuantLib::ext::shared_ptr< ZeroInflationIndex > zeroIndex_
Rate forecastFixing(const Date &fixingDate) const
Rate fixing(const Date &fixingDate, bool forecastTodaysFixing=false) const override
const QuantLib::ext::shared_ptr< ZeroInflationIndex > zeroIndex() const
Wrapper that changes the interpolation of an underlying ZC inflation index.
Rate forecastFixing(const Date &fixingDate) const
const QuantLib::ext::shared_ptr< ZeroInflationIndex > source_
QL_DEPRECATED const CPI::InterpolationType interpolation_
Rate fixing(const Date &fixingDate, bool forecastTodaysFixing=false) const override