Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
zeroinflationmodeltermstructure.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
29QL_DEPRECATED_DISABLE_WARNING
30ZeroInflationModelTermStructure::ZeroInflationModelTermStructure(const QuantLib::ext::shared_ptr<CrossAssetModel>& model,
31 Size index)
32 : ZeroInflationModelTermStructure(model, index, false) {}
33
34
35ZeroInflationModelTermStructure::ZeroInflationModelTermStructure(const QuantLib::ext::shared_ptr<CrossAssetModel>& model,
36 Size index, bool indexIsInterpolated)
37 : ZeroInflationTermStructure(
38 inflationTermStructure(model, index)->dayCounter(), inflationTermStructure(model, index)->baseRate(),
39 inflationTermStructure(model, index)->observationLag(), inflationTermStructure(model, index)->frequency()),
40 model_(model), index_(index), indexIsInterpolated_(indexIsInterpolated),
41 referenceDate_(inflationTermStructure(model_, index_)->referenceDate()), relativeTime_(0.0) {
42 registerWith(model_);
43 update();
44}
45QL_DEPRECATED_ENABLE_WARNING
46
47void ZeroInflationModelTermStructure::update() {
48 notifyObservers();
49}
50
51Date ZeroInflationModelTermStructure::maxDate() const {
52 // we don't care. Let the underlying classes throw exceptions if applicable
53 return Date::maxDate();
54}
55
56Time ZeroInflationModelTermStructure::maxTime() const {
57 // see maxDate
58 return QL_MAX_REAL;
59}
60
61const Date& ZeroInflationModelTermStructure::referenceDate() const {
62 return referenceDate_;
63}
64
65Date ZeroInflationModelTermStructure::baseDate() const {
66 QL_DEPRECATED_DISABLE_WARNING
67 if (indexIsInterpolated_) {
68 return referenceDate_ - observationLag_;
69 } else {
70 return inflationPeriod(referenceDate_ - observationLag_, frequency()).first;
71 }
72 QL_DEPRECATED_ENABLE_WARNING
73}
74
75void ZeroInflationModelTermStructure::referenceDate(const Date& d) {
76 referenceDate_ = d;
77 relativeTime_ = dayCounter().yearFraction(inflationTermStructure(model_, index_)->referenceDate(), referenceDate_);
78 update();
79}
80
81void ZeroInflationModelTermStructure::state(const Array& s) {
82 state_ = s;
83 checkState();
84 notifyObservers();
85}
86
87void ZeroInflationModelTermStructure::move(const Date& d, const Array& s) {
88 state(s);
89 referenceDate(d);
90}
91
92}
ZeroInflationModelTermStructure(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, QuantLib::Size index)
Handle< ZeroInflationTermStructure > inflationTermStructure(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, Size index)
zero inflation term structure implied by a cross asset model