30struct MarketObjectMetaInfo {
38static const vector<MarketObjectMetaInfo> marketObjectData = {
45 "ZeroInflationIndexCurves",
46 {
"ZeroInflationIndexCurve",
"name"}},
56 "YoYInflationCapFloorVol",
57 "YYInflationCapFloorVolatilities",
58 {
"YYInflationCapFloorVolatility",
"name"}},
60 "ZeroInflationCapFloorVol",
61 "ZeroInflationCapFloorVolatilities",
62 {
"ZeroInflationCapFloorVolatility",
"name"}},
69 "CommodityVolatilities",
70 "CommodityVolatilities",
71 {
"CommodityVolatility",
"name"}},
77 for (Size i = 0; i < marketObjectData.size(); i++) {
78 if (marketObjectData[i].
obj == o)
79 return out << marketObjectData[i].name;
81 return out <<
"Unknown";
85 thread_local static std::set<MarketObject> result;
87 for (
auto const& o : marketObjectData) {
95 for (Size i = 0; i < marketObjectData.size(); ++i) {
99 for (
const auto& moi : marketObjectIds)
100 setId(moi.first, moi.second);
105 "MarketConfiguration: did not find MarketObject " << o <<
" (this is unexpected)");
124 [&
id](
const pair<string, MarketConfiguration>& s) { return s.first == id; });
125 it->second.add(configuration);
152 for (Size i = 0; i < marketObjectData.size(); ++i) {
159 for (; i < marketObjectData.size(); ++i) {
167 map<string, string> swapIndices;
170 QL_REQUIRE(
name !=
"",
"no name given for SwapIndex");
171 QL_REQUIRE(swapIndices.find(
name) == swapIndices.end(),
172 "Duplicate SwapIndex found for " <<
name);
174 swapIndices[
name] = disc;
181 marketObjectData[i].xmlSingleName.second,
false);
186 n, marketObjectData[i].
xmlSingleName.first,
"currency",
false);
188 mp.insert(mp2.begin(), mp2.end());
189 WLOG(
"TodaysMarketParameters: the attribute 'currency' is deprecated for '" +
190 marketObjectData[i].
xmlName +
"', use 'key' instead.");
194 QL_REQUIRE(mp.size() == nc,
"TodaysMarketParameters::fromXML(): possible duplicate entry in node "
195 << marketObjectData[i].xmlName <<
", check for XMLUtils warnings.");
201 QL_REQUIRE(i < marketObjectData.size(),
217 for (Size i = 0; i < marketObjectData.size(); ++i) {
219 iterator->second(marketObjectData[i].obj));
224 for (Size i = 0; i < marketObjectData.size(); ++i) {
227 for (
auto mappingSetIterator =
mapping.begin(); mappingSetIterator !=
mapping.end(); mappingSetIterator++) {
232 for (
auto singleMappingIterator = mappingSetIterator->second.begin();
233 singleMappingIterator != mappingSetIterator->second.end(); singleMappingIterator++) {
238 singleMappingIterator->first.c_str());
240 (
string)singleMappingIterator->second.c_str());
246 singleMappingIterator->first);
252 return todaysMarketNode;
256 vector<string>& specs)
const {
258 auto it = m.find(
id);
260 for (
auto kv : it->second) {
261 specs.push_back(kv.second);
262 DLOG(
"Add spec " << kv.second);
268 vector<string> specs;
269 for (Size i = 0; i < marketObjectData.size(); ++i) {
280 const map<string, string>& assignments) {
285 auto mp = mo->second.find(
id);
286 if (mp != mo->second.end()) {
287 for (
auto const& m : mp->second) {
288 auto a = assignments.find(m.first);
289 if (a != assignments.end()) {
290 QL_REQUIRE(m.first != a->first || m.second == a->second,
291 "TodaysMarketParameters, inconsistent mapping is added for market object type "
292 << o <<
", id " <<
id <<
": " << a->first <<
" " << a->second <<
", but have "
293 << m.first <<
" " << m.second <<
" already.");
304 auto mp = mo->second.find(
id);
305 if (mp != mo->second.end()) {
306 for (
auto const& m : mp->second) {
307 auto a = assignments.find(m.first);
308 QL_REQUIRE(a == assignments.end(),
309 "TodaysMarketParameters, overlap between YieldCurve and IndexCurve names, try to add "
310 "mapping for market object type "
311 << o <<
", id " <<
id <<
": " << a->first <<
" " << a->second <<
", but have "
312 << m.first <<
" " << m.second <<
" already in other market object's mapping");
319 marketObjects_[o][id].insert(assignments.begin(), assignments.end());
320 for (
auto s : assignments)
321 DLOG(
"TodaysMarketParameters, add market objects of type " << o <<
": " <<
id <<
" " << s.first <<
" "
326 static map<string, string>
empty;
327 QL_REQUIRE(
hasConfiguration(configuration),
"configuration " << configuration <<
" not found");
331 if (it2 != it->second.end()) {
339 QL_REQUIRE(
hasConfiguration(configuration),
"configuration " << configuration <<
" not found");
343 if (it2 != it->second.end()) {
void setId(const MarketObject o, const string &id)
MarketConfiguration(map< MarketObject, string > marketObjectIds={})
map< MarketObject, string > marketObjectIds_
string operator()(const MarketObject o) const
void add(const MarketConfiguration &o)
static const string defaultConfiguration
Default configuration label.
vector< pair< string, MarketConfiguration > > configurations_
vector< string > curveSpecs(const string &configuration) const
Build a vector of all the curve specs (may contain duplicates)
bool hasConfiguration(const string &configuration) const
void addMarketObject(const MarketObject o, const string &id, const map< string, string > &assignments)
bool empty()
Check if any parameters.
const map< string, string > & mapping(const MarketObject o, const string &configuration) const
EUR => Yield/EUR/EUR6M, USD => Yield/USD/USD3M etc.
map< MarketObject, map< string, map< string, string > > > marketObjects_
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
void clear()
Clear the contents.
void addConfiguration(const string &name, const MarketConfiguration &configuration)
map< string, string > & mappingReference(const MarketObject o, const string &configuration)
return a mapping reference for modification
string marketObjectId(const MarketObject o, const string &configuration) const
Intermediate id for a given market object and configuration, see the description of configurations_ b...
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static void addAttribute(XMLDocument &doc, XMLNode *node, const string &attrName, const string &attrValue)
static string getAttribute(XMLNode *node, const string &attrName)
static void checkNode(XMLNode *n, const string &expectedName)
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
static string getNodeName(XMLNode *n)
Get and set a node's name.
static map< string, string > getChildrenAttributesAndValues(XMLNode *parent, const string &names, const string &attributeName, bool mandatory=false)
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
Classes and functions for log message handling.
#define DLOG(text)
Logging Macro (Level = Debug)
#define WLOG(text)
Logging Macro (Level = Warning)
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
@ YoYInflationCapFloorVol
@ ZeroInflationCapFloorVol
std::set< MarketObject > getMarketObjectTypes()
Serializable Credit Default Swap.
pair< string, string > xmlSingleName
A class to hold todays market configuration(s)