25using namespace boost::filesystem;
35 const std::set<std::string>& runTypes) {
39 LOG(
"SimmAnalytic::runAnalytic called");
44 QL_REQUIRE(simmAnalytic,
"Analytic must be of type SimmAnalytic");
46 LOG(
"Get CRIF records from CRIF loader and fill amountUSD");
47 simmAnalytic->loadCrifRecords(loader);
49 if (
analytic()->getWriteIntermediateReports()) {
50 QuantLib::ext::shared_ptr<InMemoryReport> crifReport = QuantLib::ext::make_shared<InMemoryReport>();
53 LOG(
"CRIF report generated");
56 QuantLib::ext::shared_ptr<InMemoryReport> simmDataReport = QuantLib::ext::make_shared<InMemoryReport>();
60 LOG(
"SIMM data report generated");
64 LOG(
"Calculating SIMM");
67 if (
inputs_->simmCalibrationData())
68 inputs_->simmCalibrationData()->toFile((
inputs_->resultsPath() /
"simmcalibration.xml").string());
70 auto simmConfig =
inputs_->getSimmConfiguration();
71 simmConfig->bucketMapper()->updateFromCrif(simmAnalytic->crif());
74 auto simm = QuantLib::ext::make_shared<SimmCalculator>(simmAnalytic->crif(),
76 inputs_->simmCalculationCurrencyCall(),
77 inputs_->simmCalculationCurrencyPost(),
80 simmAnalytic->determineWinningRegulations(),
81 inputs_->enforceIMRegulations());
84 if (!
inputs_->simmReportingCurrency().empty()) {
86 ->fxRate(
inputs_->simmResultCurrency() +
inputs_->simmReportingCurrency())
88 LOG(
"SIMM reporting currency is " <<
inputs_->simmReportingCurrency() <<
" with fxSpot " << fxSpot);
91 QuantLib::ext::shared_ptr<InMemoryReport> simmRegulationBreakdownReport = QuantLib::ext::make_shared<InMemoryReport>();
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");
100 QuantLib::ext::shared_ptr<InMemoryReport> simmReport = QuantLib::ext::make_shared<InMemoryReport>();
102 .
writeSIMMReport(simm->finalSimmResults(), simmReport, simmAnalytic->hasNettingSetDetails(),
103 inputs_->simmResultCurrency(),
inputs_->simmCalculationCurrencyCall(),
104 inputs_->simmCalculationCurrencyPost(),
inputs_->simmReportingCurrency(), fxSpot);
106 LOG(
"SIMM report generated");
112 QL_REQUIRE(
inputs_,
"Inputs not set");
113 QL_REQUIRE(!
inputs_->crif().empty(),
"CRIF loader does not contain any records");
Analytic * analytic() const
QuantLib::ext::shared_ptr< InputParameters > inputs_
analytic_reports & reports()
Result reports.
Configurations & configurations()
virtual void buildMarket(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const bool marketRequired=true)
const QuantLib::ext::shared_ptr< ore::data::Market > & market() const
QuantLib::ext::shared_ptr< InputParameters > inputs_
contains all the input parameters for the run
Crif aggregate() const
Aggregate all existing records.
bool hasNettingSetDetails() const
Check if netting set details are used anywhere, instead of just the netting set ID.
void fillAmountUsd(const QuantLib::ext::shared_ptr< ore::data::Market > market)
Write ORE outputs to reports.
virtual void writeSIMMReport(const std::map< SimmConfiguration::SimmSide, std::map< NettingSetDetails, std::pair< std::string, SimmResults > > > &simmResultsMap, const QuantLib::ext::shared_ptr< ore::data::Report > report, const bool hasNettingSetDetails=false, const std::string &simmResultCcy="", const std::string &simmCalcCcyCall="", const std::string &simmCalcCcyPost="", const std::string &reportCcy="", QuantLib::Real fxSpot=1.0, QuantLib::Real outputThreshold=0.005)
virtual void writeSIMMData(const ore::analytics::Crif &simmData, const QuantLib::ext::shared_ptr< ore::data::Report > &dataReport, const bool hasNettingSetDetails=false)
Write the SIMM data report i.e. the netted CRIF records used in a SIMM calculation.
virtual void writeCrifReport(const QuantLib::ext::shared_ptr< ore::data::Report > &report, const ore::analytics::Crif &crifRecords)
Write out CRIF records to a report.
virtual void loadCrifRecords(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader)
Load CRIF from external source, override to generate CRIF.
bool hasNettingSetDetails_
void setUpConfigurations() override
void runAnalytic(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const std::set< std::string > &runTypes={}) override
static constexpr const char * LABEL
A Class to write ORE outputs to reports.
Class for calculating SIMM.
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > todaysMarketParams