35 {
37 return;
38
39 LOG(
"SimmAnalytic::runAnalytic called");
40
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());
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);
60 LOG(
"SIMM data report generated");
61 }
63
64 LOG(
"Calculating SIMM");
65
66
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
74 auto simm = QuantLib::ext::make_shared<SimmCalculator>(simmAnalytic->crif(),
75 simmConfig,
76 inputs_->simmCalculationCurrencyCall(),
77 inputs_->simmCalculationCurrencyPost(),
80 simmAnalytic->determineWinningRegulations(),
81 inputs_->enforceIMRegulations());
82
83 Real fxSpot = 1.0;
84 if (!
inputs_->simmReportingCurrency().empty()) {
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");
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);
106 LOG(
"SIMM report generated");
108
109}
Analytic * analytic() const
QuantLib::ext::shared_ptr< InputParameters > inputs_
analytic_reports & reports()
Result reports.
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