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

#include <orea/scenario/scenariogeneratortransform.hpp>

+ Inheritance diagram for ScenarioGeneratorTransform:
+ Collaboration diagram for ScenarioGeneratorTransform:

Public Member Functions

 ScenarioGeneratorTransform (QuantLib::ext::shared_ptr< ScenarioGenerator > &scenarioGenerator, const QuantLib::ext::shared_ptr< ScenarioSimMarket > &simMarket, const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &simMarketConfig)
 
QuantLib::ext::shared_ptr< Scenarionext (const QuantLib::Date &d) override
 
void reset () override
 Reset the generator so calls to next() return the first scenario. More...
 
- Public Member Functions inherited from ScenarioGenerator
virtual ~ScenarioGenerator ()
 Default destructor. More...
 
virtual QuantLib::ext::shared_ptr< Scenarionext (const Date &d)=0
 Return the next scenario for the given date. More...
 
virtual void reset ()=0
 Reset the generator so calls to next() return the first scenario. More...
 

Private Attributes

QuantLib::ext::shared_ptr< ScenarioGeneratorscenarioGenerator_
 
QuantLib::ext::shared_ptr< ScenarioSimMarketsimMarket_
 
QuantLib::ext::shared_ptr< ScenarioSimMarketParameterssimMarketConfig_
 

Detailed Description

Definition at line 41 of file scenariogeneratortransform.hpp.

Constructor & Destructor Documentation

◆ ScenarioGeneratorTransform()

ScenarioGeneratorTransform ( QuantLib::ext::shared_ptr< ScenarioGenerator > &  scenarioGenerator,
const QuantLib::ext::shared_ptr< ScenarioSimMarket > &  simMarket,
const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &  simMarketConfig 
)

Definition at line 43 of file scenariogeneratortransform.hpp.

46 : scenarioGenerator_(scenarioGenerator), simMarket_(simMarket), simMarketConfig_(simMarketConfig){}
QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > simMarketConfig_
QuantLib::ext::shared_ptr< ScenarioSimMarket > simMarket_
QuantLib::ext::shared_ptr< ScenarioGenerator > scenarioGenerator_

Member Function Documentation

◆ next()

QuantLib::ext::shared_ptr< Scenario > next ( const QuantLib::Date &  d)
override

Definition at line 26 of file scenariogeneratortransform.cpp.

26 {
27 QuantLib::ext::shared_ptr<Scenario> scenario = scenarioGenerator_->next(d)->clone();
28 const vector<RiskFactorKey>& keys = simMarket_->baseScenario()->keys();
29 Date asof = simMarket_->baseScenario()->asof();
30 vector<Period> tenors;
31 Date endDate;
32 DayCounter dc;
33
34 for (Size k = 0; k < keys.size(); ++k) {
35 if ((keys[k].keytype == RiskFactorKey::KeyType::DiscountCurve) ||
36 (keys[k].keytype == RiskFactorKey::KeyType::IndexCurve) ||
37 (keys[k].keytype == RiskFactorKey::KeyType::YieldCurve)) {
38 Real df = scenario->get(keys[k]);
39 Real compound = 1 / df;
40 if ((keys[k].keytype == RiskFactorKey::KeyType::DiscountCurve)) {
41 dc = simMarket_->discountCurve(keys[k].name)->dayCounter();
42 tenors = simMarketConfig_->yieldCurveTenors(keys[k].name);
43 } else if (keys[k].keytype == RiskFactorKey::KeyType::IndexCurve ||
44 keys[k].keytype == RiskFactorKey::KeyType::YieldCurve) {
45 dc = simMarket_->iborIndex(keys[k].name)->dayCounter();
46 tenors = simMarketConfig_->yieldCurveTenors(keys[k].name);
47 }
48 endDate = asof + tenors[keys[k].index];
49 Real zero = InterestRate::impliedRate(compound, dc, QuantLib::Compounding::Continuous,
50 QuantLib::Frequency::Annual, asof, endDate)
51 .rate();
52 scenario->add(keys[k], zero);
53 }
54 }
55 return scenario;
56}
Date asof(14, Jun, 2018)
+ Here is the call graph for this function:

◆ reset()

void reset ( )
overridevirtual

Reset the generator so calls to next() return the first scenario.

This allows re-generation of scenarios if required.

Implements ScenarioGenerator.

Definition at line 58 of file scenariogeneratortransform.cpp.

58{ scenarioGenerator_->reset(); }

Member Data Documentation

◆ scenarioGenerator_

QuantLib::ext::shared_ptr<ScenarioGenerator> scenarioGenerator_
private

Definition at line 53 of file scenariogeneratortransform.hpp.

◆ simMarket_

QuantLib::ext::shared_ptr<ScenarioSimMarket> simMarket_
private

Definition at line 54 of file scenariogeneratortransform.hpp.

◆ simMarketConfig_

QuantLib::ext::shared_ptr<ScenarioSimMarketParameters> simMarketConfig_
private

Definition at line 55 of file scenariogeneratortransform.hpp.