Skip to content

Commit c096d23

Browse files
NathanielVolfangojenkins
authored andcommitted
QPR-11933 -- SEC and CFTC not being handled correctly in SIMM Calculator aggregation
1 parent e8817fd commit c096d23

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

OREAnalytics/orea/simm/simmcalculator.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ SimmCalculator::SimmCalculator(const SimmNetSensitivities& simmNetSensitivities,
122122
for (auto& s : sv.second) {
123123
// Where there is SEC and CFTC in the portfolio, we add the CFTC trades to SEC,
124124
// but still continue with CFTC calculations
125-
const bool hasCFTC = s.second.count("CFTC") > 0;
126-
const bool hasSEC = s.second.count("SEC") > 0;
125+
const bool hasCFTC = s.second.find("CFTC") != s.second.end();
126+
const bool hasSEC = s.second.find("SEC") != s.second.end();
127127
if (hasCFTC && hasSEC) {
128128
const SimmNetSensitivities& netRecordsCFTC = s.second.at("CFTC")->netRecords(true);
129129
const SimmNetSensitivities& netRecordsSEC = s.second.at("SEC")->netRecords(true);
@@ -139,6 +139,11 @@ SimmCalculator::SimmCalculator(const SimmNetSensitivities& simmNetSensitivities,
139139
}
140140
}
141141
}
142+
// The CrifLoader was set initially without aggregation, so make sure to aggregate this now
143+
if (hasCFTC)
144+
s.second.at("CFTC")->aggregate();
145+
if (hasSEC)
146+
s.second.at("SEC")->aggregate();
142147

143148
// If netting set has "Unspecified" plus other regulations, the "Unspecified" sensis are to be excluded.
144149
// If netting set only has "Unspecified", then no regulations were ever specified, so all trades are
@@ -1682,8 +1687,11 @@ void SimmCalculator::addCrifRecord(const CrifRecord& crifRecord, const SimmSide&
16821687
tradeIds_[side][nettingSetDetails][r].insert(newCrifRecord.tradeId);
16831688

16841689
// Add CRIF record to the appropriate regulations
1685-
if (regSensitivities_[side][nettingSetDetails][r] == nullptr)
1686-
regSensitivities_[side][nettingSetDetails][r] = boost::make_shared<CrifLoader>(simmConfiguration_, CrifRecord::additionalHeaders, true, true);
1690+
if (regSensitivities_[side][nettingSetDetails][r] == nullptr) {
1691+
// We aggregate SEC/CFTC CRIF records later because we do not want to lose trade ID data until we have combined these later.
1692+
const bool aggregateTrades = r == "SEC" || r == "CFTC" ? false : true;
1693+
regSensitivities_[side][nettingSetDetails][r] = boost::make_shared<CrifLoader>(simmConfiguration_, CrifRecord::additionalHeaders, true, aggregateTrades);
1694+
}
16871695

16881696
// We make sure to ignore amountCcy when aggregating the records, since we will only be using amountUsd,
16891697
// and we may have CRIF records that are equal everywhere except for the amountCcy, and this will fail

0 commit comments

Comments
 (0)