19#include <boost/algorithm/string.hpp>
20#include <boost/assign.hpp>
21#include <boost/bimap.hpp>
35 bool operator()(
const string& lhs,
const string& rhs)
const {
36 return ((boost::to_lower_copy(lhs)) < (boost::to_lower_copy(rhs)));
41template <
typename T>
using bm = boost::bimap<T, boost::bimaps::set_of<std::string, string_cmp>>;
44const bm<CrifRecord::RiskType>
riskTypeMap = boost::assign::list_of<bm<CrifRecord::RiskType>::value_type>(
45 CrifRecord::RiskType::Commodity,
"Risk_Commodity")
46 (CrifRecord::RiskType::CommodityVol,
"Risk_CommodityVol")
47 (CrifRecord::RiskType::CreditNonQ,
"Risk_CreditNonQ")
48 (CrifRecord::RiskType::CreditQ,
"Risk_CreditQ")
49 (CrifRecord::RiskType::CreditVol,
"Risk_CreditVol")
50 (CrifRecord::RiskType::CreditVolNonQ,
"Risk_CreditVolNonQ")
51 (CrifRecord::RiskType::Equity,
"Risk_Equity")
52 (CrifRecord::RiskType::EquityVol,
"Risk_EquityVol")
53 (CrifRecord::RiskType::FX,
"Risk_FX")
54 (CrifRecord::RiskType::FXVol,
"Risk_FXVol")
55 (CrifRecord::RiskType::Inflation,
"Risk_Inflation")
56 (CrifRecord::RiskType::IRCurve,
"Risk_IRCurve")
57 (CrifRecord::RiskType::IRVol,
"Risk_IRVol")
58 (CrifRecord::RiskType::InflationVol,
"Risk_InflationVol")
59 (CrifRecord::RiskType::BaseCorr,
"Risk_BaseCorr")
60 (CrifRecord::RiskType::XCcyBasis,
"Risk_XCcyBasis")
61 (CrifRecord::RiskType::ProductClassMultiplier,
"Param_ProductClassMultiplier")
62 (CrifRecord::RiskType::AddOnNotionalFactor,
"Param_AddOnNotionalFactor")
63 (CrifRecord::RiskType::Notional,
"Notional")
64 (CrifRecord::RiskType::AddOnFixedAmount,
"Param_AddOnFixedAmount")
65 (CrifRecord::RiskType::PV,
"PV")
66 (CrifRecord::RiskType::GIRR_DELTA,
"GIRR_DELTA")
67 (CrifRecord::RiskType::GIRR_VEGA,
"GIRR_VEGA")
68 (CrifRecord::RiskType::GIRR_CURV,
"GIRR_CURV")
69 (CrifRecord::RiskType::CSR_NS_DELTA,
"CSR_NS_DELTA")
70 (CrifRecord::RiskType::CSR_NS_VEGA,
"CSR_NS_VEGA")
71 (CrifRecord::RiskType::CSR_NS_CURV,
"CSR_NS_CURV")
72 (CrifRecord::RiskType::CSR_SNC_DELTA,
"CSR_SNC_DELTA")
73 (CrifRecord::RiskType::CSR_SNC_VEGA,
"CSR_SNC_VEGA")
74 (CrifRecord::RiskType::CSR_SNC_CURV,
"CSR_SNC_CURV")
75 (CrifRecord::RiskType::CSR_SC_DELTA,
"CSR_SC_DELTA")
76 (CrifRecord::RiskType::CSR_SC_VEGA,
"CSR_SC_VEGA")
77 (CrifRecord::RiskType::CSR_SC_CURV,
"CSR_SC_CURV")
78 (CrifRecord::RiskType::EQ_DELTA,
"EQ_DELTA")
79 (CrifRecord::RiskType::EQ_VEGA,
"EQ_VEGA")
80 (CrifRecord::RiskType::EQ_CURV,
"EQ_CURV")
81 (CrifRecord::RiskType::COMM_DELTA,
"COMM_DELTA")
82 (CrifRecord::RiskType::COMM_VEGA,
"COMM_VEGA")
83 (CrifRecord::RiskType::COMM_CURV,
"COMM_CURV")
84 (CrifRecord::RiskType::FX_DELTA,
"FX_DELTA")
85 (CrifRecord::RiskType::FX_VEGA,
"FX_VEGA")
86 (CrifRecord::RiskType::FX_CURV,
"FX_CURV")
87 (CrifRecord::RiskType::DRC_NS,
"DRC_NS")
88 (CrifRecord::RiskType::DRC_SNC,
"DRC_SNC")
89 (CrifRecord::RiskType::DRC_SC,
"DRC_SC")
90 (CrifRecord::RiskType::RRAO_1_PERCENT,
"RRAO_1_PERCENT")
91 (CrifRecord::RiskType::RRAO_01_PERCENT,
"RRAO_01_PERCENT")
92 (CrifRecord::RiskType::Empty,
"")
93 (CrifRecord::RiskType::All,
"All");
96 CrifRecord::ProductClass::RatesFX,
"RatesFX")(CrifRecord::ProductClass::Rates,
"Rates")(
97 CrifRecord::ProductClass::FX,
"FX")(CrifRecord::ProductClass::Credit,
"Credit")(
98 CrifRecord::ProductClass::Equity,
"Equity")(CrifRecord::ProductClass::Commodity,
"Commodity")(
99 CrifRecord::ProductClass::Other,
"Other")(CrifRecord::ProductClass::Empty,
"")(
100 CrifRecord::ProductClass::All,
"All")(CrifRecord::ProductClass::AddOnNotionalFactor,
"AddOnNotionalFactor")(
101 CrifRecord::ProductClass::AddOnFixedAmount,
"AddOnFixedAmount");
106 "Risk type (" <<
static_cast<int>(rt) <<
") not a valid CrifRecord::RiskType");
112 "Product class (" <<
static_cast<int>(pc) <<
") not a valid CrifRecord::ProductClass");
119 if (boost::to_lower_copy(rt) == boost::to_lower_copy(it->first))
124 QL_FAIL(
"Risk type string " << rt <<
" does not correspond to a valid CrifRecord::RiskType");
129 if (boost::to_lower_copy(pc) == boost::to_lower_copy(it->first))
134 QL_FAIL(
"Product class string " << pc <<
" does not correspond to a valid CrifRecord::ProductClass");
140 out <<
"CurvatureDown";
143 out <<
"CurvatureUp";
153 if (scenario ==
"CurvatureDown") {
155 }
else if (scenario ==
"CurvatureUp") {
188 case RiskType::Commodity:
189 case RiskType::CommodityVol:
190 case RiskType::CreditNonQ:
191 case RiskType::CreditQ:
192 case RiskType::CreditVol:
193 case RiskType::CreditVolNonQ:
194 case RiskType::Equity:
195 case RiskType::EquityVol:
197 case RiskType::FXVol:
198 case RiskType::Inflation:
199 case RiskType::IRCurve:
200 case RiskType::IRVol:
201 case RiskType::InflationVol:
202 case RiskType::BaseCorr:
203 case RiskType::XCcyBasis:
204 case RiskType::ProductClassMultiplier:
205 case RiskType::AddOnNotionalFactor:
206 case RiskType::Notional:
207 case RiskType::AddOnFixedAmount:
210 case RiskType::GIRR_DELTA:
211 case RiskType::GIRR_VEGA:
212 case RiskType::GIRR_CURV:
213 case RiskType::CSR_NS_DELTA:
214 case RiskType::CSR_NS_VEGA:
215 case RiskType::CSR_NS_CURV:
216 case RiskType::CSR_SNC_DELTA:
217 case RiskType::CSR_SNC_VEGA:
218 case RiskType::CSR_SNC_CURV:
219 case RiskType::CSR_SC_DELTA:
220 case RiskType::CSR_SC_VEGA:
221 case RiskType::CSR_SC_CURV:
222 case RiskType::EQ_DELTA:
223 case RiskType::EQ_VEGA:
224 case RiskType::EQ_CURV:
225 case RiskType::COMM_DELTA:
226 case RiskType::COMM_VEGA:
227 case RiskType::COMM_CURV:
228 case RiskType::FX_DELTA:
229 case RiskType::FX_VEGA:
230 case RiskType::FX_CURV:
231 case RiskType::DRC_NS:
232 case RiskType::DRC_SNC:
233 case RiskType::DRC_SC:
234 case RiskType::RRAO_1_PERCENT:
235 case RiskType::RRAO_01_PERCENT:
238 case RiskType::Empty:
241 QL_FAIL(
"Unexpected RiskType " <<
riskType);
Struct for holding a CRIF record.
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
const bm< CrifRecord::ProductClass > productClassMap
boost::bimap< T, boost::bimaps::set_of< string, string_cmp > > bm
CrifRecord::CurvatureScenario parseFrtbCurvatureScenario(const std::string &scenario)
CrifRecord::RiskType parseRiskType(const string &rt)
const bm< MarketRiskConfiguration::RiskType > riskTypeMap
CrifRecord::ProductClass parseProductClass(const string &pc)
std::string amountCurrency
std::string collectRegulations
static std::vector< std::set< std::string > > additionalHeaders
ProductClass productClass
NettingSetDetails nettingSetDetails
CurvatureScenario
There are two entries for curvature risk in frtb, a up and down shift.
std::string postRegulations