@@ -111,10 +111,8 @@ SimmCalculator::SimmCalculator(const SimmNetSensitivities& simmNetSensitivities,
111111 if (!quiet_) {
112112 LOG (" SimmCalculator: Splitting up original CRIF records into their respective collect/post regulations" );
113113 }
114- for (const CrifRecord& crifRecord : simmNetSensitivities_) {
115- addCrifRecord (crifRecord, SimmSide::Call, enforceIMRegulations);
116- addCrifRecord (crifRecord, SimmSide::Post, enforceIMRegulations);
117- }
114+ for (const CrifRecord& crifRecord : simmNetSensitivities_)
115+ addCrifRecord (crifRecord, enforceIMRegulations);
118116
119117 // Some additional processing depending on the regulations applicable to each netting set
120118 for (auto & sv : regSensitivities_) {
@@ -1657,34 +1655,34 @@ void SimmCalculator::add(const NettingSetDetails& nettingSetDetails, const strin
16571655 add (nettingSetDetails, regulation, pc, rc, mt, kv.first , kv.second , side, overwrite);
16581656}
16591657
1660- void SimmCalculator::addCrifRecord (const CrifRecord& crifRecord, const SimmSide& side,
1661- const bool enforceIMRegulations) {
1662-
1663- const NettingSetDetails& nettingSetDetails = crifRecord.nettingSetDetails ;
1664-
1665- bool collectRegsIsEmpty = false ;
1666- bool postRegsIsEmpty = false ;
1667- if (collectRegsIsEmpty_.find (crifRecord.nettingSetDetails ) != collectRegsIsEmpty_.end ())
1668- collectRegsIsEmpty = collectRegsIsEmpty_.at (crifRecord.nettingSetDetails );
1669- if (postRegsIsEmpty_.find (crifRecord.nettingSetDetails ) != postRegsIsEmpty_.end ())
1670- postRegsIsEmpty = postRegsIsEmpty_.at (crifRecord.nettingSetDetails );
1671-
1672- string regsString;
1673- if (enforceIMRegulations)
1674- regsString = side == SimmSide::Call ? crifRecord.collectRegulations : crifRecord.postRegulations ;
1675- set<string> regs = parseRegulationString (regsString);
1676-
1677- auto newCrifRecord = crifRecord;
1678- newCrifRecord.collectRegulations .clear ();
1679- newCrifRecord.postRegulations .clear ();
1680- for (const string& r : regs)
1681- if (r == " Excluded" ||
1682- (r == " Unspecified" && enforceIMRegulations && !(collectRegsIsEmpty && postRegsIsEmpty))) {
1683- continue ;
1684- } else if (r != " Excluded" ) {
1685- // Keep a record of trade IDs for each regulation
1686- if (!newCrifRecord.isSimmParameter ())
1687- tradeIds_[side][nettingSetDetails][r].insert (newCrifRecord.tradeId );
1658+ void SimmCalculator::addCrifRecord (const CrifRecord& crifRecord, const bool enforceIMRegulations) {
1659+
1660+ for ( const auto & side : {SimmSide::Call, SimmSide::Post}) {
1661+ const NettingSetDetails& nettingSetDetails = crifRecord.nettingSetDetails ;
1662+
1663+ bool collectRegsIsEmpty = false ;
1664+ bool postRegsIsEmpty = false ;
1665+ if (collectRegsIsEmpty_.find (crifRecord.nettingSetDetails ) != collectRegsIsEmpty_.end ())
1666+ collectRegsIsEmpty = collectRegsIsEmpty_.at (crifRecord.nettingSetDetails );
1667+ if (postRegsIsEmpty_.find (crifRecord.nettingSetDetails ) != postRegsIsEmpty_.end ())
1668+ postRegsIsEmpty = postRegsIsEmpty_.at (crifRecord.nettingSetDetails );
1669+
1670+ string regsString;
1671+ if (enforceIMRegulations)
1672+ regsString = side == SimmSide::Call ? crifRecord.collectRegulations : crifRecord.postRegulations ;
1673+ set<string> regs = parseRegulationString (regsString);
1674+
1675+ auto newCrifRecord = crifRecord;
1676+ newCrifRecord.collectRegulations .clear ();
1677+ newCrifRecord.postRegulations .clear ();
1678+ for (const string& r : regs)
1679+ if (r == " Excluded" ||
1680+ (r == " Unspecified" && enforceIMRegulations && !(collectRegsIsEmpty && postRegsIsEmpty))) {
1681+ continue ;
1682+ } else if (r != " Excluded" ) {
1683+ // Keep a record of trade IDs for each regulation
1684+ if (!newCrifRecord.isSimmParameter ())
1685+ tradeIds_[side][nettingSetDetails][r].insert (newCrifRecord.tradeId );
16881686
16891687 // Add CRIF record to the appropriate regulations
16901688 if (regSensitivities_[side][nettingSetDetails][r] == nullptr ) {
@@ -1693,12 +1691,13 @@ void SimmCalculator::addCrifRecord(const CrifRecord& crifRecord, const SimmSide&
16931691 regSensitivities_[side][nettingSetDetails][r] = boost::make_shared<CrifLoader>(simmConfiguration_, CrifRecord::additionalHeaders, true , aggregateTrades);
16941692 }
16951693
1696- // We make sure to ignore amountCcy when aggregating the records, since we will only be using amountUsd,
1697- // and we may have CRIF records that are equal everywhere except for the amountCcy, and this will fail
1698- // in the case of Risk_XCcyBasis and Risk_Inflation.
1699- const bool onDiffAmountCcy = true ;
1700- regSensitivities_[side][nettingSetDetails][r]->add (newCrifRecord, onDiffAmountCcy);
1701- }
1694+ // We make sure to ignore amountCcy when aggregating the records, since we will only be using amountUsd,
1695+ // and we may have CRIF records that are equal everywhere except for the amountCcy, and this will fail
1696+ // in the case of Risk_XCcyBasis and Risk_Inflation.
1697+ const bool onDiffAmountCcy = true ;
1698+ regSensitivities_[side][nettingSetDetails][r]->add (newCrifRecord, onDiffAmountCcy);
1699+ }
1700+ }
17021701}
17031702
17041703Real SimmCalculator::lambda (Real theta) const {
0 commit comments