Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
historicalscenarioloader.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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 orea/scenario/historicalscenarioloader.hpp
20 \brief historical scenario loader
21 \ingroup scenario
22*/
23
24#pragma once
25
26#include <boost/make_shared.hpp>
30#include <ql/time/calendar.hpp>
31#include <vector>
32
33namespace ore {
34namespace analytics {
35
36//! Class for loading historical scenarios
38public:
39 //! Default constructor
41
42 /*! Constructor that loads scenarios, read from \p scenarioReader, between \p startDate
43 and \p endDate.
44
45 \warning The scenarios coming from \p scenarioReader must be in ascending order. If not,
46 an exception is thrown.
47 */
49 //! A scenario reader that feeds the loader with scenarios
50 const QuantLib::ext::shared_ptr<HistoricalScenarioReader>& scenarioReader,
51 //! The first date to load a a scenario for
52 const QuantLib::Date& startDate,
53 //! The last date to load a scenario for
54 const QuantLib::Date& endDate,
55 //! Calendar to use when advancing dates
56 const QuantLib::Calendar& calendar);
57
58 /*! Constructor that loads scenarios, read from \p scenarioReader, for given dates */
60 //! A scenario reader that feeds the loader with scenarios
61 const boost::shared_ptr<HistoricalScenarioReader>& scenarioReader,
62 //! The first date to load a a scenario for
63 const std::set<QuantLib::Date>& dates);
64
65 /*! Constructor that loads scenarios from a vector */
67 //! A vector of scenarios
68 const std::vector<QuantLib::ext::shared_ptr<ore::analytics::Scenario>>& scenarios,
69 //! The first date to load a a scenario for
70 const std::set<QuantLib::Date>& dates);
71
72 //! Get a Scenario for a given date
73 QuantLib::ext::shared_ptr<ore::analytics::Scenario> getHistoricalScenario(const QuantLib::Date& date) const;
74 //! Number of scenarios
75 QuantLib::Size numScenarios() const { return historicalScenarios_.size(); }
76 //! Set historical scenarios
77 std::vector<QuantLib::ext::shared_ptr<ore::analytics::Scenario>>& historicalScenarios() { return historicalScenarios_; }
78 //! The historical scenarios
79 const std::vector<QuantLib::ext::shared_ptr<ore::analytics::Scenario>>& historicalScenarios() const {
81 }
82 //! Set historical scenario dates
83 std::vector<QuantLib::Date>& dates() { return dates_; }
84 //! The historical scenario dates
85 const std::vector<QuantLib::Date>& dates() const { return dates_; }
86
87protected:
88 // to be populated by derived classes
89 std::vector<QuantLib::ext::shared_ptr<ore::analytics::Scenario>> historicalScenarios_;
90 std::vector<QuantLib::Date> dates_;
91};
92
93} // namespace analytics
94} // namespace ore
Class for loading historical scenarios.
HistoricalScenarioLoader(const boost::shared_ptr< HistoricalScenarioReader > &scenarioReader, const std::set< QuantLib::Date > &dates)
HistoricalScenarioLoader(const QuantLib::ext::shared_ptr< HistoricalScenarioReader > &scenarioReader, const QuantLib::Date &startDate, const QuantLib::Date &endDate, const QuantLib::Calendar &calendar)
QuantLib::ext::shared_ptr< ore::analytics::Scenario > getHistoricalScenario(const QuantLib::Date &date) const
Get a Scenario for a given date.
QuantLib::Size numScenarios() const
Number of scenarios.
const std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > & historicalScenarios() const
The historical scenarios.
std::vector< QuantLib::Date > & dates()
Set historical scenario dates.
std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > & historicalScenarios()
Set historical scenarios.
std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > historicalScenarios_
const std::vector< QuantLib::Date > & dates() const
The historical scenario dates.
historical scenario reader
Scenario class.
factory classes for scenarios