Logo
Reference manual - version orea_version
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ScenarioSimMarket Class Reference

Simulation Market updated with discrete scenarios. More...

#include <orea/scenario/scenariosimmarket.hpp>

+ Inheritance diagram for ScenarioSimMarket:

Public Member Functions

 ScenarioSimMarket (const bool handlePseudoCurrencies)
 Constructor.
 
 ScenarioSimMarket (const QuantLib::ext::shared_ptr< Market > &initMarket, const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &parameters, const std::string &configuration=Market::defaultConfiguration, const ore::data::CurveConfigurations &curveConfigs=ore::data::CurveConfigurations(), const ore::data::TodaysMarketParameters &todaysMarketParams=ore::data::TodaysMarketParameters(), const bool continueOnError=false, const bool useSpreadedTermStructures=false, const bool cacheSimData=false, const bool allowPartialScenarios=false, const IborFallbackConfig &iborFallbackConfig=IborFallbackConfig::defaultConfig(), const bool handlePseudoCurrencies=true, const QuantLib::ext::shared_ptr< Scenario > &offSetScenario=nullptr)
 
 ScenarioSimMarket (const QuantLib::ext::shared_ptr< Market > &initMarket, const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &parameters, const QuantLib::ext::shared_ptr< FixingManager > &fixingManager, const std::string &configuration=Market::defaultConfiguration, const ore::data::CurveConfigurations &curveConfigs=ore::data::CurveConfigurations(), const ore::data::TodaysMarketParameters &todaysMarketParams=ore::data::TodaysMarketParameters(), const bool continueOnError=false, const bool useSpreadedTermStructures=false, const bool cacheSimData=false, const bool allowPartialScenarios=false, const IborFallbackConfig &iborFallbackConfig=IborFallbackConfig::defaultConfig(), const bool handlePseudoCurrencies=true, const QuantLib::ext::shared_ptr< Scenario > &offSetScenario=nullptr)
 
virtual QuantLib::ext::shared_ptr< ScenarioGenerator > & scenarioGenerator ()
 Set scenario generator.
 
virtual const QuantLib::ext::shared_ptr< ScenarioGenerator > & scenarioGenerator () const
 Get scenario generator.
 
virtual QuantLib::ext::shared_ptr< AggregationScenarioData > & aggregationScenarioData ()
 Set aggregation data.
 
virtual const QuantLib::ext::shared_ptr< AggregationScenarioData > & aggregationScenarioData () const
 Get aggregation data.
 
virtual QuantLib::ext::shared_ptr< ScenarioFilter > & filter ()
 Set scenarioFilter.
 
virtual const QuantLib::ext::shared_ptr< ScenarioFilter > & filter () const
 Get scenarioFilter.
 
virtual void preUpdate () override
 Update.
 
virtual void updateScenario (const Date &) override
 Retrieve next market scenario and apply this, but don't update date.
 
virtual void updateDate (const Date &) override
 Update to the given date.
 
virtual void postUpdate (const Date &d, bool withFixings) override
 Observable reset depending on selected mode, instrument updates.
 
virtual void updateAsd (const Date &) override
 Update aggregation scenario data.
 
virtual void reset () override
 Reset sim market to initial state.
 
virtual QuantLib::ext::shared_ptr< ScenariobaseScenario () const
 
virtual QuantLib::ext::shared_ptr< ScenariobaseScenarioAbsolute () const
 
bool useSpreadedTermStructures () const
 
const QuantLib::ext::shared_ptr< FixingManager > & fixingManager () const override
 Return the fixing manager.
 
virtual bool isSimulated (const RiskFactorKey::KeyType &factor) const
 is risk factor key simulated by this sim market instance?
 
void applyScenario (const QuantLib::ext::shared_ptr< Scenario > &scenario)
 
- Public Member Functions inherited from SimMarket
 SimMarket (const bool handlePseudoCurrencies)
 
virtual void update (const Date &d)
 Generate or retrieve market scenario, update market, notify termstructures and update fixings.
 
Real numeraire ()
 Return current numeraire value.
 
const std::string & label ()
 Return current scenario label, if any.
 
- Public Member Functions inherited from MarketImpl
Date asofDate () const override
 
