19#include <boost/algorithm/string/split.hpp>
22#include <ql/errors.hpp>
32 boost::hash_combine(seed, k.
keytype);
33 boost::hash_combine(seed, k.
name);
34 boost::hash_combine(seed, k.
index);
39 return asof() == s->asof() &&
label() == s->label() && QuantLib::close_enough(
getNumeraire(), s->getNumeraire()) &&
41 return QuantLib::close_enough(this->
get(k), s->get(k));
48 return out <<
"DiscountCurve";
50 return out <<
"YieldCurve";
52 return out <<
"IndexCurve";
54 return out <<
"SwaptionVolatility";
56 return out <<
"YieldVolatility";
58 return out <<
"OptionletVolatility";
60 return out <<
"FXSpot";
62 return out <<
"FXVolatility";
64 return out <<
"EquitySpot";
66 return out <<
"EquityVolatility";
68 return out <<
"DividendYield";
70 return out <<
"SurvivalProbability";
72 return out <<
"SurvivalWeight";
74 return out <<
"RecoveryRate";
76 return out <<
"CrState";
78 return out <<
"CDSVolatility";
80 return out <<
"BaseCorrelation";
82 return out <<
"CPIIndex";
84 return out <<
"ZeroInflationCurve";
86 return out <<
"YoYInflationCurve";
88 return out <<
"YoYInflationCapFloorVolatility";
90 return out <<
"ZeroInflationCapFloorVolatility";
92 return out <<
"CommodityCurve";
94 return out <<
"CommodityVolatility";
96 return out <<
"SecuritySpread";
98 return out <<
"Correlation";
112 string keyStr = key.
name;
116 index = keyStr.find(
"/", index);
117 if (index == std::string::npos)
120 keyStr.replace(index, 1,
"\\/");
125 return out << key.
keytype <<
"/" << keyStr <<
"/" << key.
index;
129 if (str ==
"DiscountCurve")
131 else if (str ==
"YieldCurve")
133 else if (str ==
"IndexCurve")
135 else if (str ==
"SwaptionVolatility")
137 else if (str ==
"YieldVolatility")
139 else if (str ==
"OptionletVolatility")
141 else if (str ==
"FXSpot")
143 else if (str ==
"FXVolatility")
145 else if (str ==
"EquitySpot")
147 else if (str ==
"EquityVolatility")
149 else if (str ==
"DividendYield")
151 else if (str ==
"SurvivalProbability")
153 else if (str ==
"RecoveryRate")
155 else if (str ==
"CDSVolatility")
157 else if (str ==
"BaseCorrelation")
159 else if (str ==
"CPIIndex")
161 else if (str ==
"ZeroInflationCurve")
163 else if (str ==
"YoYInflationCurve")
165 else if (str ==
"YoYInflationCapFloorVolatility")
167 else if (str ==
"ZeroInflationCapFloorVolatility")
169 else if (str ==
"CommodityCurve")
171 else if (str ==
"CommodityVolatility")
173 else if (str ==
"SecuritySpread")
175 else if (str ==
"Correlation")
177 else if (str ==
"CPR")
180 QL_FAIL(
"RiskFactorKey " << str <<
" does not exist.");
184 boost::escaped_list_separator<char> sep(
'\\',
'/',
'\"');
185 boost::tokenizer<boost::escaped_list_separator<char> > tokenSplit(str, sep);
186 vector<string> tokens(tokenSplit.begin(), tokenSplit.end());
188 QL_REQUIRE(tokens.size() == 3,
"Could not parse key " << str);
201 QL_FAIL(
"Cannot convert shift scheme \"" << s <<
"\" to ShiftScheme");
207 return out <<
"Forward";
209 return out <<
"Backward";
211 return out <<
"Central";
213 QL_FAIL(
"Invalid ShiftScheme " <<
static_cast<int>(shiftScheme));
217 static map<string, ShiftType> m = {
224 QL_FAIL(
"Cannot convert shift type \"" << s <<
"\" to ShiftType");
230 return out <<
"Absolute";
232 return out <<
"Relative";
234 QL_FAIL(
"Invalid ShiftType " << shiftType);
Data types stored in the scenario class.
std::string name
Key name.
KeyType
Risk Factor types.
@ YoYInflationCapFloorVolatility
@ ZeroInflationCapFloorVolatility
virtual const string & label() const =0
Get the scenario label.
virtual bool isCloseEnough(const QuantLib::ext::shared_ptr< Scenario > &s) const
checks for equality up to numerical differences
virtual const std::vector< RiskFactorKey > & keys() const =0
Risk factor keys for which this scenario provides data.
virtual const Date & asof() const =0
Return the scenario asof date.
virtual Real get(const RiskFactorKey &key) const =0
Get an element from the scenario.
virtual Real getNumeraire() const =0
Get Numeraire ratio n = N(t) / N(0) so that Price(0) = N(0) * E [Price(t) / N(t) ].
Integer parseInteger(const string &s)
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
ShiftScheme parseShiftScheme(const std::string &s)
RiskFactorKey::KeyType parseRiskFactorKeyType(const string &str)
RiskFactorKey parseRiskFactorKey(const string &str)
std::size_t hash_value(const RiskFactorKey &k)
ShiftType parseShiftType(const std::string &s)