Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
yoyinflationmodeltermstructure.cpp
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
20
21using QuantLib::Array;
22using QuantLib::Date;
23using QuantLib::Real;
24using QuantLib::Size;
25using QuantLib::Time;
26
27namespace QuantExt {
28
29YoYInflationModelTermStructure::YoYInflationModelTermStructure(const QuantLib::ext::shared_ptr<CrossAssetModel>& model,
30 Size index, bool indexIsInterpolated)
31 : YoYInflationTermStructure(
32 inflationTermStructure(model, index)->dayCounter(), inflationTermStructure(model, index)->baseRate(),
33 inflationTermStructure(model, index)->observationLag(), inflationTermStructure(model, index)->frequency(),
34 indexIsInterpolated), // the QL constructor is not up to date, but the last argument here will go soon
35 model_(model), index_(index), indexIsInterpolated_(indexIsInterpolated),
36 referenceDate_(inflationTermStructure(model_, index_)->referenceDate()), relativeTime_(0.0) {
37 registerWith(model_);
38 update();
39}
40
42 notifyObservers();
43}
44
46 // we don't care. Let the underlying classes throw exceptions if applicable
47 return Date::maxDate();
48}
49
51 // see maxDate
52 return QL_MAX_REAL;
53}
54
56 return referenceDate_;
57}
58
61 return referenceDate_ - observationLag_;
62 } else {
63 return inflationPeriod(referenceDate_ - observationLag_, frequency()).first;
64 }
65}
66
70 update();
71}
72
74 state_ = s;
75 checkState();
76 notifyObservers();
77}
78
79void YoYInflationModelTermStructure::move(const Date& d, const Array& s) {
80 state(s);
82}
83
84Real YoYInflationModelTermStructure::yoyRate(const Date& d, const Period& obsLag, bool forceLinearInterpolation,
85 bool extrapolate) const {
86 return yoyRates({ d }, obsLag).at(d);
87}
88
90 QL_FAIL("YoYInflationModelTermStructure::yoyRateImpl cannot be called.");
91}
92
93}
QuantLib::Real yoyRateImpl(QuantLib::Time t) const override
This cannot be called. The implementation is set to throw an exception.
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_
YoYInflationModelTermStructure(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, QuantLib::Size index, bool indexIsInterpolated)
QuantLib::Real yoyRate(const QuantLib::Date &d, const QuantLib::Period &obsLag=-1 *QuantLib::Days, bool forceLinearInterpolation=false, bool extrapolate=false) const
Handle< ZeroInflationTermStructure > inflationTermStructure(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, Size index)
year-on-year inflation term structure implied by a cross asset model