Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
SimmConcentrationBase Class Reference

#include <orea/simm/simmconcentration.hpp>

+ Inheritance diagram for SimmConcentrationBase:
+ Collaboration diagram for SimmConcentrationBase:

Public Member Functions

 SimmConcentrationBase ()
 
QuantLib::Real threshold (const CrifRecord::RiskType &riskType, const std::string &qualifier) const override
 
- Public Member Functions inherited from SimmConcentration
virtual ~SimmConcentration ()
 Destructor. More...
 
virtual QuantLib::Real threshold (const CrifRecord::RiskType &riskType, const std::string &qualifier) const =0
 

Protected Member Functions

QuantLib::Real thresholdImpl (const QuantLib::ext::shared_ptr< SimmBucketMapper > &simmBucketMapper, const CrifRecord::RiskType &riskType, const std::string &qualifier) const
 
QuantLib::Real fxVolThreshold (const std::string &fxPair) const
 Return concentration threshold for Risk_FXVol given the fxPair. More...
 
std::string category (const std::string &qualifier, const std::map< std::string, std::set< std::string > > &categories) const
 Find the concentration threshold category of the qualifier. More...
 

Protected Attributes

QuantLib::Real units_
 The units of quotation of the threshold amount e.g. $1MM. More...
 
std::map< CrifRecord::RiskType, QuantLib::Real > flatThresholds_
 
std::map< CrifRecord::RiskType, std::map< std::string, QuantLib::Real > > bucketedThresholds_
 
std::map< std::string, std::set< std::string > > irCategories_
 
std::map< std::string, std::set< std::string > > fxCategories_
 
QuantLib::ext::shared_ptr< SimmBucketMappersimmBucketMapper_
 Maps SIMM qualifiers to SIMM buckets. More...
 

Detailed Description

Definition at line 47 of file simmconcentration.hpp.

Constructor & Destructor Documentation

◆ SimmConcentrationBase()

Default ctor. May need to generalise if units of threshold quotation change significantly

Definition at line 55 of file simmconcentration.hpp.

55: units_(1000000) {}
QuantLib::Real units_
The units of quotation of the threshold amount e.g. $1MM.

Member Function Documentation

◆ threshold()

QuantLib::Real threshold ( const CrifRecord::RiskType riskType,
const std::string &  qualifier 
) const
overridevirtual

Early versions of SIMM did not have concentration thresholds assigned. This base class just returns the maximum real number i.e. effectively no concentration threshold

Implements SimmConcentration.

Reimplemented in SimmConcentrationCalibration, SimmConcentration_ISDA_V1_3, SimmConcentration_ISDA_V1_3_38, SimmConcentration_ISDA_V2_0, SimmConcentration_ISDA_V2_1, SimmConcentration_ISDA_V2_2, SimmConcentration_ISDA_V2_3, SimmConcentration_ISDA_V2_3_8, SimmConcentration_ISDA_V2_5, SimmConcentration_ISDA_V2_5A, and SimmConcentration_ISDA_V2_6.

Definition at line 61 of file simmconcentration.hpp.

61 {
62 return QL_MAX_REAL;
63 }

◆ thresholdImpl()

Real thresholdImpl ( const QuantLib::ext::shared_ptr< SimmBucketMapper > &  simmBucketMapper,
const CrifRecord::RiskType riskType,
const std::string &  qualifier 
) const
protected

Shared threshold implementation for derived classes to call

Definition at line 39 of file simmconcentration.cpp.

40 {
41
42 // Deal with some specific cases first
43 if (riskType == RiskType::IRCurve || riskType == RiskType::IRVol || riskType == RiskType::FX) {
44
45 QL_REQUIRE(qualifier.size() == 3, "Expect the qualifier, " << qualifier << ", to be a valid currency code");
46 QL_REQUIRE(checkCurrency(qualifier),
47 "The qualifier, " << qualifier << ", is not a supported currency code");
48 auto cat = riskType == RiskType::FX ? category(qualifier, fxCategories_) : category(qualifier, irCategories_);
49
50 return bucketedThresholds_.at(riskType).at(cat) * units_;
51 }
52
53 if (riskType == RiskType::FXVol) {
54 return fxVolThreshold(qualifier) * units_;
55 }
56
57 // Check if the risk type's threshold is not bucket dependent and if so return the threshold
58 if (flatThresholds_.count(riskType) > 0) {
59 return flatThresholds_.at(riskType) * units_;
60 }
61
62 // Check if the risk type's threshold is bucket dependent and if so, find the bucket and return the threshold
63 if (bucketedThresholds_.count(riskType) > 0) {
64 string bucket = simmBucketMapper->bucket(riskType, qualifier);
65 bucket = bucket == "residual" ? "Residual" : bucket;
66 auto const& m = bucketedThresholds_.at(riskType);
67 auto const& t = m.find(bucket);
68 QL_REQUIRE(t != m.end(), "SimmConcentrationBase::thresholdImpl(): bucket '"
69 << bucket << "' not found in bucketedThresholds for qualifier '" << qualifier
70 << "' and risk type '" << riskType << "'");
71 return t->second * units_;
72 }
73
74 // If we get to here, no threshold
75 return QL_MAX_REAL;
76}
QuantLib::Real fxVolThreshold(const std::string &fxPair) const
Return concentration threshold for Risk_FXVol given the fxPair.
std::map< std::string, std::set< std::string > > fxCategories_
std::map< std::string, std::set< std::string > > irCategories_
std::map< CrifRecord::RiskType, std::map< std::string, QuantLib::Real > > bucketedThresholds_
std::string category(const std::string &qualifier, const std::map< std::string, std::set< std::string > > &categories) const
Find the concentration threshold category of the qualifier.
std::map< CrifRecord::RiskType, QuantLib::Real > flatThresholds_
bool checkCurrency(const string &code)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fxVolThreshold()