Handle< YieldTermStructure > yieldCurve (const YieldCurveType &type, const string &ccy, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantLib::SwaptionVolatilityStructure > swaptionVol (const string &key, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantLib::SwaptionVolatilityStructure > yieldVol (const string &securityID, const string &configuration=Market::defaultConfiguration) const override
 
QuantLib::Handle< QuantExt::FxIndexfxIndexImpl (const string &fxIndex, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::CreditCurvedefaultCurve (const string &, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::CreditVolCurvecdsVol (const string &name, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::BaseCorrelationTermStructurebaseCorrelation (const string &name, const string &configuration=Market::defaultConfiguration) const override
 
Handle< OptionletVolatilityStructure > capFloorVol (const string &key, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::YoYOptionletVolatilitySurface > yoyCapFloorVol (const string &name, const string &configuration=Market::defaultConfiguration) const override
 
virtual Handle< ZeroInflationIndex > zeroInflationIndex (const string &indexName, const string &configuration=Market::defaultConfiguration) const override
 
virtual Handle< CPIVolatilitySurface > cpiInflationCapFloorVolatilitySurface (const string &indexName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< Quote > equitySpot (const string &eqName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< BlackVolTermStructureequityVol (const string &eqName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< YieldTermStructure > equityForecastCurve (const string &eqName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< Quote > securitySpread (const string &securityID, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::InflationIndexObserverbaseCpis (const string &index, const string &configuration=Market::defaultConfiguration) const
 
QuantLib::Handle< QuantExt::PriceTermStructurecommodityPriceCurve (const string &commodityName, const string &configuration=Market::defaultConfiguration) const override
 
QuantLib::Handle< QuantExt::CommodityIndexcommodityIndex (const std::string &commodityName, const std::string &configuration=Market::defaultConfiguration) const override
 
QuantLib::Handle< QuantLib::BlackVolTermStructure > commodityVolatility (const string &commodityName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::CorrelationTermStructurecorrelationCurve (const string &index1, const string &index2, const string &configuration=Market::defaultConfiguration) const override
 
void refresh (const string &configuration=Market::defaultConfiguration) override
 
Date asofDate () const override
 
Handle< YieldTermStructure > yieldCurve (const YieldCurveType &type, const string &ccy, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantLib::SwaptionVolatilityStructure > swaptionVol (const string &key, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantLib::SwaptionVolatilityStructure > yieldVol (const string &securityID, const string &configuration=Market::defaultConfiguration) const override
 
QuantLib::Handle< QuantExt::FxIndexfxIndexImpl (const string &fxIndex, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::CreditCurvedefaultCurve (const string &, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::CreditVolCurvecdsVol (const string &name, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::BaseCorrelationTermStructurebaseCorrelation (const string &name, const string &configuration=Market::defaultConfiguration) const override
 
Handle< OptionletVolatilityStructure > capFloorVol (const string &key, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::YoYOptionletVolatilitySurface > yoyCapFloorVol (const string &name, const string &configuration=Market::defaultConfiguration) const override
 
virtual Handle< ZeroInflationIndex > zeroInflationIndex (const string &indexName, const string &configuration=Market::defaultConfiguration) const override
 
virtual Handle< CPIVolatilitySurface > cpiInflationCapFloorVolatilitySurface (const string &indexName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< Quote > equitySpot (const string &eqName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< BlackVolTermStructureequityVol (const string &eqName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< YieldTermStructure > equityForecastCurve (const string &eqName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< Quote > securitySpread (const string &securityID, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::InflationIndexObserverbaseCpis (const string &index, const string &configuration=Market::defaultConfiguration) const
 
QuantLib::Handle< QuantExt::PriceTermStructurecommodityPriceCurve (const string &commodityName, const string &configuration=Market::defaultConfiguration) const override
 
QuantLib::Handle< QuantExt::CommodityIndexcommodityIndex (const std::string &commodityName, const std::string &configuration=Market::defaultConfiguration) const override
 
QuantLib::Handle< QuantLib::BlackVolTermStructure > commodityVolatility (const string &commodityName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::CorrelationTermStructurecorrelationCurve (const string &index1, const string &index2, const string &configuration=Market::defaultConfiguration) const override
 
- Public Member Functions inherited from Market
 Market (const bool handlePseudoCurrencies)
 

Protected Member Functions

void writeSimData (std::map< RiskFactorKey, QuantLib::ext::shared_ptr< SimpleQuote >> &simDataTmp, std::map< RiskFactorKey, Real > &absoluteSimDataTmp, const RiskFactorKey::KeyType keyType, const std::string &name, const std::vector< std::vector< Real >> &coordinates)
 
void addYieldCurve (const QuantLib::ext::shared_ptr< Market > &initMarket, const std::string &configuration, const RiskFactorKey::KeyType rf, const string &key, const vector< Period > &tenors, bool &simDataWritten, bool simulate=true, bool spreaded=false)
 
QuantLib::Handle< QuantLib::YieldTermStructure > getYieldCurve (const std::string &yieldSpecId, const ore::data::TodaysMarketParameters &todaysMarketParams, const std::string &configuration, const QuantLib::ext::shared_ptr< ore::data::Market > &market=nullptr) const
 
bool addSwapIndexToSsm (const std::string &indexName, const bool continueOnError)
 
- Protected Member Functions inherited from MarketImpl
virtual void require (const MarketObject o, const string &name, const string &configuration, const bool forceBuild=false) const
 
void addSwapIndex (const string &swapindex, const string &discountIndex, const string &configuration=Market::defaultConfiguration) const
 

Protected Attributes

const QuantLib::ext::shared_ptr< ScenarioSimMarketParametersparameters_
 
QuantLib::ext::shared_ptr< ScenarioGeneratorscenarioGenerator_
 
QuantLib::ext::shared_ptr< AggregationScenarioDataasd_
 
QuantLib::ext::shared_ptr< FixingManagerfixingManager_
 
QuantLib::ext::shared_ptr< ScenarioFilterfilter_
 
std::map< RiskFactorKey, QuantLib::ext::shared_ptr< SimpleQuote > > simData_
 
QuantLib::ext::shared_ptr< ScenariobaseScenario_
 
QuantLib::ext::shared_ptr< ScenariobaseScenarioAbsolute_
 
std::vector< QuantLib::ext::shared_ptr< SimpleQuote > > cachedSimData_
 
std::vector< bool > cachedSimDataActive_
 
std::size_t cachedSimDataKeysHash_ = 0
 
std::set< RiskFactorKey::KeyTypenonSimulatedFactors_
 
bool useSpreadedTermStructures_
 
std::map< RiskFactorKey, Real > absoluteSimData_
 
std::set< std::tuple< RiskFactorKey::KeyType, std::string, std::vector< std::vector< Real > > > > coordinatesData_
 
bool cacheSimData_
 
bool allowPartialScenarios_
 
IborFallbackConfig iborFallbackConfig_
 
std::set< ore::analytics::RiskFactorKeydiffToBaseKeys_
 
QuantLib::ext::shared_ptr< ScenariocurrentScenario_
 
QuantLib::ext::shared_ptr< ScenariooffsetScenario_
 
- Protected Attributes inherited from SimMarket
Real numeraire_
 
std::string label_
 

Additional Inherited Members

- Static Public Attributes inherited from Market
static const string defaultConfiguration
 
static const string inCcyConfiguration
 

Detailed Description

Simulation Market updated with discrete scenarios.

If useSpreadedTermStructures is true, spreaded term structures over the initMarket for supported risk factors will be generated. This is used by the SensitivityScenarioGenerator.

If cacheSimData is true, the scenario application is optimised. This requires that all scenarios are SimpleScenario instances with identical key structure in their data.

If allowPartialScenarios is true, the check that all simData_ is touched by a scenario is disabled.

Member Function Documentation

◆ baseScenario()

virtual QuantLib::ext::shared_ptr<Scenario> baseScenario ( ) const
virtual

Scenario representing the initial state of the market. If useSpreadedTermStructures = false, this scenario contains absolute values for all risk factor keys. If useSpreadedTermStructures = true, this scenario contains spread values for all risk factor keys which support spreaded term structures and absolute values for the other risk factor keys. The spread values will typically be zero (e.g. for vol risk factors) or 1 (e.g. for rate curve risk factors, since we use discount factors there).

◆ baseScenarioAbsolute()

virtual QuantLib::ext::shared_ptr<Scenario> baseScenarioAbsolute ( ) const
virtual

Scenario representing the initial state of the market. This scenario contains absolute values for all risk factor types, no matter whether useSpreadedTermStructures is true or false.

◆ useSpreadedTermStructures()

bool useSpreadedTermStructures ( ) const

Return true if this instance uses spreaded term structures

◆ getYieldCurve()

QuantLib::Handle<QuantLib::YieldTermStructure> getYieldCurve ( const std::string &  yieldSpecId,
const ore::data::TodaysMarketParameters todaysMarketParams,
const std::string &  configuration,
const QuantLib::ext::shared_ptr< ore::data::Market > &  market = nullptr 
) const
protected

Given a yield curve spec ID, yieldSpecId, return the corresponding yield term structure from the market. If market is nullptr, then the yield term structure is taken from this ScenarioSimMarket instance.

◆ addSwapIndexToSsm()

bool addSwapIndexToSsm ( const std::string &  indexName,
const bool  continueOnError 
)
protected

add a single swap index to the market, return true if successful