26#include <boost/make_shared.hpp>
35#include <ql/math/randomnumbers/rngtraits.hpp>
56 const QuantLib::Date& d1,
const QuantLib::Date& d2)
const;
63 const std::map<RiskFactorKey::KeyType, ReturnType>
returnTypes()
const;
66 const std::map<RiskFactorKey::KeyType, ReturnType>
returnType_;
105 const QuantLib::ext::shared_ptr<HistoricalScenarioLoader>& historicalScenarioLoader,
111 const QuantLib::ext::shared_ptr<ore::data::AdjustmentFactors>&
adjFactors =
nullptr,
125 const boost::shared_ptr<HistoricalScenarioLoader>& historicalScenarioLoader,
129 const boost::shared_ptr<ore::data::AdjustmentFactors>&
adjFactors =
nullptr,
161 QuantLib::ext::shared_ptr<Scenario>
next(
const QuantLib::Date& d)
override;
207 std::pair<QuantLib::ext::shared_ptr<Scenario>, QuantLib::ext::shared_ptr<Scenario>>
scenarioPair();
223 QuantLib::ext::shared_ptr<ore::data::AdjustmentFactors>
adjFactors_;
234 const QuantLib::ext::shared_ptr<HistoricalScenarioLoader>& historicalScenarioLoader,
240 const QuantLib::ext::shared_ptr<ore::data::AdjustmentFactors>&
adjFactors =
nullptr,
249 normalrng_ = QuantLib::ext::make_shared<QuantLib::PseudoRandom::rng_type>(MersenneTwisterUniformRng(42));
252 QuantLib::ext::shared_ptr<Scenario>
next(
const QuantLib::Date& d)
override;
253 void reset()
override;
256 QuantLib::ext::shared_ptr<QuantLib::PseudoRandom::rng_type>
normalrng_;
268 const QuantLib::ext::shared_ptr<ScenarioSimMarket>& simMarket,
269 const QuantLib::ext::shared_ptr<ScenarioSimMarketParameters>& simMarketConfig)
277 QuantLib::ext::shared_ptr<Scenario>
next(
const QuantLib::Date& d)
override;
291 const QuantLib::ext::shared_ptr<HistoricalScenarioGenerator>& gen);
292 void reset()
override;
293 QuantLib::ext::shared_ptr<Scenario>
next(
const QuantLib::Date& d)
override;
296 QuantLib::ext::shared_ptr<HistoricalScenarioGenerator>
gen_;
302 const QuantLib::ext::shared_ptr<HistoricalScenarioReader>& hsr,
303 const QuantLib::ext::shared_ptr<ore::data::AdjustmentFactors>& adjFactors,
const TimePeriod& period,
304 Calendar calendar, Size mporDays,
305 const QuantLib::ext::shared_ptr<ScenarioSimMarketParameters>& simParams,
306 const QuantLib::ext::shared_ptr<TodaysMarketParameters>& marketParam,
307 const bool overlapping =
true);
310 const QuantLib::ext::shared_ptr<HistoricalScenarioReader>& hsr,
311 const QuantLib::ext::shared_ptr<ore::data::AdjustmentFactors>& adjFactors,
const std::set<QuantLib::Date>& dates,
312 const QuantLib::ext::shared_ptr<ScenarioSimMarketParameters>& simParams,
313 const QuantLib::ext::shared_ptr<TodaysMarketParameters>& marketParam);
Historical Scenario Generator.
const QuantLib::ext::shared_ptr< ore::data::AdjustmentFactors > & adjFactors() const
Get the adj factors.
virtual void setDates()
set the start and end dates, can be overwritten in derived class
std::vector< QuantLib::Date > startDates_
const std::vector< QuantLib::Date > & startDates() const
start dates from which the scenarios were generated from
const QuantLib::ext::shared_ptr< Scenario > & baseScenario() const
Get base scenario.
bool overlapping() const
Are scenarios overlapping.
std::vector< HistoricalScenarioCalculationDetails > calculationDetails_
const QuantLib::ext::shared_ptr< ScenarioFactory > & scenarioFactory() const
Get the ScenarioFactory.
HistoricalScenarioGenerator(const boost::shared_ptr< HistoricalScenarioLoader > &historicalScenarioLoader, const boost::shared_ptr< ScenarioFactory > &scenarioFactory, const boost::shared_ptr< ore::data::AdjustmentFactors > &adjFactors=nullptr, const ReturnConfiguration &returnConfiguration=ReturnConfiguration(), const std::string &labelPrefix="")
Constructor with no mporDays/Calendar, construct historical shift scenario between each scneario.
QuantLib::ext::shared_ptr< Scenario > baseScenario_
QuantLib::Size mporDays() const
Get mpor days.
QuantLib::ext::shared_ptr< HistoricalScenarioLoader > historicalScenarioLoader_
QuantLib::ext::shared_ptr< Scenario > next(const QuantLib::Date &d) override
Return the next scenario for the given date.
QuantLib::ext::shared_ptr< ore::data::AdjustmentFactors > adjFactors_
const std::vector< HistoricalScenarioCalculationDetails > & lastHistoricalScenarioCalculationDetails() const
Return the calculation details of the last generated scenario */.
virtual QuantLib::Real scaling(const RiskFactorKey &key, const QuantLib::Real &keyReturn)
Scaling.
ReturnConfiguration returnConfiguration_
const QuantLib::ext::shared_ptr< HistoricalScenarioLoader > & scenarioLoader() const
Get the HistoricalScenarioLoader.
QuantLib::ext::shared_ptr< Scenario > & baseScenario()
Set base scenario, this also defines the asof date.
const std::vector< QuantLib::Date > & endDates() const
end dates from which the scenarios were generated from
virtual QuantLib::Size numScenarios() const
Number of scenarios this generator can generate.
const std::string & labelPrefix() const
Get the scenario label prefix.
std::vector< std::pair< QuantLib::Date, QuantLib::Date > > filteredScenarioDates(const ore::data::TimePeriod &period) const
Get (start, end) scenario date pairs filtered on the given period.
QuantLib::ext::shared_ptr< ScenarioFactory > scenarioFactory_
const QuantLib::Calendar & cal() const
Get calendar.
QuantLib::Real adjustedPrice(RiskFactorKey key, QuantLib::Date d, QuantLib::Real price)
Returns the adjusted price.
std::vector< QuantLib::Date > endDates_
std::pair< QuantLib::ext::shared_ptr< Scenario >, QuantLib::ext::shared_ptr< Scenario > > scenarioPair()
The Scenario Pairs for a given index.
void reset() override
Reset the generator so calls to next() return the first scenario.
const ReturnConfiguration & returnConfiguration() const
Return configuration.
Historical scenario generator generating random scenarios, for testing purposes.
QuantLib::ext::shared_ptr< Scenario > next(const QuantLib::Date &d) override
HistoricalScenarioGeneratorRandom(const QuantLib::ext::shared_ptr< HistoricalScenarioLoader > &historicalScenarioLoader, const QuantLib::ext::shared_ptr< ScenarioFactory > &scenarioFactory, const QuantLib::Calendar &cal, const QuantLib::ext::shared_ptr< ore::data::AdjustmentFactors > &adjFactors=nullptr, const QuantLib::Size mporDays=10, const bool overlapping=true, const ReturnConfiguration &returnConfiguration=ReturnConfiguration())
void reset() override
Reset the generator so calls to next() return the first scenario.
QuantLib::ext::shared_ptr< QuantLib::PseudoRandom::rng_type > normalrng_
std::vector< bool > isRelevantScenario_
QuantLib::ext::shared_ptr< Scenario > next(const QuantLib::Date &d) override
QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > gen_
void reset() override
Reset the generator so calls to next() return the first scenario.
Return type for historical scenario generation (absolute, relative, log)
const std::map< RiskFactorKey::KeyType, ReturnType > returnType_
QuantLib::Real applyReturn(const RiskFactorKey &key, const QuantLib::Real baseValue, const QuantLib::Real returnValue) const
apply return from v1, v2 to base value
ReturnConfiguration()
default return types per risk factor
const std::map< RiskFactorKey::KeyType, ReturnType > returnTypes() const
get return types
QuantLib::Real returnValue(const RiskFactorKey &key, const QuantLib::Real v1, const QuantLib::Real v2, const QuantLib::Date &d1, const QuantLib::Date &d2) const
Data types stored in the scenario class.
Scenario generator base class.
SafeStack< Filter > filter
historical scenario loader
historical scenario reader
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
QuantLib::ext::shared_ptr< HistoricalScenarioGenerator > buildHistoricalScenarioGenerator(const QuantLib::ext::shared_ptr< HistoricalScenarioReader > &hsr, const QuantLib::ext::shared_ptr< ore::data::AdjustmentFactors > &adjFactors, const TimePeriod &period, Calendar calendar, Size mporDays, const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &simParams, const QuantLib::ext::shared_ptr< TodaysMarketParameters > &marketParams, const bool overlapping)
factory classes for scenarios
Scenario generator base classes.
A Market class that can be updated by Scenarios.
ReturnConfiguration::ReturnType returnType