QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
indexmanager.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2004, 2005, 2006 StatPro Italia srl
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
21
22namespace QuantLib {
23
24 bool IndexManager::hasHistory(const std::string& name) const {
25 return data_.find(name) != data_.end();
26 }
27
28 const TimeSeries<Real>& IndexManager::getHistory(const std::string& name) const {
29 return data_[name].value();
30 }
31
32 void IndexManager::setHistory(const std::string& name, TimeSeries<Real> history) {
33 data_[name] = std::move(history);
34 }
35
36 ext::shared_ptr<Observable> IndexManager::notifier(const std::string& name) const {
37 return data_[name];
38 }
39
40 std::vector<std::string> IndexManager::histories() const {
41 std::vector<std::string> temp;
42 temp.reserve(data_.size());
43 for (const auto& i : data_)
44 temp.push_back(i.first);
45 return temp;
46 }
47
48 void IndexManager::clearHistory(const std::string& name) { data_.erase(name); }
49
51
52 bool IndexManager::hasHistoricalFixing(const std::string& name, const Date& fixingDate) const {
53 auto const& indexIter = data_.find(name);
54 return (indexIter != data_.end()) &&
55 ((*indexIter).second.value()[fixingDate] != Null<Real>());
56 }
57
58}
Concrete date class.
Definition: date.hpp:125
const TimeSeries< Real > & getHistory(const std::string &name) const
returns the (possibly empty) history of the index fixings
bool hasHistoricalFixing(const std::string &name, const Date &fixingDate) const
returns whether a specific historical fixing was stored for the index and date
void setHistory(const std::string &name, TimeSeries< Real > history)
stores the historical fixings of the index
void clearHistories()
clears all stored fixings
std::map< std::string, ObservableValue< TimeSeries< Real > >, CaseInsensitiveCompare > data_
ext::shared_ptr< Observable > notifier(const std::string &name) const
observer notifying of changes in the index fixings
std::vector< std::string > histories() const
returns all names of the indexes for which fixings were stored
void clearHistory(const std::string &name)
clears the historical fixings of the index
bool hasHistory(const std::string &name) const
returns whether historical fixings were stored for the index
template class providing a null value for a given type.
Definition: null.hpp:76
Container for historical data.
Definition: timeseries.hpp:51
global repository for past index fixings
Definition: any.hpp:35