23#include <ql/errors.hpp>
40 const RiskType& riskType,
const string& qualifier)
const {
43 if (riskType == RiskType::IRCurve || riskType == RiskType::IRVol || riskType == RiskType::FX) {
45 QL_REQUIRE(qualifier.size() == 3,
"Expect the qualifier, " << qualifier <<
", to be a valid currency code");
47 "The qualifier, " << qualifier <<
", is not a supported currency code");
53 if (riskType == RiskType::FXVol) {
64 string bucket = simmBucketMapper->bucket(riskType, qualifier);
65 bucket = bucket ==
"residual" ?
"Residual" : bucket;
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 <<
"'");
80 for (
const auto& kv : categories) {
81 if (kv.second.empty()) {
84 if (kv.second.count(qualifier) > 0) {
97 QL_REQUIRE(fxPair.size() == 6,
"Expected '" << fxPair <<
"' to be a currency pair so it should be of length 6.");
99 string ccy_1 = fxPair.substr(0, 3);
101 "First currency in pair " << fxPair <<
" (" << ccy_1 <<
") is not a supported currency code");
102 string ccy_2 = fxPair.substr(3);
104 "Second currency in pair " << fxPair <<
" (" << ccy_2 <<
") is not a supported currency code");
110 if (category_1 ==
"1" && category_2 ==
"1") {
113 }
else if ((category_1 ==
"1" && category_2 ==
"2") || (category_1 ==
"2" && category_2 ==
"1")) {
116 }
else if ((category_1 ==
"1" && category_2 ==
"3") || (category_1 ==
"3" && category_2 ==
"1")) {
119 }
else if (category_1 ==
"2" && category_2 ==
"2") {
122 }
else if ((category_1 ==
"2" && category_2 ==
"3") || (category_1 ==
"3" && category_2 ==
"2")) {
QuantLib::Real units_
The units of quotation of the threshold amount e.g. $1MM.
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_
QuantLib::Real thresholdImpl(const QuantLib::ext::shared_ptr< SimmBucketMapper > &simmBucketMapper, const CrifRecord::RiskType &riskType, const std::string &qualifier) const
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)
SimmConfiguration::RiskClass RiskClass
CrifRecord::RiskType RiskType
Abstract base class for classes that map SIMM qualifiers to buckets.
Abstract base class for retrieving SIMM concentration thresholds.