A class to calculate SIMM given a set of aggregated CRIF results for one or more portfolios. More...
#include <orea/simm/simmcalculator.hpp>
Public Types | |
typedef SimmConfiguration::SimmSide | SimmSide |
Public Member Functions | |
SimmCalculator (const ore::analytics::Crif &crif, const QuantLib::ext::shared_ptr< SimmConfiguration > &simmConfiguration, const std::string &calculationCcyCall="USD", const std::string &calculationCcyPost="USD", const std::string &resultCcy="", const QuantLib::ext::shared_ptr< ore::data::Market > market=nullptr, const bool determineWinningRegulations=true, const bool enforceIMRegulations=false, const bool quiet=false, const std::map< SimmSide, std::set< NettingSetDetails > > &hasSEC=std::map< SimmSide, std::set< NettingSetDetails > >(), const std::map< SimmSide, std::set< NettingSetDetails > > &hasCFTC=std::map< SimmSide, std::set< NettingSetDetails > >()) | |
const void | calculateRegulationSimm (const ore::analytics::Crif &crif, const ore::data::NettingSetDetails &nsd, const string ®ulation, const SimmSide &side) |
Calculates SIMM for a given regulation under a given netting set. More... | |
const std::string & | winningRegulations (const SimmSide &side, const ore::data::NettingSetDetails &nettingSetDetails) const |
Return the winning regulation for each netting set. More... | |
const std::map< ore::data::NettingSetDetails, string > & | winningRegulations (const SimmSide &side) const |
const std::map< SimmSide, std::map< ore::data::NettingSetDetails, string > > & | winningRegulations () const |
const SimmResults & | simmResults (const SimmSide &side, const ore::data::NettingSetDetails &nettingSetDetails, const std::string ®ulation) const |
Give back the SIMM results container for the given portfolioId and SIMM side. More... | |
const std::map< std::string, SimmResults > & | simmResults (const SimmSide &side, const ore::data::NettingSetDetails &nettingSetDetails) const |
const std::map< ore::data::NettingSetDetails, std::map< std::string, SimmResults > > & | simmResults (const SimmSide &side) const |
const std::map< SimmSide, std::map< ore::data::NettingSetDetails, std::map< std::string, SimmResults > > > & | simmResults () const |
const std::pair< std::string, SimmResults > & | finalSimmResults (const SimmSide &side, const ore::data::NettingSetDetails &nettingSetDetails) const |
Give back the SIMM results container for the given netting set and SIMM side. More... | |
const std::map< ore::data::NettingSetDetails, std::pair< std::string, SimmResults > > & | finalSimmResults (const SimmSide &side) const |
const std::map< SimmSide, std::map< ore::data::NettingSetDetails, std::pair< std::string, SimmResults > > > & | finalSimmResults () const |
const std::map< SimmSide, std::set< std::string > > & | finalTradeIds () const |
const Crif & | simmParameters () const |
const std::string & | calculationCurrency (const SimmSide &side) const |
Return the calculator's calculation currency. More... | |
const std::string & | resultCurrency () const |
Return the calculator's result currency. More... | |
void | populateFinalResults (const std::map< SimmSide, std::map< ore::data::NettingSetDetails, std::string > > &winningRegulations) |
Private Member Functions | |
std::pair< std::map< std::string, QuantLib::Real >, bool > | irDeltaMargin (const ore::data::NettingSetDetails &nettingSetDetails, const CrifRecord::ProductClass &pc, const ore::analytics::Crif &netRecords, const SimmSide &side) const |
Calculate the Interest Rate delta margin component for the given portfolio and product class. More... | |
std::pair< std::map< std::string, QuantLib::Real >, bool > | irVegaMargin (const ore::data::NettingSetDetails &nettingSetDetails, const CrifRecord::ProductClass &pc, const ore::analytics::Crif &netRecords, const SimmSide &side) const |
Calculate the Interest Rate vega margin component for the given portfolio and product class. More... | |
std::pair< std::map< std::string, QuantLib::Real >, bool > | irCurvatureMargin (const ore::data::NettingSetDetails &nettingSetDetails, const CrifRecord::ProductClass &pc, const SimmSide &side, const ore::analytics::Crif &crif) const |
Calculate the Interest Rate curvature margin component for the given portfolio and product class. More... | |
std::pair< std::map< std::string, QuantLib::Real >, bool > | margin (const ore::data::NettingSetDetails &nettingSetDetails, const CrifRecord::ProductClass &pc, const CrifRecord::RiskType &rt, const ore::analytics::Crif &netRecords, const SimmSide &side) const |
std::pair< std::map< std::string, QuantLib::Real >, bool > | curvatureMargin (const ore::data::NettingSetDetails &nettingSetDetails, const CrifRecord::ProductClass &pc, const CrifRecord::RiskType &rt, const SimmSide &side, const ore::analytics::Crif &netRecords, bool rfLabels=true) const |
void | calcAddMargin (const SimmSide &side, const ore::data::NettingSetDetails &nsd, const string ®ulation, const ore::analytics::Crif &netRecords) |
Calculate the additional initial margin for the portfolio ID and regulation. More... | |
void | populateResults (const SimmSide &side, const ore::data::NettingSetDetails &nsd, const string ®ulation) |
void | populateFinalResults () |
void | add (const ore::data::NettingSetDetails &nettingSetDetails, const string ®ulation, const CrifRecord::ProductClass &pc, const SimmConfiguration::RiskClass &rc, const SimmConfiguration::MarginType &mt, const std::string &b, QuantLib::Real margin, SimmSide side, const bool overwrite=true) |
void | add (const ore::data::NettingSetDetails &nettingSetDetails, const string ®ulation, const CrifRecord::ProductClass &pc, const SimmConfiguration::RiskClass &rc, const SimmConfiguration::MarginType &mt, const std::map< std::string, QuantLib::Real > &margins, SimmSide side, const bool overwrite=true) |
void | splitCrifByRegulationsAndPortfolios (const Crif &crif, const bool enforceIMRegulations) |
Add CRIF record to the CRIF records container that correspondsd to the given regulation/s and portfolio ID. More... | |
QuantLib::Real | lambda (QuantLib::Real theta) const |
Give the \(\lambda\) used in the curvature margin calculation. More... | |
std::set< std::string > | getQualifiers (const Crif &crif, const ore::data::NettingSetDetails &nettingSetDetails, const CrifRecord::ProductClass &pc, const std::vector< CrifRecord::RiskType > &riskTypes) const |
Private Attributes | |
ore::analytics::Crif | crif_ |
All the net sensitivities passed in for the calculation. More... | |
std::map< SimmSide, std::map< ore::data::NettingSetDetails, std::map< std::string, Crif > > > | regSensitivities_ |
Net sentivities at the regulation level within each netting set. More... | |
ore::analytics::Crif | simmParameters_ |
Record of SIMM parameters that were used in the calculation. More... | |
QuantLib::ext::shared_ptr< SimmConfiguration > | simmConfiguration_ |
The SIMM configuration governing the calculation. More... | |
std::string | calculationCcyCall_ |
The SIMM exposure calculation currency i.e. the currency for which FX delta risk is ignored. More... | |
std::string | calculationCcyPost_ |
std::string | resultCcy_ |
The SIMM result currency i.e. the currency in which the main SIMM results are denominated. More... | |
QuantLib::ext::shared_ptr< ore::data::Market > | market_ |
Market data for FX rates to use for converting amounts to USD. More... | |
bool | quiet_ |
If true, no logging is written out. More... | |
std::map< SimmSide, std::set< NettingSetDetails > > | hasSEC_ |
std::map< SimmSide, std::set< NettingSetDetails > > | hasCFTC_ |
std::map< ore::data::NettingSetDetails, bool > | collectRegsIsEmpty_ |
For each netting set, whether all CRIF records' collect regulations are empty. More... | |
std::map< ore::data::NettingSetDetails, bool > | postRegsIsEmpty_ |
For each netting set, whether all CRIF records' post regulations are empty. More... | |
std::map< SimmSide, std::map< ore::data::NettingSetDetails, std::string > > | winningRegulations_ |
Regulation with highest initial margin for each given netting set. More... | |
std::map< SimmSide, std::map< ore::data::NettingSetDetails, std::map< std::string, SimmResults > > > | simmResults_ |
std::map< SimmSide, std::map< ore::data::NettingSetDetails, std::pair< std::string, SimmResults > > > | finalSimmResults_ |
std::map< SimmSide, std::map< ore::data::NettingSetDetails, std::map< std::string, set< string > > > > | tradeIds_ |
Container for keeping track of what trade IDs belong to each regulation. More... | |
std::map< SimmSide, set< string > > | finalTradeIds_ |
A class to calculate SIMM given a set of aggregated CRIF results for one or more portfolios.
Definition at line 36 of file simmcalculator.hpp.
typedef SimmConfiguration::SimmSide SimmSide |
Definition at line 38 of file simmcalculator.hpp.
SimmCalculator | ( | const ore::analytics::Crif & | crif, |
const QuantLib::ext::shared_ptr< SimmConfiguration > & | simmConfiguration, | ||
const std::string & | calculationCcyCall = "USD" , |
||
const std::string & | calculationCcyPost = "USD" , |
||
const std::string & | resultCcy = "" , |
||
const QuantLib::ext::shared_ptr< ore::data::Market > | market = nullptr , |
||
const bool | determineWinningRegulations = true , |
||
const bool | enforceIMRegulations = false , |
||
const bool | quiet = false , |
||
const std::map< SimmSide, std::set< NettingSetDetails > > & | hasSEC = std::map<SimmSide, std::set<NettingSetDetails>>() , |
||
const std::map< SimmSide, std::set< NettingSetDetails > > & | hasCFTC = std::map<SimmSide, std::set<NettingSetDetails>>() |
||
) |
Construct the SimmCalculator from a container of netted CRIF records and a SIMM configuration. The SIMM number is initially calculated in USD using the AmountUSD column. It can optionally be converted to a calculation currency other than USD by using the calculationCcy
parameter. If the calculationCcy
is not USD then the usdSpot
parameter must be used to give the FX spot rate between USD and the calculationCcy
. This spot rate is interpreted as the number of USD per unit of calculationCcy
.
Definition at line 65 of file simmcalculator.cpp.
const void calculateRegulationSimm | ( | const ore::analytics::Crif & | crif, |
const ore::data::NettingSetDetails & | nsd, | ||
const string & | regulation, | ||
const SimmSide & | side | ||
) |
Calculates SIMM for a given regulation under a given netting set.
Definition at line 251 of file simmcalculator.cpp.
const string & winningRegulations | ( | const SimmSide & | side, |
const ore::data::NettingSetDetails & | nettingSetDetails | ||
) | const |
Return the winning regulation for each netting set.
Definition at line 379 of file simmcalculator.cpp.
const map< NettingSetDetails, string > & winningRegulations | ( | const SimmSide & | side | ) | const |
Definition at line 387 of file simmcalculator.cpp.
const map< SimmSide, map< NettingSetDetails, string > > & winningRegulations | ( | ) | const |
const SimmResults & simmResults | ( | const SimmSide & | side, |
const ore::data::NettingSetDetails & | nettingSetDetails, | ||
const std::string & | regulation | ||
) | const |
Give back the SIMM results container for the given portfolioId and SIMM side.
Definition at line 397 of file simmcalculator.cpp.
const map< string, SimmResults > & simmResults | ( | const SimmSide & | side, |
const ore::data::NettingSetDetails & | nettingSetDetails | ||
) | const |
Definition at line 406 of file simmcalculator.cpp.
const map< NettingSetDetails, map< string, SimmResults > > & simmResults | ( | const SimmSide & | side | ) | const |
Give back a map containing the SIMM results containers for every portfolio for the given SIMM side
. The key is the portfolio ID and the value is the SIMM results container for that portfolio.
Definition at line 415 of file simmcalculator.cpp.
const map< SimmSide, map< NettingSetDetails, map< string, SimmResults > > > & simmResults | ( | ) | const |
const pair< string, SimmResults > & finalSimmResults | ( | const SimmSide & | side, |
const ore::data::NettingSetDetails & | nettingSetDetails | ||
) | const |
Give back the SIMM results container for the given netting set and SIMM side.
Definition at line 425 of file simmcalculator.cpp.
const map< NettingSetDetails, pair< string, SimmResults > > & finalSimmResults | ( | const SimmSide & | side | ) | const |
Give back a map containing the SIMM results containers for every portfolio for the given SIMM side
. The key is the portfolio ID and the value is a map, with regulation as the key, and the value is the SIMM results container for that portfolioId-regulation combination.
Definition at line 434 of file simmcalculator.cpp.
const map< SimmSide, map< NettingSetDetails, pair< string, SimmResults > > > & finalSimmResults | ( | ) | const |
const std::map< SimmSide, std::set< std::string > > & finalTradeIds | ( | ) | const |
Definition at line 93 of file simmcalculator.hpp.
const Crif & simmParameters | ( | ) | const |
Definition at line 95 of file simmcalculator.hpp.
const std::string & calculationCurrency | ( | const SimmSide & | side | ) | const |
Return the calculator's calculation currency.
Definition at line 98 of file simmcalculator.hpp.
const std::string & resultCurrency | ( | ) | const |
void populateFinalResults | ( | const std::map< SimmSide, std::map< ore::data::NettingSetDetails, std::string > > & | winningRegulations | ) |
Populate the finalSimmResults_ and finalAddMargins_ containers using the provided map of winning call/post regulations.
|
private |
Calculate the Interest Rate delta margin component for the given portfolio and product class.
Definition at line 444 of file simmcalculator.cpp.
|
private |
Calculate the Interest Rate vega margin component for the given portfolio and product class.
Definition at line 615 of file simmcalculator.cpp.
|
private |
Calculate the Interest Rate curvature margin component for the given portfolio and product class.
Definition at line 751 of file simmcalculator.cpp.
|
private |
Calculate the (delta or vega) margin component for the given portfolio, product class and risk type Used to calculate delta or vega or base correlation margin for all risk types except IR, IRVol (and by association, Inflation, XccyBasis and InflationVol)
Definition at line 886 of file simmcalculator.cpp.
|
private |
Calculate the curvature margin component for the given portfolio, product class and risk type Used to calculate curvature margin for all risk types except IR
Definition at line 1076 of file simmcalculator.cpp.
|
private |
Calculate the additional initial margin for the portfolio ID and regulation.
Definition at line 1236 of file simmcalculator.cpp.
|
private |
Populate the results structure with the higher level results after the IMs have been calculated at the (product class, risk class, margin type) level for the given regulation under the given portfolio
Definition at line 1351 of file simmcalculator.cpp.
|
private |
Populate final (i.e. winning regulators') using own list of winning regulators, which were determined solely by the SIMM results (i.e. not including any external IMSchedule results)
Definition at line 1595 of file simmcalculator.cpp.
|
private |
Add a margin result to either call or post results container depending on the side
parameter.
|
private |
|
private |
Add CRIF record to the CRIF records container that correspondsd to the given regulation/s and portfolio ID.
Definition at line 1620 of file simmcalculator.cpp.
|
private |
Give the \(\lambda\) used in the curvature margin calculation.
Definition at line 1659 of file simmcalculator.cpp.
|
private |
Definition at line 1667 of file simmcalculator.cpp.
|
private |
All the net sensitivities passed in for the calculation.
Definition at line 112 of file simmcalculator.hpp.
|
private |
Net sentivities at the regulation level within each netting set.
Definition at line 115 of file simmcalculator.hpp.
|
private |
Record of SIMM parameters that were used in the calculation.
Definition at line 118 of file simmcalculator.hpp.
|
private |
The SIMM configuration governing the calculation.
Definition at line 121 of file simmcalculator.hpp.
|
private |
The SIMM exposure calculation currency i.e. the currency for which FX delta risk is ignored.
Definition at line 124 of file simmcalculator.hpp.
|
private |
Definition at line 124 of file simmcalculator.hpp.
|
private |
The SIMM result currency i.e. the currency in which the main SIMM results are denominated.
Definition at line 127 of file simmcalculator.hpp.
|
private |
Market data for FX rates to use for converting amounts to USD.
Definition at line 130 of file simmcalculator.hpp.
|
private |
If true, no logging is written out.
Definition at line 133 of file simmcalculator.hpp.
|
private |
Definition at line 135 of file simmcalculator.hpp.
|
private |
Definition at line 135 of file simmcalculator.hpp.
|
private |
For each netting set, whether all CRIF records' collect regulations are empty.
Definition at line 138 of file simmcalculator.hpp.
|
private |
For each netting set, whether all CRIF records' post regulations are empty.
Definition at line 141 of file simmcalculator.hpp.
|
private |
Regulation with highest initial margin for each given netting set.
Definition at line 145 of file simmcalculator.hpp.
|
private |
Containers, one for call and post, with a map containing a SimmResults object for each regulation under each portfolio ID
Definition at line 151 of file simmcalculator.hpp.
|
private |
Containers, one for call and post, with a SimmResults object for each portfolio ID, and each margin amount is that of the winning regulation applicable to the portfolio ID
Definition at line 157 of file simmcalculator.hpp.
|
private |
Container for keeping track of what trade IDs belong to each regulation.
Definition at line 161 of file simmcalculator.hpp.
|
private |
Definition at line 163 of file simmcalculator.hpp.