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

#include <orea/app/sensitivityrunner.hpp>

+ Collaboration diagram for SensitivityRunner:

Public Member Functions

 SensitivityRunner (QuantLib::ext::shared_ptr< Parameters > params, const QuantLib::ext::shared_ptr< ore::data::ReferenceDataManager > &referenceData=nullptr, const IborFallbackConfig &iborFallbackConfig=IborFallbackConfig::defaultConfig(), const bool continueOnError=false)
 
virtual ~SensitivityRunner ()
 
virtual void runSensitivityAnalysis (QuantLib::ext::shared_ptr< ore::data::Market > market, const QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > &curveConfigs, const QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > &todaysMarketParams)
 
virtual void sensiInputInitialize (QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &simMarketData, QuantLib::ext::shared_ptr< SensitivityScenarioData > &sensiData, QuantLib::ext::shared_ptr< EngineData > &engineData, QuantLib::ext::shared_ptr< Portfolio > &sensiPortfolio)
 Initialize input parameters to the sensitivities analysis. More...
 
virtual void sensiOutputReports (const QuantLib::ext::shared_ptr< SensitivityAnalysis > &sensiAnalysis)
 Write out some standard sensitivities reports. More...
 

Inspectors

QuantLib::ext::shared_ptr< Parametersparams_
 
QuantLib::ext::shared_ptr< ore::data::ReferenceDataManagerreferenceData_
 
IborFallbackConfig iborFallbackConfig_
 
const bool continueOnError_
 
QuantLib::ext::shared_ptr< ScenarioSimMarketsimMarket_
 Scenario simulation market that is bumped for the sensitivity run. More...
 
QuantLib::ext::shared_ptr< SensitivityScenarioDatasensiData_
 Sensitivity configuration data used for the sensitivity run. More...
 
const QuantLib::ext::shared_ptr< ScenarioSimMarket > & simMarket () const
 
const QuantLib::ext::shared_ptr< SensitivityScenarioData > & sensiData () const
 

Detailed Description

Definition at line 38 of file sensitivityrunner.hpp.

Constructor & Destructor Documentation

◆ SensitivityRunner()

SensitivityRunner ( QuantLib::ext::shared_ptr< Parameters params,
const QuantLib::ext::shared_ptr< ore::data::ReferenceDataManager > &  referenceData = nullptr,
const IborFallbackConfig iborFallbackConfig = IborFallbackConfig::defaultConfig(),
const bool  continueOnError = false 
)

Definition at line 40 of file sensitivityrunner.hpp.

44 : params_(params), referenceData_(referenceData), iborFallbackConfig_(iborFallbackConfig),
45 continueOnError_(continueOnError) {}
QuantLib::ext::shared_ptr< Parameters > params_
QuantLib::ext::shared_ptr< ore::data::ReferenceDataManager > referenceData_

◆ ~SensitivityRunner()

virtual ~SensitivityRunner ( )
virtual

Definition at line 47 of file sensitivityrunner.hpp.

47{};

Member Function Documentation

◆ runSensitivityAnalysis()

void runSensitivityAnalysis ( QuantLib::ext::shared_ptr< ore::data::Market market,
const QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > &  curveConfigs,
const QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > &  todaysMarketParams 
)
virtual

Definition at line 45 of file sensitivityrunner.cpp.

47 {
48
49 MEM_LOG;
50 LOG("Running sensitivity analysis");
51
52 QuantLib::ext::shared_ptr<ScenarioSimMarketParameters> simMarketData(new ScenarioSimMarketParameters);
53 sensiData_ = QuantLib::ext::make_shared<SensitivityScenarioData>();
54 QuantLib::ext::shared_ptr<EngineData> engineData = QuantLib::ext::make_shared<EngineData>();
55 QuantLib::ext::shared_ptr<Portfolio> sensiPortfolio = QuantLib::ext::make_shared<Portfolio>();
56 string marketConfiguration = params_->get("markets", "sensitivity");
57
58 sensiInputInitialize(simMarketData, sensiData_, engineData, sensiPortfolio);
59
60 bool recalibrateModels =
61 params_->has("sensitivity", "recalibrateModels") && parseBool(params_->get("sensitivity", "recalibrateModels"));
62
63 bool analyticFxSensis = false;
64 if (params_->has("sensitivity", "analyticFxSensis")) {
65 analyticFxSensis = parseBool(params_->get("sensitivity", "analyticFxSensis"));
66 }
67
68 QuantLib::ext::shared_ptr<SensitivityAnalysis> sensiAnalysis = QuantLib::ext::make_shared<SensitivityAnalysis>(
69 sensiPortfolio, market, marketConfiguration, engineData, simMarketData, sensiData_, recalibrateModels,
70 curveConfigs, todaysMarketParams, false, referenceData_, iborFallbackConfig_, continueOnError_,
71 analyticFxSensis);
72 sensiAnalysis->generateSensitivities();
73
74 simMarket_ = sensiAnalysis->simMarket();
75
76 sensiOutputReports(sensiAnalysis);
77
78 LOG("Sensitivity analysis completed");
79 MEM_LOG;
80}
QuantLib::ext::shared_ptr< SensitivityScenarioData > sensiData_
Sensitivity configuration data used for the sensitivity run.
QuantLib::ext::shared_ptr< ScenarioSimMarket > simMarket_
Scenario simulation market that is bumped for the sensitivity run.
virtual void sensiInputInitialize(QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &simMarketData, QuantLib::ext::shared_ptr< SensitivityScenarioData > &sensiData, QuantLib::ext::shared_ptr< EngineData > &engineData, QuantLib::ext::shared_ptr< Portfolio > &sensiPortfolio)
Initialize input parameters to the sensitivities analysis.
virtual void sensiOutputReports(const QuantLib::ext::shared_ptr< SensitivityAnalysis > &sensiAnalysis)
Write out some standard sensitivities reports.
bool parseBool(const string &s)
#define MEM_LOG
#define LOG(text)
+ Here is the call graph for this function:

