From 03a5ea07f90a22d695b77d5a08a1561a3ae0a68c Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Fri, 4 Oct 2024 10:34:48 +0200 Subject: [PATCH 01/10] QPR-12849 avoid copying the time series of fixings --- ql/index.hpp | 3 +-- ql/indexes/indexmanager.cpp | 4 ++++ ql/indexes/indexmanager.hpp | 2 ++ ql/utilities/observablevalue.hpp | 6 ++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ql/index.hpp b/ql/index.hpp index 6419700ff64..57da0ff14e4 100644 --- a/ql/index.hpp +++ b/ql/index.hpp @@ -101,7 +101,7 @@ namespace QuantLib { bool forceOverwrite = false) { checkNativeFixingsAllowed(); std::string tag = name(); - TimeSeries h = IndexManager::instance().getHistory(tag); + TimeSeries& h = IndexManager::instance().getHistoryRef(tag); bool noInvalidFixing = true, noDuplicatedFixing = true; Date invalidDate, duplicatedDate; Real nullValue = Null(); @@ -128,7 +128,6 @@ namespace QuantLib { invalidValue = *(vBegin++); } } - IndexManager::instance().setHistory(tag, h); QL_REQUIRE(noInvalidFixing, "At least one invalid fixing provided: " << invalidDate.weekday() << " " << invalidDate << ", " << invalidValue); diff --git a/ql/indexes/indexmanager.cpp b/ql/indexes/indexmanager.cpp index 19f4c4f77de..39bb14d0b26 100644 --- a/ql/indexes/indexmanager.cpp +++ b/ql/indexes/indexmanager.cpp @@ -29,6 +29,10 @@ namespace QuantLib { return data_[name].value(); } + TimeSeries& IndexManager::getHistoryRef(const std::string& name) { + return data_[name].ref(); + } + void IndexManager::setHistory(const std::string& name, TimeSeries history) { data_[name] = std::move(history); } diff --git a/ql/indexes/indexmanager.hpp b/ql/indexes/indexmanager.hpp index 0115aabfe93..2e18fbc3ed6 100644 --- a/ql/indexes/indexmanager.hpp +++ b/ql/indexes/indexmanager.hpp @@ -45,6 +45,8 @@ namespace QuantLib { bool hasHistory(const std::string& name) const; //! returns the (possibly empty) history of the index fixings const TimeSeries& getHistory(const std::string& name) const; + //! returns a ref to the (possibly empty) history of the index fixings + TimeSeries& getHistoryRef(const std::string& name); //! stores the historical fixings of the index void setHistory(const std::string& name, TimeSeries history); //! observer notifying of changes in the index fixings diff --git a/ql/utilities/observablevalue.hpp b/ql/utilities/observablevalue.hpp index aa54ce7846f..a35fa972bb7 100644 --- a/ql/utilities/observablevalue.hpp +++ b/ql/utilities/observablevalue.hpp @@ -57,6 +57,8 @@ namespace QuantLib { operator ext::shared_ptr() const; //! explicit inspector const T& value() const; + //! explicit reference + T& ref(); private: T value_; ext::shared_ptr observable_; @@ -118,6 +120,10 @@ namespace QuantLib { return value_; } + template + T& ObservableValue::ref() { + return value_; + } } #endif From 256d272ff73081b35165fa3d650cd971a194e63e Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Fri, 4 Oct 2024 12:51:37 +0200 Subject: [PATCH 02/10] QPR-12849 fix observability --- ql/index.hpp | 5 +++-- ql/indexes/indexmanager.cpp | 5 +++-- ql/indexes/indexmanager.hpp | 4 ++-- ql/utilities/observablevalue.hpp | 7 +++++++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ql/index.hpp b/ql/index.hpp index 57da0ff14e4..d7b12adae49 100644 --- a/ql/index.hpp +++ b/ql/index.hpp @@ -100,8 +100,8 @@ namespace QuantLib { ValueIterator vBegin, bool forceOverwrite = false) { checkNativeFixingsAllowed(); - std::string tag = name(); - TimeSeries& h = IndexManager::instance().getHistoryRef(tag); + auto& obsValue = IndexManager::instance().getHistoryObservableValueRef(name()); + auto& h = obsValue.ref(); bool noInvalidFixing = true, noDuplicatedFixing = true; Date invalidDate, duplicatedDate; Real nullValue = Null(); @@ -128,6 +128,7 @@ namespace QuantLib { invalidValue = *(vBegin++); } } + obsValue.notifyObservers(); QL_REQUIRE(noInvalidFixing, "At least one invalid fixing provided: " << invalidDate.weekday() << " " << invalidDate << ", " << invalidValue); diff --git a/ql/indexes/indexmanager.cpp b/ql/indexes/indexmanager.cpp index 39bb14d0b26..2397c4fafb1 100644 --- a/ql/indexes/indexmanager.cpp +++ b/ql/indexes/indexmanager.cpp @@ -29,8 +29,9 @@ namespace QuantLib { return data_[name].value(); } - TimeSeries& IndexManager::getHistoryRef(const std::string& name) { - return data_[name].ref(); + ObservableValue>& + IndexManager::getHistoryObservableValueRef(const std::string& name) { + return data_[name]; } void IndexManager::setHistory(const std::string& name, TimeSeries history) { diff --git a/ql/indexes/indexmanager.hpp b/ql/indexes/indexmanager.hpp index 2e18fbc3ed6..2310e484aab 100644 --- a/ql/indexes/indexmanager.hpp +++ b/ql/indexes/indexmanager.hpp @@ -45,8 +45,8 @@ namespace QuantLib { bool hasHistory(const std::string& name) const; //! returns the (possibly empty) history of the index fixings const TimeSeries& getHistory(const std::string& name) const; - //! returns a ref to the (possibly empty) history of the index fixings - TimeSeries& getHistoryRef(const std::string& name); + //! returns the observable value for a history + ObservableValue>& getHistoryObservableValueRef(const std::string& name); //! stores the historical fixings of the index void setHistory(const std::string& name, TimeSeries history); //! observer notifying of changes in the index fixings diff --git a/ql/utilities/observablevalue.hpp b/ql/utilities/observablevalue.hpp index a35fa972bb7..cdd7b8d23b0 100644 --- a/ql/utilities/observablevalue.hpp +++ b/ql/utilities/observablevalue.hpp @@ -59,6 +59,8 @@ namespace QuantLib { const T& value() const; //! explicit reference T& ref(); + //! explicit notification of observers + void notifyObservers() const; private: T value_; ext::shared_ptr observable_; @@ -124,6 +126,11 @@ namespace QuantLib { T& ObservableValue::ref() { return value_; } + + template + void ObservableValue::notifyObservers() const { + observable_->notifyObservers(); + } } #endif From 347c2c580f105525eb9340f675eb317344468713 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Fri, 4 Oct 2024 17:17:25 +0200 Subject: [PATCH 03/10] QPR-12849 clean up --- ql/index.cpp | 5 ++-- ql/index.hpp | 42 +++++++-------------------------- ql/indexes/indexmanager.cpp | 21 +++++++++++------ ql/indexes/indexmanager.hpp | 46 +++++++++++++++++++++++++++++++++---- 4 files changed, 66 insertions(+), 48 deletions(-) diff --git a/ql/index.cpp b/ql/index.cpp index c5bb900a15e..31ae9d280be 100644 --- a/ql/index.cpp +++ b/ql/index.cpp @@ -25,9 +25,8 @@ namespace QuantLib { Real fixing, bool forceOverwrite) { checkNativeFixingsAllowed(); - addFixings(&fixingDate, (&fixingDate)+1, - &fixing, - forceOverwrite); + std::cout << "adding fixing " << fixingDate << " " << name() << " " << std::endl; + addFixings(&fixingDate, (&fixingDate) + 1, &fixing, forceOverwrite); } void Index::addFixings(const TimeSeries& t, diff --git a/ql/index.hpp b/ql/index.hpp index d7b12adae49..3604152f80e 100644 --- a/ql/index.hpp +++ b/ql/index.hpp @@ -100,42 +100,16 @@ namespace QuantLib { ValueIterator vBegin, bool forceOverwrite = false) { checkNativeFixingsAllowed(); - auto& obsValue = IndexManager::instance().getHistoryObservableValueRef(name()); - auto& h = obsValue.ref(); - bool noInvalidFixing = true, noDuplicatedFixing = true; - Date invalidDate, duplicatedDate; - Real nullValue = Null(); - Real invalidValue = Null(); - Real duplicatedValue = Null(); + DateIterator dBegin2 = dBegin, dEnd2 = dEnd; + ValueIterator vBegin2 = vBegin; while (dBegin != dEnd) { - bool validFixing = isValidFixingDate(*dBegin); - Real currentValue = h[*dBegin]; - bool missingFixing = forceOverwrite || currentValue == nullValue; - if (validFixing) { - if (missingFixing) - h[*(dBegin++)] = *(vBegin++); - else if (close(currentValue, *(vBegin))) { - ++dBegin; - ++vBegin; - } else { - noDuplicatedFixing = false; - duplicatedDate = *(dBegin++); - duplicatedValue = *(vBegin++); - } - } else { - noInvalidFixing = false; - invalidDate = *(dBegin++); - invalidValue = *(vBegin++); - } + QL_REQUIRE(isValidFixingDate(*dBegin), + "At least on invalid fixing provided: " << dBegin->weekday() << *dBegin + << ", " << *vBegin); + ++dBegin; + ++vBegin; } - obsValue.notifyObservers(); - QL_REQUIRE(noInvalidFixing, "At least one invalid fixing provided: " - << invalidDate.weekday() << " " << invalidDate << ", " - << invalidValue); - QL_REQUIRE(noDuplicatedFixing, "At least one duplicated fixing provided: " - << duplicatedDate << ", " << duplicatedValue - << " while " << h[duplicatedDate] - << " value is already present"); + IndexManager::instance().addFixings(name(), dBegin2, dEnd2, vBegin2, forceOverwrite); } //! clears all stored historical fixings void clearFixings(); diff --git a/ql/indexes/indexmanager.cpp b/ql/indexes/indexmanager.cpp index 2397c4fafb1..28a11127c43 100644 --- a/ql/indexes/indexmanager.cpp +++ b/ql/indexes/indexmanager.cpp @@ -26,11 +26,6 @@ namespace QuantLib { } const TimeSeries& IndexManager::getHistory(const std::string& name) const { - return data_[name].value(); - } - - ObservableValue>& - IndexManager::getHistoryObservableValueRef(const std::string& name) { return data_[name]; } @@ -38,8 +33,20 @@ namespace QuantLib { data_[name] = std::move(history); } + void IndexManager::addFixing(const std::string& name, + const Date& fixingDate, + Real fixing, + bool forceOverwrite) { + addFixings(name, &fixingDate, (&fixingDate) + 1, &fixing, forceOverwrite); + } + ext::shared_ptr IndexManager::notifier(const std::string& name) const { - return data_[name]; + auto n = notifiers_.find(name); + if(n != notifiers_.end()) + return n->second; + auto o = ext::make_shared(); + notifiers_[name] = o; + return o; } std::vector IndexManager::histories() const { @@ -57,7 +64,7 @@ namespace QuantLib { bool IndexManager::hasHistoricalFixing(const std::string& name, const Date& fixingDate) const { auto const& indexIter = data_.find(name); return (indexIter != data_.end()) && - ((*indexIter).second.value()[fixingDate] != Null()); + ((*indexIter).second[fixingDate] != Null()); } } diff --git a/ql/indexes/indexmanager.hpp b/ql/indexes/indexmanager.hpp index 2310e484aab..6705650f0db 100644 --- a/ql/indexes/indexmanager.hpp +++ b/ql/indexes/indexmanager.hpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -45,11 +46,47 @@ namespace QuantLib { bool hasHistory(const std::string& name) const; //! returns the (possibly empty) history of the index fixings const TimeSeries& getHistory(const std::string& name) const; - //! returns the observable value for a history - ObservableValue>& getHistoryObservableValueRef(const std::string& name); //! stores the historical fixings of the index void setHistory(const std::string& name, TimeSeries history); - //! observer notifying of changes in the index fixings + //! add a fixing + void addFixing(const std::string& name, + const Date& fixingDate, + Real fixing, + bool forceOverwrite = false); + //! add fixings + template + void addFixings(const std::string& name, + DateIterator dBegin, + DateIterator dEnd, + ValueIterator vBegin, + bool forceOverwrite = false) { + auto& h = data_[name]; + bool noDuplicatedFixing = true; + Date duplicatedDate; + Real nullValue = Null(); + Real invalidValue = Null(); + Real duplicatedValue = Null(); + while (dBegin != dEnd) { + Real currentValue = h[*dBegin]; + bool missingFixing = forceOverwrite || currentValue == nullValue; + if (missingFixing) + h[*(dBegin++)] = *(vBegin++); + else if (close(currentValue, *(vBegin))) { + ++dBegin; + ++vBegin; + } else { + noDuplicatedFixing = false; + duplicatedDate = *(dBegin++); + duplicatedValue = *(vBegin++); + } + } + notifier(name)->notifyObservers(); + QL_REQUIRE(noDuplicatedFixing, "At least one duplicated fixing provided: " + << duplicatedDate << ", " << duplicatedValue + << " while " << h[duplicatedDate] + << " value is already present"); + } + //! observer notifying of changes in the index fixings_ ext::shared_ptr notifier(const std::string& name) const; //! returns all names of the indexes for which fixings were stored std::vector histories() const; @@ -69,7 +106,8 @@ namespace QuantLib { } }; - mutable std::map>, CaseInsensitiveCompare> data_; + mutable std::map, CaseInsensitiveCompare> data_; + mutable std::map> notifiers_; }; } From 98f9f6f75560c13af5c4682e61d9b6e3a5d07bc9 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Fri, 4 Oct 2024 17:20:40 +0200 Subject: [PATCH 04/10] QPR-12849 clean up --- ql/index.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ql/index.cpp b/ql/index.cpp index 31ae9d280be..967a806b2c2 100644 --- a/ql/index.cpp +++ b/ql/index.cpp @@ -25,7 +25,6 @@ namespace QuantLib { Real fixing, bool forceOverwrite) { checkNativeFixingsAllowed(); - std::cout << "adding fixing " << fixingDate << " " << name() << " " << std::endl; addFixings(&fixingDate, (&fixingDate) + 1, &fixing, forceOverwrite); } From a9e7a868ce4d87b51189a1e6437bef1f42b7aee3 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Fri, 4 Oct 2024 17:22:20 +0200 Subject: [PATCH 05/10] QPR-12849 clean up --- ql/utilities/observablevalue.hpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/ql/utilities/observablevalue.hpp b/ql/utilities/observablevalue.hpp index cdd7b8d23b0..461bb8c0b36 100644 --- a/ql/utilities/observablevalue.hpp +++ b/ql/utilities/observablevalue.hpp @@ -57,10 +57,6 @@ namespace QuantLib { operator ext::shared_ptr() const; //! explicit inspector const T& value() const; - //! explicit reference - T& ref(); - //! explicit notification of observers - void notifyObservers() const; private: T value_; ext::shared_ptr observable_; @@ -121,16 +117,6 @@ namespace QuantLib { const T& ObservableValue::value() const { return value_; } - - template - T& ObservableValue::ref() { - return value_; - } - - template - void ObservableValue::notifyObservers() const { - observable_->notifyObservers(); - } } #endif From 772110d44f554aad7c17e1056023793f14b72512 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Fri, 4 Oct 2024 19:14:21 +0200 Subject: [PATCH 06/10] QPR-12849 missing notifications --- ql/indexes/indexmanager.cpp | 12 ++++++++++-- ql/indexes/indexmanager.hpp | 1 - ql/utilities/observablevalue.hpp | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ql/indexes/indexmanager.cpp b/ql/indexes/indexmanager.cpp index 28a11127c43..3977b10def4 100644 --- a/ql/indexes/indexmanager.cpp +++ b/ql/indexes/indexmanager.cpp @@ -30,6 +30,7 @@ namespace QuantLib { } void IndexManager::setHistory(const std::string& name, TimeSeries history) { + notifier(name)->notifyObservers(); data_[name] = std::move(history); } @@ -57,9 +58,16 @@ namespace QuantLib { return temp; } - void IndexManager::clearHistory(const std::string& name) { data_.erase(name); } + void IndexManager::clearHistory(const std::string& name) { + notifier(name)->notifyObservers(); + data_.erase(name); + } - void IndexManager::clearHistories() { data_.clear(); } + void IndexManager::clearHistories() { + for (auto const& d : data_) + notifier(d.first)->notifyObservers(); + data_.clear(); + } bool IndexManager::hasHistoricalFixing(const std::string& name, const Date& fixingDate) const { auto const& indexIter = data_.find(name); diff --git a/ql/indexes/indexmanager.hpp b/ql/indexes/indexmanager.hpp index 6705650f0db..9fbb5440e6d 100644 --- a/ql/indexes/indexmanager.hpp +++ b/ql/indexes/indexmanager.hpp @@ -64,7 +64,6 @@ namespace QuantLib { bool noDuplicatedFixing = true; Date duplicatedDate; Real nullValue = Null(); - Real invalidValue = Null(); Real duplicatedValue = Null(); while (dBegin != dEnd) { Real currentValue = h[*dBegin]; diff --git a/ql/utilities/observablevalue.hpp b/ql/utilities/observablevalue.hpp index 461bb8c0b36..aa54ce7846f 100644 --- a/ql/utilities/observablevalue.hpp +++ b/ql/utilities/observablevalue.hpp @@ -117,6 +117,7 @@ namespace QuantLib { const T& ObservableValue::value() const { return value_; } + } #endif From 25c27569db2696e329b26a50a8a9a8933b908b12 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Fri, 4 Oct 2024 19:19:37 +0200 Subject: [PATCH 07/10] QPR-12849 update notifiers --- ql/indexes/indexmanager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ql/indexes/indexmanager.cpp b/ql/indexes/indexmanager.cpp index 3977b10def4..759a7bb1fc7 100644 --- a/ql/indexes/indexmanager.cpp +++ b/ql/indexes/indexmanager.cpp @@ -61,12 +61,14 @@ namespace QuantLib { void IndexManager::clearHistory(const std::string& name) { notifier(name)->notifyObservers(); data_.erase(name); + notifiers_.erase(name); } void IndexManager::clearHistories() { for (auto const& d : data_) notifier(d.first)->notifyObservers(); data_.clear(); + notifiers_.clear(); } bool IndexManager::hasHistoricalFixing(const std::string& name, const Date& fixingDate) const { From f609bb325aa7ab0d0ff8534656c5ebe73f144152 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sun, 6 Oct 2024 12:21:51 +0200 Subject: [PATCH 08/10] QPR-12849 restore old behaviour w.r.t. invalid fixings --- ql/index.hpp | 13 +++---------- ql/indexes/indexmanager.hpp | 34 +++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/ql/index.hpp b/ql/index.hpp index 3604152f80e..1bbe384caad 100644 --- a/ql/index.hpp +++ b/ql/index.hpp @@ -100,16 +100,9 @@ namespace QuantLib { ValueIterator vBegin, bool forceOverwrite = false) { checkNativeFixingsAllowed(); - DateIterator dBegin2 = dBegin, dEnd2 = dEnd; - ValueIterator vBegin2 = vBegin; - while (dBegin != dEnd) { - QL_REQUIRE(isValidFixingDate(*dBegin), - "At least on invalid fixing provided: " << dBegin->weekday() << *dBegin - << ", " << *vBegin); - ++dBegin; - ++vBegin; - } - IndexManager::instance().addFixings(name(), dBegin2, dEnd2, vBegin2, forceOverwrite); + IndexManager::instance().addFixings( + name(), dBegin, dEnd, vBegin, forceOverwrite, + [this](const Date& d) { return isValidFixingDate(d); }); } //! clears all stored historical fixings void clearFixings(); diff --git a/ql/indexes/indexmanager.hpp b/ql/indexes/indexmanager.hpp index 9fbb5440e6d..b6346356df5 100644 --- a/ql/indexes/indexmanager.hpp +++ b/ql/indexes/indexmanager.hpp @@ -59,27 +59,39 @@ namespace QuantLib { DateIterator dBegin, DateIterator dEnd, ValueIterator vBegin, - bool forceOverwrite = false) { + bool forceOverwrite = false, + const std::function& isValidFixingDate = {}) { auto& h = data_[name]; - bool noDuplicatedFixing = true; - Date duplicatedDate; + bool noInvalidFixing = true, noDuplicatedFixing = true; + Date invalidDate, duplicatedDate; Real nullValue = Null(); + Real invalidValue = Null(); Real duplicatedValue = Null(); while (dBegin != dEnd) { + bool validFixing = isValidFixingDate ? isValidFixingDate(*dBegin) : true; Real currentValue = h[*dBegin]; bool missingFixing = forceOverwrite || currentValue == nullValue; - if (missingFixing) - h[*(dBegin++)] = *(vBegin++); - else if (close(currentValue, *(vBegin))) { - ++dBegin; - ++vBegin; + if (validFixing) { + if (missingFixing) + h[*(dBegin++)] = *(vBegin++); + else if (close(currentValue, *(vBegin))) { + ++dBegin; + ++vBegin; + } else { + noDuplicatedFixing = false; + duplicatedDate = *(dBegin++); + duplicatedValue = *(vBegin++); + } } else { - noDuplicatedFixing = false; - duplicatedDate = *(dBegin++); - duplicatedValue = *(vBegin++); + noInvalidFixing = false; + invalidDate = *(dBegin++); + invalidValue = *(vBegin++); } } notifier(name)->notifyObservers(); + QL_REQUIRE(noInvalidFixing, "At least one invalid fixing provided: " + << invalidDate.weekday() << " " << invalidDate << ", " + << invalidValue); QL_REQUIRE(noDuplicatedFixing, "At least one duplicated fixing provided: " << duplicatedDate << ", " << duplicatedValue << " while " << h[duplicatedDate] From 6957b0a16c4eb225a63c7c6c84c0f2573b81e2c1 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sun, 6 Oct 2024 17:49:45 +0200 Subject: [PATCH 09/10] QPR-12849 keep notifiers --- ql/indexes/indexmanager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/ql/indexes/indexmanager.cpp b/ql/indexes/indexmanager.cpp index 759a7bb1fc7..3977b10def4 100644 --- a/ql/indexes/indexmanager.cpp +++ b/ql/indexes/indexmanager.cpp @@ -61,14 +61,12 @@ namespace QuantLib { void IndexManager::clearHistory(const std::string& name) { notifier(name)->notifyObservers(); data_.erase(name); - notifiers_.erase(name); } void IndexManager::clearHistories() { for (auto const& d : data_) notifier(d.first)->notifyObservers(); data_.clear(); - notifiers_.clear(); } bool IndexManager::hasHistoricalFixing(const std::string& name, const Date& fixingDate) const { From 0e5267690631d0edcfb3eab8222f58b573d7195e Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sun, 6 Oct 2024 19:30:19 +0200 Subject: [PATCH 10/10] QPR-12849 hide new methods --- ql/indexes/indexmanager.hpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ql/indexes/indexmanager.hpp b/ql/indexes/indexmanager.hpp index b6346356df5..49ba0ad23e2 100644 --- a/ql/indexes/indexmanager.hpp +++ b/ql/indexes/indexmanager.hpp @@ -40,14 +40,7 @@ namespace QuantLib { private: IndexManager() = default; - - public: - //! returns whether historical fixings were stored for the index - bool hasHistory(const std::string& name) const; - //! returns the (possibly empty) history of the index fixings - const TimeSeries& getHistory(const std::string& name) const; - //! stores the historical fixings of the index - void setHistory(const std::string& name, TimeSeries history); + friend class Index; //! add a fixing void addFixing(const std::string& name, const Date& fixingDate, @@ -97,6 +90,14 @@ namespace QuantLib { << " while " << h[duplicatedDate] << " value is already present"); } + + public: + //! returns whether historical fixings were stored for the index + bool hasHistory(const std::string& name) const; + //! returns the (possibly empty) history of the index fixings + const TimeSeries& getHistory(const std::string& name) const; + //! stores the historical fixings of the index + void setHistory(const std::string& name, TimeSeries history); //! observer notifying of changes in the index fixings_ ext::shared_ptr notifier(const std::string& name) const; //! returns all names of the indexes for which fixings were stored