25using QuantLib::io::iso_date;
35 QL_REQUIRE(it !=
dates_.end(),
"HistoricalScenarioLoader can't find an index for date " << date);
37 Size index = std::distance(
dates_.begin(), it);
42 const Date& startDate,
const Date& endDate,
43 const Calendar& calendar) {
45 QL_REQUIRE(scenarioReader,
"The historical scenario loader must be provided with a valid scenario reader");
47 LOG(
"Loading historical scenarios from " << startDate <<
" to " << endDate);
55 while (scenarioReader->next() && d <= endDate) {
56 Date scenarioDate = scenarioReader->date();
57 QL_REQUIRE(previousDate < scenarioDate,
"Require that the scenario reader provides dates in "
58 <<
"ascending order but we got: " << iso_date(previousDate)
59 <<
" >= " << iso_date(scenarioDate));
60 previousDate = scenarioDate;
65 if (scenarioDate > d) {
66 while (d < scenarioDate && d <= endDate) {
67 DLOG(
"No data in file for date " << iso_date(d));
73 if (scenarioDate < d) {
74 DLOG(
"Skipping scenario for date " << iso_date(scenarioDate) <<
" as it is before next requested date "
82 DLOG(
"Loading scenario for date " << iso_date(d));
89 DLOG(
"Skipping scenario for date " << iso_date(scenarioDate) <<
" as it is past the loader's end date "
90 << iso_date(endDate));
98 const boost::shared_ptr<HistoricalScenarioReader>& scenarioReader,
99 const std::set<Date>& dates) {
100 while (scenarioReader->next()) {
101 Date scenarioDate = scenarioReader->date();
103 auto it =
dates.find(scenarioDate);
104 if (it ==
dates.end())
108 dates_.push_back(scenarioDate);
116 const std::vector<QuantLib::ext::shared_ptr<ore::analytics::Scenario>>& scenarios,
117 const std::set<QuantLib::Date>& dates) {
118 for (
const auto& s : scenarios) {
119 Date scenarioDate = s->asof();
121 auto it =
dates.find(scenarioDate);
122 if (it ==
dates.end())
126 dates_.push_back(scenarioDate);
HistoricalScenarioLoader()
Default constructor.
std::vector< QuantLib::Date > dates_
QuantLib::ext::shared_ptr< ore::analytics::Scenario > getHistoricalScenario(const QuantLib::Date &date) const
Get a Scenario for a given date.
std::vector< QuantLib::Date > & dates()
Set historical scenario dates.
std::vector< QuantLib::ext::shared_ptr< ore::analytics::Scenario > > historicalScenarios_
historical scenario loader