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

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

+ Inheritance diagram for SimmAnalyticImpl:
+ Collaboration diagram for SimmAnalyticImpl:

Public Member Functions

 SimmAnalyticImpl (const QuantLib::ext::shared_ptr< InputParameters > &inputs)
 
void runAnalytic (const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const std::set< std::string > &runTypes={}) override
 
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 = "SIMM"
 

Additional Inherited Members

- 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 30 of file simmanalytic.hpp.

Constructor & Destructor Documentation

◆ SimmAnalyticImpl()

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

Definition at line 34 of file simmanalytic.hpp.

34 : Analytic::Impl(inputs) {
36 }
void setLabel(const string &label)
Definition: analytic.hpp:189
static constexpr const char * LABEL
+ Here is the call graph for this function:

Member Function Documentation

◆ runAnalytic()

void runAnalytic ( const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &  loader,
const std::set< std::string > &  runTypes = {} 
)
overridevirtual

Implements Analytic::Impl.

Definition at line 34 of file simmanalytic.cpp.

35 {
36 if (!analytic()->match(runTypes))
37 return;
38
39 LOG("SimmAnalytic::runAnalytic called");
40
41 analytic()->buildMarket(loader, false);
42
43 auto simmAnalytic = static_cast<SimmAnalytic*>(analytic());
44 QL_REQUIRE(simmAnalytic, "Analytic must be of type SimmAnalytic");
45
46 LOG("Get CRIF records from CRIF loader and fill amountUSD");
47 simmAnalytic->loadCrifRecords(loader);
48
49 if (analytic()->getWriteIntermediateReports()) {
50 QuantLib::ext::shared_ptr<InMemoryReport> crifReport = QuantLib::ext::make_shared<InMemoryReport>();
51 ReportWriter(inputs_->reportNaString()).writeCrifReport(crifReport, simmAnalytic->crif());
52 analytic()->reports()[LABEL]["crif"] = crifReport;
53 LOG("CRIF report generated");
54
55 Crif simmDataCrif = simmAnalytic->crif().aggregate();
56 QuantLib::ext::shared_ptr<InMemoryReport> simmDataReport = QuantLib::ext::make_shared<InMemoryReport>();
57 ReportWriter(inputs_->reportNaString())
58 .writeSIMMData(simmAnalytic->crif(), simmDataReport);
59 analytic()->reports()[LABEL]["simm_data"] = simmDataReport;
60 LOG("SIMM data report generated");
61 }
62 MEM_LOG;
63
64 LOG("Calculating SIMM");
65
66 // Save SIMM calibration data to output
67 if (inputs_->simmCalibrationData())
68 inputs_->simmCalibrationData()->toFile((inputs_->resultsPath() / "simmcalibration.xml").string());
69
70 auto simmConfig = inputs_->getSimmConfiguration();
71 simmConfig->bucketMapper()->updateFromCrif(simmAnalytic->crif());
72
73 // Calculate SIMM
74 auto simm = QuantLib::ext::make_shared<SimmCalculator>(simmAnalytic->crif(),
75 simmConfig,
76 inputs_->simmCalculationCurrencyCall(),
77 inputs_->simmCalculationCurrencyPost(),
78 inputs_->simmResultCurrency(),
79 analytic()->market(),
80 simmAnalytic->determineWinningRegulations(),
81 inputs_->enforceIMRegulations());
82
83 Real fxSpot = 1.0;
84 if (!inputs_->simmReportingCurrency().empty()) {
85 fxSpot = analytic()->market()
86 ->fxRate(inputs_->simmResultCurrency() + inputs_->simmReportingCurrency())
87 ->value();
88 LOG("SIMM reporting currency is " << inputs_->simmReportingCurrency() << " with fxSpot " << fxSpot);
89 }
90
91 QuantLib::ext::shared_ptr<InMemoryReport> simmRegulationBreakdownReport = QuantLib::ext::make_shared<InMemoryReport>();
92 ReportWriter(inputs_->reportNaString())
93 .writeSIMMReport(simm->simmResults(), simmRegulationBreakdownReport, simmAnalytic->hasNettingSetDetails(),
94 inputs_->simmResultCurrency(), inputs_->simmCalculationCurrencyCall(),
95 inputs_->simmCalculationCurrencyPost(), inputs_->simmReportingCurrency(), false, fxSpot);
96 LOG("SIMM regulation breakdown report generated");
97 analytic()->reports()[LABEL]["regulation_breakdown_simm"] = simmRegulationBreakdownReport;
98
99
100 QuantLib::ext::shared_ptr<InMemoryReport> simmReport = QuantLib::ext::make_shared<InMemoryReport>();
101 ReportWriter(inputs_->reportNaString())
102 .writeSIMMReport(simm->finalSimmResults(), simmReport, simmAnalytic->hasNettingSetDetails(),
103 inputs_->simmResultCurrency(), inputs_->simmCalculationCurrencyCall(),
104 inputs_->simmCalculationCurrencyPost(), inputs_->simmReportingCurrency(), fxSpot);
105 analytic()->reports()[LABEL]["simm"] = simmReport;
106 LOG("SIMM report generated");
107 MEM_LOG;
108
109}
Analytic * analytic() const
Definition: analytic.hpp:193
QuantLib::ext::shared_ptr< InputParameters > inputs_
Definition: analytic.hpp:216
analytic_reports & reports()
Result reports.
Definition: analytic.hpp:131
virtual void buildMarket(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const bool marketRequired=true)
Definition: analytic.cpp:178
const QuantLib::ext::shared_ptr< ore::data::Market > & market() const
Definition: analytic.hpp:117
#define MEM_LOG
#define LOG(text)
+ Here is the call graph for this function:

◆ setUpConfigurations()

void setUpConfigurations ( )
overridevirtual

Reimplemented from Analytic::Impl.

Definition at line 30 of file simmanalytic.cpp.

30 {
31 analytic()->configurations().todaysMarketParams = inputs_->todaysMarketParams();
32}
Configurations & configurations()
Definition: analytic.hpp:128
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > todaysMarketParams
Definition: analytic.hpp:68
+ Here is the call graph for this function:

Member Data Documentation

◆ LABEL

constexpr const char* LABEL = "SIMM"
staticconstexpr

Definition at line 32 of file simmanalytic.hpp.