◆ sensiInputInitialize()

void sensiInputInitialize ( QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &  simMarketData,
QuantLib::ext::shared_ptr< SensitivityScenarioData > &  sensiData,
QuantLib::ext::shared_ptr< EngineData > &  engineData,
QuantLib::ext::shared_ptr< Portfolio > &  sensiPortfolio 
)
virtual

Initialize input parameters to the sensitivities analysis.

Definition at line 82 of file sensitivityrunner.cpp.

85 {
86
87 DLOG("sensiInputInitialize called");
88
89 LOG("Get Simulation Market Parameters");
90 string inputPath = params_->get("setup", "inputPath");
91 string marketConfigFile = inputPath + "/" + params_->get("sensitivity", "marketConfigFile");
92 simMarketData->fromFile(marketConfigFile);
93
94 LOG("Get Sensitivity Parameters");
95 string sensitivityConfigFile = inputPath + "/" + params_->get("sensitivity", "sensitivityConfigFile");
96 sensiData->fromFile(sensitivityConfigFile);
97
98 LOG("Get Engine Data");
99 string sensiPricingEnginesFile = inputPath + "/" + params_->get("sensitivity", "pricingEnginesFile");
100 engineData->fromFile(sensiPricingEnginesFile);
101
102 LOG("Get Portfolio");
103 string portfoliosString = params_->get("setup", "portfolioFile");
104 vector<string> portfolioFiles = getFilenames(portfoliosString, inputPath);
105 // Just load here. We build the portfolio in SensitivityAnalysis, after building SimMarket.
106 for (auto portfolioFile : portfolioFiles) {
107 sensiPortfolio->fromFile(portfolioFile);
108 }
109
110 DLOG("sensiInputInitialize done");
111}
const QuantLib::ext::shared_ptr< SensitivityScenarioData > & sensiData() const
#define DLOG(text)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sensiOutputReports()

void sensiOutputReports ( const QuantLib::ext::shared_ptr< SensitivityAnalysis > &  sensiAnalysis)
virtual

Write out some standard sensitivities reports.

Definition at line 113 of file sensitivityrunner.cpp.

113 {
114
115 string outputPath = params_->get("setup", "outputPath");
116 Real sensiThreshold = parseReal(params_->get("sensitivity", "outputSensitivityThreshold"));
117
118 string outputFile = outputPath + "/" + params_->get("sensitivity", "scenarioOutputFile");
119 CSVFileReport scenReport(outputFile);
120 ReportWriter().writeScenarioReport(scenReport, sensiAnalysis->sensiCubes(), sensiThreshold);
121
122 // Create a stream from the sensitivity cube
123 auto baseCurrency = sensiAnalysis->simMarketData()->baseCcy();
124 auto ss = QuantLib::ext::make_shared<SensitivityCubeStream>(sensiAnalysis->sensiCube(), baseCurrency);
125
126 Size outputPrecision = 2;
127 if (params_->has("sensitivity", "outputPrecision")) {
128 outputPrecision = parseInteger(params_->get("sensitivity", "outputPrecision"));
129 }
130
131 outputFile = outputPath + "/" + params_->get("sensitivity", "sensitivityOutputFile");
132 CSVFileReport sensiReport(outputFile);
133 ReportWriter().writeSensitivityReport(sensiReport, ss, sensiThreshold, outputPrecision);
134
135 CSVFileReport pricingStatsReport(params_->get("setup", "outputPath") + "/pricingstats_sensi.csv");
136 ore::analytics::ReportWriter().writePricingStats(pricingStatsReport, sensiAnalysis->portfolio());
137}
Write ORE outputs to reports.
virtual void writePricingStats(ore::data::Report &report, const QuantLib::ext::shared_ptr< Portfolio > &portfolio)
Real parseReal(const string &s)
Integer parseInteger(const string &s)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ simMarket()

const QuantLib::ext::shared_ptr< ScenarioSimMarket > & simMarket ( ) const

Definition at line 64 of file sensitivityrunner.hpp.

64{ return simMarket_; }

◆ sensiData()

const QuantLib::ext::shared_ptr< SensitivityScenarioData > & sensiData ( ) const

Definition at line 65 of file sensitivityrunner.hpp.

65{ return sensiData_; }
+ Here is the caller graph for this function:

Member Data Documentation

◆ params_

QuantLib::ext::shared_ptr<Parameters> params_
protected

Definition at line 69 of file sensitivityrunner.hpp.

◆ referenceData_

QuantLib::ext::shared_ptr<ore::data::ReferenceDataManager> referenceData_
protected

Definition at line 70 of file sensitivityrunner.hpp.

◆ iborFallbackConfig_

IborFallbackConfig iborFallbackConfig_
protected

Definition at line 71 of file sensitivityrunner.hpp.

◆ continueOnError_

const bool continueOnError_
protected

Definition at line 72 of file sensitivityrunner.hpp.

◆ simMarket_

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

Scenario simulation market that is bumped for the sensitivity run.

Definition at line 75 of file sensitivityrunner.hpp.

◆ sensiData_

QuantLib::ext::shared_ptr<SensitivityScenarioData> sensiData_
protected

Sensitivity configuration data used for the sensitivity run.

Definition at line 78 of file sensitivityrunner.hpp.