Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
inflationindexobserver.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 qle/indexes/inflationindexobserver.hpp
20 \brief inflation index observer class
21 \ingroup indexes
22*/
23
24#ifndef quantext_inflation_index_observer_hpp
25#define quantext_inflation_index_observer_hpp
26
27namespace QuantExt {
28
29//! Inflation Index observer
30/*! \ingroup indexes */
32public:
33 InflationIndexObserver(const QuantLib::ext::shared_ptr<InflationIndex>& index, const Handle<Quote>& quote,
34 const Period& observationLag, const DayCounter& dayCounter = DayCounter())
35 : TermStructure(dayCounter), index_(index), quote_(quote), observationLag_(observationLag) {
36 registerWith(quote_);
37 }
38
39 void update() override { // called when the quote changes
40 setFixing();
41 }
42
43 Date maxDate() const override {
44 Date today = Settings::instance().evaluationDate();
45 return today;
46 }
47
48private:
49 void setFixing() {
50 // something like this
51 Date today = Settings::instance().evaluationDate();
52 Date fixingDate = today - observationLag_;
53 // overwrite the current fixing in the QuantLib::FixingManager
54 index_->addFixing(fixingDate, quote_->value(), true);
55 }
56
57 QuantLib::ext::shared_ptr<InflationIndex> index_;
58 Handle<Quote> quote_;
60};
61} // namespace QuantExt
62
63#endif
QuantLib::ext::shared_ptr< InflationIndex > index_
InflationIndexObserver(const QuantLib::ext::shared_ptr< InflationIndex > &index, const Handle< Quote > &quote, const Period &observationLag, const DayCounter &dayCounter=DayCounter())