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

#include <orea/app/analytics/varanalytic.hpp>

+ Inheritance diagram for ParametricVarAnalyticImpl:
+ Collaboration diagram for ParametricVarAnalyticImpl:

Public Member Functions

 ParametricVarAnalyticImpl (const QuantLib::ext::shared_ptr< InputParameters > &inputs)
 
virtual void setUpConfigurations () override
 
virtual QuantLib::ext::shared_ptr< SensitivityStreamsensiStream (const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader)
 
- Public Member Functions inherited from VarAnalyticImpl
 VarAnalyticImpl (const QuantLib::ext::shared_ptr< InputParameters > &inputs, const string &label)
 
virtual void runAnalytic (const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const std::set< std::string > &runTypes={}) override
 
virtual void setUpConfigurations () override
 
- Public Member Functions inherited from Analytic::Impl
 Impl ()
 
 Impl (const QuantLib::ext::shared_ptr< InputParameters > &inputs)
 
virtual ~Impl ()
 
virtual void runAnalytic (const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const std::set< std::string > &runTypes={})=0
 
virtual void setUpConfigurations ()
 
virtual QuantLib::ext::shared_ptr< ore::data::EngineFactoryengineFactory ()
 build an engine factory More...
 
void setLabel (const string &label)
 
const std::string & label () const
 
void setAnalytic (Analytic *analytic)
 
Analyticanalytic () const
 
void setInputs (const QuantLib::ext::shared_ptr< InputParameters > &inputs)
 
bool generateAdditionalResults () const
 
void setGenerateAdditionalResults (const bool generateAdditionalResults)
 
bool hasDependentAnalytic (const std::string &key)
 
template<class T >
QuantLib::ext::shared_ptr< T > dependentAnalytic (const std::string &key) const
 
QuantLib::ext::shared_ptr< AnalyticdependentAnalytic (const std::string &key) const
 
const std::map< std::string, QuantLib::ext::shared_ptr< Analytic > > & dependentAnalytics () const
 
void addDependentAnalytic (const std::string &key, const QuantLib::ext::shared_ptr< Analytic > &analytic)
 
std::vector< QuantLib::ext::shared_ptr< Analytic > > allDependentAnalytics () const
 
virtual std::vector< QuantLib::Date > additionalMarketDates () const
 

Static Public Attributes

static constexpr const char * LABEL = "PARAMETRIC_VAR"
 

Protected Member Functions

void setVarReport (const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader) override
 
virtual void setVarReport (const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader)
 

Additional Inherited Members

- Protected Attributes inherited from VarAnalyticImpl
QuantLib::ext::shared_ptr< VarReportvarReport_
 
- Protected Attributes inherited from Analytic::Impl
QuantLib::ext::shared_ptr< InputParametersinputs_
 
std::string label_
 label for logging purposes primarily More...
 
std::map< std::string, QuantLib::ext::shared_ptr< Analytic > > dependentAnalytics_
 

Detailed Description

Definition at line 56 of file varanalytic.hpp.

Constructor & Destructor Documentation

◆ ParametricVarAnalyticImpl()

ParametricVarAnalyticImpl ( const QuantLib::ext::shared_ptr< InputParameters > &  inputs)

Definition at line 60 of file varanalytic.hpp.

61 : VarAnalyticImpl(inputs, LABEL) {};
static constexpr const char * LABEL
Definition: varanalytic.hpp:58
VarAnalyticImpl(const QuantLib::ext::shared_ptr< InputParameters > &inputs, const string &label)
Definition: varanalytic.hpp:34

Member Function Documentation

◆ setUpConfigurations()

void setUpConfigurations ( )
overridevirtual

Reimplemented from VarAnalyticImpl.

Definition at line 78 of file varanalytic.cpp.

78 {
80 if (inputs_->covarianceData().size() == 0) {
81 analytic()->configurations().sensiScenarioData = inputs_->sensiScenarioData();
82 analytic()->configurations().simMarketParams = inputs_->sensiSimMarketParams();
83 }
84}
Analytic * analytic() const
Definition: analytic.hpp:193
QuantLib::ext::shared_ptr< InputParameters > inputs_
Definition: analytic.hpp:216
Configurations & configurations()
Definition: analytic.hpp:128
virtual void setUpConfigurations() override
Definition: varanalytic.cpp:39
QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > sensiScenarioData
Definition: analytic.hpp:70
QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > simMarketParams
Definition: analytic.hpp:69
+ Here is the call graph for this function:

◆ sensiStream()

virtual QuantLib::ext::shared_ptr< SensitivityStream > sensiStream ( const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &  loader)
virtual

