66 {
67
69 return;
70
71 LOG(
"IMScheduleAnalytic::runAnalytic called");
72
74
75 auto imAnalytic =
static_cast<IMScheduleAnalytic*
>(
analytic());
76 QL_REQUIRE(imAnalytic, "Analytic must be of type IMScheduleAnalytic");
77
78
79 imAnalytic->loadCrifRecords(loader);
80
81
82 LOG(
"Calculating Schedule IM")
83 auto imSchedule =
QuantLib::ext::make_shared<IMScheduleCalculator>(
84 imAnalytic->crif(),
inputs_->simmResultCurrency(),
analytic()->market(),
85 true,
inputs_->enforceIMRegulations(), false, imAnalytic->hasSEC(),
86 imAnalytic->hasCFTC());
87 imAnalytic->setImSchedule(imSchedule);
88
89 Real fxSpotReport = 1.0;
90 if (!
inputs_->simmReportingCurrency().empty()) {
93 ->fxRate(
inputs_->simmResultCurrency() +
inputs_->simmReportingCurrency())
94 ->value();
95 DLOG(
"SIMM reporting currency is " <<
inputs_->simmReportingCurrency() <<
" with fxSpot "
96 << fxSpotReport);
97 }
98
99 QuantLib::ext::shared_ptr<InMemoryReport> imScheduleSummaryReport = QuantLib::ext::make_shared<InMemoryReport>();
100 QuantLib::ext::shared_ptr<InMemoryReport> imScheduleTradeReport = QuantLib::ext::make_shared<InMemoryReport>();
101
102
103 LOG(
"Generating Schedule IM reports")
104 ore::analytics::ReportWriter(
inputs_->reportNaString())
105 .writeIMScheduleTradeReport(imSchedule->imScheduleTradeResults(), imScheduleTradeReport,
106 imAnalytic->hasNettingSetDetails());
107
108
109 ore::analytics::ReportWriter(
inputs_->reportNaString())
110 .writeIMScheduleSummaryReport(imSchedule->finalImScheduleSummaryResults(), imScheduleSummaryReport,
111 imAnalytic->hasNettingSetDetails(),
inputs_->simmResultCurrency(),
112 inputs_->simmReportingCurrency(), fxSpotReport);
113
114 LOG("Schedule IM reports generated");
115 MEM_LOG;
116
117 analytic()->reports()["IM_SCHEDULE"]["im_schedule"] = imScheduleSummaryReport;
118 analytic()->reports()["IM_SCHEDULE"]["im_schedule_trade"] = imScheduleTradeReport;
119}
Analytic * analytic() const
QuantLib::ext::shared_ptr< InputParameters > inputs_
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