Real fxVolThreshold ( const std::string &  fxPair) const
protected

Return concentration threshold for Risk_FXVol given the fxPair.

Definition at line 95 of file simmconcentration.cpp.

95 {
96
97 QL_REQUIRE(fxPair.size() == 6, "Expected '" << fxPair << "' to be a currency pair so it should be of length 6.");
98
99 string ccy_1 = fxPair.substr(0, 3);
100 QL_REQUIRE(checkCurrency(ccy_1),
101 "First currency in pair " << fxPair << " (" << ccy_1 << ") is not a supported currency code");
102 string ccy_2 = fxPair.substr(3);
103 QL_REQUIRE(checkCurrency(ccy_2),
104 "Second currency in pair " << fxPair << " (" << ccy_2 << ") is not a supported currency code");
105
106 // Find category of currency 1 and currency 2
107 string category_1 = category(ccy_1, fxCategories_);
108 string category_2 = category(ccy_2, fxCategories_);
109
110 if (category_1 == "1" && category_2 == "1") {
111 // Both currencies in FX category 1
112 return bucketedThresholds_.at(RiskType::FXVol).at("1");
113 } else if ((category_1 == "1" && category_2 == "2") || (category_1 == "2" && category_2 == "1")) {
114 // One currency in FX category 1 and the other in FX category 2
115 return bucketedThresholds_.at(RiskType::FXVol).at("2");
116 } else if ((category_1 == "1" && category_2 == "3") || (category_1 == "3" && category_2 == "1")) {
117 // One currency in FX category 1 and the other in FX category 3
118 return bucketedThresholds_.at(RiskType::FXVol).at("3");
119 } else if (category_1 == "2" && category_2 == "2") {
120 // Both currencies in FX category 2
121 return bucketedThresholds_.at(RiskType::FXVol).at("4");
122 } else if ((category_1 == "2" && category_2 == "3") || (category_1 == "3" && category_2 == "2")) {
123 // One currency in FX category 2 and the other in FX category 3
124 return bucketedThresholds_.at(RiskType::FXVol).at("5");
125 } else {
126 // Both currencies in FX category 3
127 return bucketedThresholds_.at(RiskType::FXVol).at("6");
128 }
129}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ category()

string category ( const std::string &  qualifier,
const std::map< std::string, std::set< std::string > > &  categories 
) const
protected

Find the concentration threshold category of the qualifier.

Definition at line 78 of file simmconcentration.cpp.

78 {
79 string result;
80 for (const auto& kv : categories) {
81 if (kv.second.empty()) {
82 result = kv.first;
83 } else {
84 if (kv.second.count(qualifier) > 0) {
85 // Found qualifier in category so return it
86 return kv.first;
87 }
88 }
89 }
90
91 // If we get here, result should hold category with empty set
92 return result;
93}
+ Here is the caller graph for this function:

Member Data Documentation

◆ units_

QuantLib::Real units_
protected

The units of quotation of the threshold amount e.g. $1MM.

Definition at line 67 of file simmconcentration.hpp.

◆ flatThresholds_

std::map<CrifRecord::RiskType, QuantLib::Real> flatThresholds_
protected

Map from SIMM RiskType to another map that holds the SIMM concentration threshold bucket to threshold value mappings

Definition at line 72 of file simmconcentration.hpp.

◆ bucketedThresholds_

std::map<CrifRecord::RiskType, std::map<std::string, QuantLib::Real> > bucketedThresholds_
protected

Map from SIMM RiskType to another map that holds the SIMM concentration threshold bucket to threshold value mappings

Definition at line 77 of file simmconcentration.hpp.

◆ irCategories_

std::map<std::string, std::set<std::string> > irCategories_
protected

Map defining the currency groupings for IR concentration thresholds i.e. key is the category and value is the set of currencies in that category.

Definition at line 82 of file simmconcentration.hpp.

◆ fxCategories_

std::map<std::string, std::set<std::string> > fxCategories_
protected

Map defining the currency groupings for concentration thresholds i.e. key is the category and value is the set of currencies in that category.

Definition at line 87 of file simmconcentration.hpp.

◆ simmBucketMapper_

QuantLib::ext::shared_ptr<SimmBucketMapper> simmBucketMapper_
protected

Maps SIMM qualifiers to SIMM buckets.

Definition at line 90 of file simmconcentration.hpp.