Definition at line 65 of file varanalytic.hpp.

65 {
66 return inputs_->sensitivityStream();
67 };
+ Here is the caller graph for this function:

◆ setVarReport()

void setVarReport ( const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &  loader)
overrideprotectedvirtual

Reimplemented from VarAnalyticImpl.

Definition at line 86 of file varanalytic.cpp.

86 {
87 LOG("Build trade to portfolio id mapping");
88 ParametricVarCalculator::ParametricVarParams varParams(inputs_->varMethod(), inputs_->mcVarSamples(),
89 inputs_->mcVarSeed());
90
91 QuantLib::ext::shared_ptr<SensitivityStream> ss = sensiStream(loader);
92
93 LOG("Build VaR calculator");
94 if (inputs_->covarianceData().size() > 0) {
95 std::unique_ptr<MarketRiskReport::SensiRunArgs> sensiArgs =
96 std::make_unique<MarketRiskReport::SensiRunArgs>(ss, nullptr, 0.01, inputs_->covarianceData());
97
98 varReport_ = ext::make_shared<ParametricVarReport>(
99 inputs_->baseCurrency(), analytic()->portfolio(), inputs_->portfolioFilter(), inputs_->varQuantiles(),
100 varParams,
101 inputs_->salvageCovariance(), boost::none, std::move(sensiArgs), inputs_->varBreakDown());
102 } else {
103 TimePeriod benchmarkVarPeriod(parseListOfValues<Date>(inputs_->benchmarkVarPeriod(), &parseDate),
104 inputs_->mporDays(), inputs_->mporCalendar());
105
106 QuantLib::ext::shared_ptr<ore::data::AdjustmentFactors> adjFactors;
107 if (auto adjLoader = QuantLib::ext::dynamic_pointer_cast<AdjustedInMemoryLoader>(loader))
108 adjFactors = QuantLib::ext::make_shared<ore::data::AdjustmentFactors>(adjLoader->adjustmentFactors());
109
110 auto scenarios = buildHistoricalScenarioGenerator(inputs_->historicalScenarioReader(), adjFactors,
111 benchmarkVarPeriod, inputs_->mporCalendar(), inputs_->mporDays(), analytic()->configurations().simMarketParams,
112 analytic()->configurations().todaysMarketParams, inputs_->mporOverlappingPeriods());
113
114 if (inputs_->outputHistoricalScenarios())
115 ReportWriter().writeHistoricalScenarios(
116 scenarios->scenarioLoader(),
117 QuantLib::ext::make_shared<CSVFileReport>(path(inputs_->resultsPath() / "backtest_histscenrios.csv").string(),
118 ',', false, inputs_->csvQuoteChar(), inputs_->reportNaString()));
119
120 auto simMarket = QuantLib::ext::make_shared<ScenarioSimMarket>(
121 analytic()->market(), analytic()->configurations().simMarketParams, Market::defaultConfiguration,
122 *analytic()->configurations().curveConfig, *analytic()->configurations().todaysMarketParams, true, false,
123 false, false, *inputs_->iborFallbackConfig());
124 simMarket->scenarioGenerator() = scenarios;
125 scenarios->baseScenario() = simMarket->baseScenario();
126
127 QuantLib::ext::shared_ptr<ScenarioShiftCalculator> shiftCalculator = QuantLib::ext::make_shared<ScenarioShiftCalculator>(
128 analytic()->configurations().sensiScenarioData, analytic()->configurations().simMarketParams);
129
130 std::unique_ptr<MarketRiskReport::SensiRunArgs> sensiArgs =
131 std::make_unique<MarketRiskReport::SensiRunArgs>(ss, shiftCalculator, 0.01, inputs_->covarianceData());
132
133 varReport_ = ext::make_shared<ParametricVarReport>(
134 inputs_->baseCurrency(), analytic()->portfolio(), inputs_->portfolioFilter(), scenarios,
135 inputs_->varQuantiles(), varParams,
136 inputs_->salvageCovariance(), benchmarkVarPeriod, std::move(sensiArgs), inputs_->varBreakDown());
137 }
138}
virtual QuantLib::ext::shared_ptr< SensitivityStream > sensiStream(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader)
Definition: varanalytic.hpp:65
QuantLib::ext::shared_ptr< VarReport > varReport_
Definition: varanalytic.hpp:43
static const string defaultConfiguration
#define LOG(text)
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)
+ Here is the call graph for this function:

Member Data Documentation

◆ LABEL

constexpr const char* LABEL = "PARAMETRIC_VAR"
staticconstexpr

Definition at line 58 of file varanalytic.hpp.