24using namespace boost::filesystem;
30 QL_REQUIRE(
inputs_,
"Inputs not set");
31 QL_REQUIRE(!
inputs_->crif().empty(),
"CRIF loader does not contain any records");
38 map<string, bool> hasSECCache, hasCFTCCache;
43 const string& crifRegs = side == SimmConfiguration::SimmSide::Call ? cr.collectRegulations : cr.postRegulations;
44 for (
const string& reg : {
"SEC",
"CFTC"}) {
45 map<string, bool>& regCache = reg ==
"SEC" ? hasSECCache : hasCFTCCache;
48 if (hasRegMap[side].find(nsd) == hasRegMap[side].end()) {
50 if (regCache.find(crifRegs) != regCache.end()) {
51 hasReg = regCache.at(crifRegs);
54 hasReg = regs.find(reg) != regs.end();
55 regCache[crifRegs] = hasReg;
58 hasRegMap[side].insert(nsd);
66 const std::set<std::string>& runTypes) {
71 LOG(
"IMScheduleAnalytic::runAnalytic called");
76 QL_REQUIRE(imAnalytic,
"Analytic must be of type IMScheduleAnalytic");
79 imAnalytic->loadCrifRecords(loader);
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);
89 Real fxSpotReport = 1.0;
90 if (!
inputs_->simmReportingCurrency().empty()) {
93 ->fxRate(
inputs_->simmResultCurrency() +
inputs_->simmReportingCurrency())
95 DLOG(
"SIMM reporting currency is " <<
inputs_->simmReportingCurrency() <<
" with fxSpot "
99 QuantLib::ext::shared_ptr<InMemoryReport> imScheduleSummaryReport = QuantLib::ext::make_shared<InMemoryReport>();
100 QuantLib::ext::shared_ptr<InMemoryReport> imScheduleTradeReport = QuantLib::ext::make_shared<InMemoryReport>();
103 LOG(
"Generating Schedule IM reports")
106 imAnalytic->hasNettingSetDetails());
111 imAnalytic->hasNettingSetDetails(),
inputs_->simmResultCurrency(),
112 inputs_->simmReportingCurrency(), fxSpotReport);
114 LOG(
"Schedule IM reports generated");
117 analytic()->
reports()[
"IM_SCHEDULE"][
"im_schedule"] = imScheduleSummaryReport;
118 analytic()->
reports()[
"IM_SCHEDULE"][
"im_schedule_trade"] = imScheduleTradeReport;
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
QuantLib::ext::shared_ptr< InputParameters > inputs_
contains all the input parameters for the run
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)
std::map< SimmConfiguration::SimmSide, std::set< ore::data::NettingSetDetails > > hasSEC_
virtual void loadCrifRecords(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader)
Load CRIF from external source, override to generate CRIF from the input portfolio.
std::map< SimmConfiguration::SimmSide, std::set< ore::data::NettingSetDetails > > hasCFTC_
bool hasNettingSetDetails_
void runAnalytic(const QuantLib::ext::shared_ptr< ore::data::InMemoryLoader > &loader, const std::set< std::string > &runTypes={}) override
Write ORE outputs to reports.
virtual void writeIMScheduleTradeReport(const std::map< std::string, std::vector< IMScheduleCalculator::IMScheduleTradeData > > &tradeResults, const QuantLib::ext::shared_ptr< ore::data::Report > report, const bool hasNettingSetDetails=false)
virtual void writeIMScheduleSummaryReport(const std::map< SimmConfiguration::SimmSide, std::map< NettingSetDetails, std::pair< std::string, IMScheduleResults > > > &finalResultsMap, const QuantLib::ext::shared_ptr< Report > report, const bool hasNettingSetDetails=false, const std::string &simmResultCcy="", const std::string &reportCcy="", QuantLib::Real fxSpot=1.0, QuantLib::Real outputThreshold=0.005)
SimmSide
Enum indicating the relevant side of the SIMM calculation.
ORE IM Schedule Analytic.
set< string > parseRegulationString(const string ®sString, const set< string > &valueIfEmpty)
Reads a string containing regulations applicable for a given CRIF record.
A Class to write ORE outputs to reports.
SIMM configuration interface.