Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
HistoricalScenarioLoader Class Reference

Class for loading historical scenarios. More...

#include <orea/scenario/historicalscenarioloader.hpp>

+ Collaboration diagram for HistoricalScenarioLoader:

Public Member Functions

 HistoricalScenarioLoader ()
 Default constructor. More...
 
 HistoricalScenarioLoader (const QuantLib::ext::shared_ptr< HistoricalScenarioReader > &scenarioReader, const QuantLib::Date &startDate, const QuantLib::Date &endDate, const QuantLib::Calendar &calendar)
 
 HistoricalScenarioLoader (const boost::shared_ptr< HistoricalScenarioReader > &scenarioReader, const std::set< QuantLib::Date > &dates)
 
 HistoricalScenarioLoader (const std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > &scenarios, const std::set< QuantLib::Date > &dates)
 
QuantLib::ext::shared_ptr< ore::analytics::ScenariogetHistoricalScenario (const QuantLib::Date &date) const
 Get a Scenario for a given date. More...
 
QuantLib::Size numScenarios () const
 Number of scenarios. More...
 
std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > & historicalScenarios ()
 Set historical scenarios. More...
 
const std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > & historicalScenarios () const
 The historical scenarios. More...
 
std::vector< QuantLib::Date > & dates ()
 Set historical scenario dates. More...
 
const std::vector< QuantLib::Date > & dates () const
 The historical scenario dates. More...
 

Protected Attributes

std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > historicalScenarios_
 
std::vector< QuantLib::Date > dates_
 

Detailed Description

Class for loading historical scenarios.

Definition at line 37 of file historicalscenarioloader.hpp.

Constructor & Destructor Documentation

◆ HistoricalScenarioLoader() [1/4]

Default constructor.

Definition at line 40 of file historicalscenarioloader.hpp.

40{}

◆ HistoricalScenarioLoader() [2/4]

HistoricalScenarioLoader ( const QuantLib::ext::shared_ptr< HistoricalScenarioReader > &  scenarioReader,
const QuantLib::Date &  startDate,
const QuantLib::Date &  endDate,
const QuantLib::Calendar &  calendar 
)

Constructor that loads scenarios, read from scenarioReader, between startDate and endDate.

Warning:
The scenarios coming from scenarioReader must be in ascending order. If not, an exception is thrown.
Parameters
scenarioReaderA scenario reader that feeds the loader with scenarios
startDateThe first date to load a a scenario for
endDateThe last date to load a scenario for
calendarCalendar to use when advancing dates

◆ HistoricalScenarioLoader() [3/4]

HistoricalScenarioLoader ( const boost::shared_ptr< HistoricalScenarioReader > &  scenarioReader,
const std::set< QuantLib::Date > &  dates 
)

Constructor that loads scenarios, read from scenarioReader, for given dates

Parameters
scenarioReaderA scenario reader that feeds the loader with scenarios
datesThe first date to load a a scenario for

◆ HistoricalScenarioLoader() [4/4]

HistoricalScenarioLoader ( const std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > &  scenarios,
const std::set< QuantLib::Date > &  dates 
)

Constructor that loads scenarios from a vector

Parameters
scenariosA vector of scenarios
datesThe first date to load a a scenario for

Definition at line 115 of file historicalscenarioloader.cpp.

117 {
118 for (const auto& s : scenarios) {
119 Date scenarioDate = s->asof();
120
121 auto it = dates.find(scenarioDate);
122 if (it == dates.end())
123 continue;
124 else {
125 historicalScenarios_.push_back(s);
126 dates_.push_back(scenarioDate);
127 }
128 if (dates_.size() == dates.size())
129 break;
130 }
131}
std::vector< QuantLib::Date > & dates()
Set historical scenario dates.
std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > historicalScenarios_
+ Here is the call graph for this function:

Member Function Documentation

◆ getHistoricalScenario()

QuantLib::ext::shared_ptr< Scenario > getHistoricalScenario ( const QuantLib::Date &  date) const

Get a Scenario for a given date.

Definition at line 31 of file historicalscenarioloader.cpp.

31 {
32 QL_REQUIRE(historicalScenarios_.size() > 0, "No Historical Scenarios Loaded");
33
34 auto it = std::find(dates_.begin(), dates_.end(), date);
35 QL_REQUIRE(it != dates_.end(), "HistoricalScenarioLoader can't find an index for date " << date);
36
37 Size index = std::distance(dates_.begin(), it);
38 return historicalScenarios_[index];
39};

◆ numScenarios()

QuantLib::Size numScenarios ( ) const

Number of scenarios.

Definition at line 75 of file historicalscenarioloader.hpp.

75{ return historicalScenarios_.size(); }

◆ historicalScenarios() [1/2]

std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > & historicalScenarios ( )

Set historical scenarios.

Definition at line 77 of file historicalscenarioloader.hpp.

77{ return historicalScenarios_; }

◆ historicalScenarios() [2/2]

const std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > & historicalScenarios ( ) const

The historical scenarios.

Definition at line 79 of file historicalscenarioloader.hpp.

79 {
81 }

◆ dates() [1/2]

std::vector< QuantLib::Date > & dates ( )

Set historical scenario dates.

Definition at line 83 of file historicalscenarioloader.hpp.

83{ return dates_; }
+ Here is the caller graph for this function:

◆ dates() [2/2]

const std::vector< QuantLib::Date > & dates ( ) const

The historical scenario dates.

Definition at line 85 of file historicalscenarioloader.hpp.

85{ return dates_; }

Member Data Documentation

◆ historicalScenarios_

std::vector<QuantLib::ext::shared_ptr<ore::analytics::Scenario> > historicalScenarios_
protected

Definition at line 89 of file historicalscenarioloader.hpp.

◆ dates_

std::vector<QuantLib::Date> dates_
protected

Definition at line 90 of file historicalscenarioloader.hpp.