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

Today's Market Parameters. More...

#include <ored/marketdata/todaysmarketparameters.hpp>

+ Inheritance diagram for TodaysMarketParameters:
+ Collaboration diagram for TodaysMarketParameters:

Public Member Functions

 TodaysMarketParameters ()
 Default constructor. More...
 
Inspectors
const vector< pair< string, MarketConfiguration > > & configurations () const
 
bool hasConfiguration (const string &configuration) const
 
bool hasMarketObject (const MarketObject &o) const
 
const map< string, string > & mapping (const MarketObject o, const string &configuration) const
 EUR => Yield/EUR/EUR6M, USD => Yield/USD/USD3M etc. More...
 
map< string, string > & mappingReference (const MarketObject o, const string &configuration)
 return a mapping reference for modification More...
 
vector< string > curveSpecs (const string &configuration) const
 Build a vector of all the curve specs (may contain duplicates) More...
 
string marketObjectId (const MarketObject o, const string &configuration) const
 Intermediate id for a given market object and configuration, see the description of configurations_ below. More...
 
void clear ()
 Clear the contents. More...
 
bool empty ()
 Check if any parameters. More...
 
Setters
void addConfiguration (const string &name, const MarketConfiguration &configuration)
 
void addMarketObject (const MarketObject o, const string &id, const map< string, string > &assignments)
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const =0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 Parse from XML string. More...
 
std::string toXMLString () const
 Parse from XML string. More...
 

Serialisation

vector< pair< string, MarketConfiguration > > configurations_
 
map< MarketObject, map< string, map< string, string > > > marketObjects_
 
void fromXML (XMLNode *node) override
 
XMLNodetoXML (XMLDocument &doc) const override
 
void curveSpecs (const map< string, map< string, string > > &, const string &, vector< string > &) const
 

Detailed Description

Today's Market Parameters.

This class is a container of instructions (all text) for how to build a market object.

An instance of this object is needed in order to call a TodaysMarket constructor.

Definition at line 78 of file todaysmarketparameters.hpp.

Constructor & Destructor Documentation

◆ TodaysMarketParameters()

Default constructor.

Definition at line 81 of file todaysmarketparameters.hpp.

81{}

Member Function Documentation

◆ configurations()

const vector< pair< string, MarketConfiguration > > & configurations ( ) const

Definition at line 155 of file todaysmarketparameters.hpp.

155 {
156 return configurations_;
157}
vector< pair< string, MarketConfiguration > > configurations_
+ Here is the caller graph for this function:

◆ hasConfiguration()

bool hasConfiguration ( const string &  configuration) const

Definition at line 159 of file todaysmarketparameters.hpp.

159 {
160 auto it = find_if(configurations_.begin(), configurations_.end(),
161 [&configuration](const pair<string, MarketConfiguration>& s) { return s.first == configuration; });
162 return it != configurations_.end();
163}
+ Here is the caller graph for this function:

◆ hasMarketObject()

bool hasMarketObject ( const MarketObject o) const

Definition at line 165 of file todaysmarketparameters.hpp.

165 {
166 auto it = marketObjects_.find(o);
167 return it != marketObjects_.end();
168}
map< MarketObject, map< string, map< string, string > > > marketObjects_
+ Here is the caller graph for this function:

◆ mapping()

const map< string, string > & mapping ( const MarketObject  o,
const string &  configuration 
) const

EUR => Yield/EUR/EUR6M, USD => Yield/USD/USD3M etc.

Definition at line 325 of file todaysmarketparameters.cpp.

325 {
326 static map<string, string> empty;
327 QL_REQUIRE(hasConfiguration(configuration), "configuration " << configuration << " not found");
328 auto it = marketObjects_.find(o);
329 if (it != marketObjects_.end()) {
330 auto it2 = it->second.find(marketObjectId(o, configuration));
331 if (it2 != it->second.end()) {
332 return it2->second;
333 }
334 }
335 return empty;
336}
bool hasConfiguration(const string &configuration) const
bool empty()
Check if any parameters.
string marketObjectId(const MarketObject o, const string &configuration) const
Intermediate id for a given market object and configuration, see the description of configurations_ b...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mappingReference()

map< string, string > & mappingReference ( const MarketObject  o,
const string &  configuration 
)

return a mapping reference for modification

Definition at line 338 of file todaysmarketparameters.cpp.

338 {
339 QL_REQUIRE(hasConfiguration(configuration), "configuration " << configuration << " not found");
340 auto it = marketObjects_.find(o);
341 if (it != marketObjects_.end()) {
342 auto it2 = it->second.find(marketObjectId(o, configuration));
343 if (it2 != it->second.end()) {
344 return it2->second;
345 } else {
346 return it->second[marketObjectId(o, configuration)];
347 }
348 } else {
349 return marketObjects_[o][marketObjectId(o, configuration)];
350 }
351}
+ Here is the call graph for this function:

◆ curveSpecs() [1/2]

vector< string > curveSpecs ( const string &  configuration) const

Build a vector of all the curve specs (may contain duplicates)

Definition at line 267 of file todaysmarketparameters.cpp.

267 {
268 vector<string> specs;
269 for (Size i = 0; i < marketObjectData.size(); ++i) {
270 MarketObject mo = marketObjectData[i].obj;
271 // swap indices have to be excluded here...
272 if (mo != MarketObject::SwapIndexCurve && marketObjects_.find(mo) != marketObjects_.end()) {
273 curveSpecs(marketObjects_.at(mo), marketObjectId(mo, configuration), specs);
274 }
275 }
276 return specs;
277}
vector< string > curveSpecs(const string &configuration) const
Build a vector of all the curve specs (may contain duplicates)
MarketObject
Definition: market.hpp:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ marketObjectId()

string marketObjectId ( const MarketObject  o,
const string &  configuration 
) const

Intermediate id for a given market object and configuration, see the description of configurations_ below.

Definition at line 170 of file todaysmarketparameters.hpp.

170 {
171 QL_REQUIRE(hasConfiguration(configuration), "configuration " << configuration << " not found");
172 auto it = find_if(configurations_.begin(), configurations_.end(),
173 [&configuration](const pair<string, MarketConfiguration>& s) { return s.first == configuration; });
174 return it->second(o);
175}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear()

void clear ( )

Clear the contents.

Definition at line 130 of file todaysmarketparameters.cpp.

130 {
131 // clear data members
132 configurations_.clear();
133 marketObjects_.clear();
134}

◆ empty()

bool empty ( )

Check if any parameters.

Definition at line 136 of file todaysmarketparameters.cpp.

136 {
137 return marketObjects_.size() == 0;
138}
+ Here is the caller graph for this function:

◆ addConfiguration()

void addConfiguration ( const string &  name,
const MarketConfiguration configuration 
)

Definition at line 120 of file todaysmarketparameters.cpp.

120 {
121 if (hasConfiguration(id)) {
122 auto it =
123 find_if(configurations_.begin(), configurations_.end(),
124 [&id](const pair<string, MarketConfiguration>& s) { return s.first == id; });
125 it->second.add(configuration);
126 } else
127 configurations_.push_back(make_pair(id, configuration));
128}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addMarketObject()

void addMarketObject ( const MarketObject  o,
const string &  id,
const map< string, string > &  assignments 
)

Definition at line 279 of file todaysmarketparameters.cpp.

280 {
281
282 // check that we do not have an inconsistent mapping within one market object
283 auto mo = marketObjects_.find(o);
284 if (mo != marketObjects_.end()) {
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.");
294 }
295 }
296 }
297 }
298
299 // check that we do not have an overlap of names for yield curves and index curves
301 auto mo =
303 if (mo != marketObjects_.end()) {
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");
313 }
314 }
315 }
316 }
317
318 // add the 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 << " "
322 << s.second);
323}
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 140 of file todaysmarketparameters.cpp.

140 {
141
142 // add default configuration if we do not have one (may be overwritten below)
144 addConfiguration(Market::defaultConfiguration, MarketConfiguration());
145
146 // fill data from XML
147 XMLUtils::checkNode(node, "TodaysMarket");
149 while (n) {
150 if (XMLUtils::getNodeName(n) == "Configuration") {
151 MarketConfiguration tmp;
152 for (Size i = 0; i < marketObjectData.size(); ++i) {
153 tmp.setId(marketObjectData[i].obj,
154 XMLUtils::getChildValue(n, marketObjectData[i].xmlName + "Id", false));
156 }
157 } else {
158 Size i = 0;
159 for (; i < marketObjectData.size(); ++i) {
160 if (XMLUtils::getNodeName(n) == marketObjectData[i].xmlName) {
161 string id = XMLUtils::getAttribute(n, "id");
162 if (id == "")
164 // The XML schema for swap indices is different ...
165 if (marketObjectData[i].obj == MarketObject::SwapIndexCurve) {
166 vector<XMLNode*> nodes = XMLUtils::getChildrenNodes(n, marketObjectData[i].xmlSingleName.first);
167 map<string, string> swapIndices;
168 for (XMLNode* xn : nodes) {
169 string name = XMLUtils::getAttribute(xn, marketObjectData[i].xmlSingleName.second);
170 QL_REQUIRE(name != "", "no name given for SwapIndex");
171 QL_REQUIRE(swapIndices.find(name) == swapIndices.end(),
172 "Duplicate SwapIndex found for " << name);
173 string disc = XMLUtils::getChildValue(xn, "Discounting", true);
174 swapIndices[name] = disc; //.emplace(name, { ibor, disc }); won't work?
175 }
177
178 } else {
179 auto mp =
180 XMLUtils::getChildrenAttributesAndValues(n, marketObjectData[i].xmlSingleName.first,
181 marketObjectData[i].xmlSingleName.second, false);
182 // deprecated attribute currency for capfloor vols and swaption vols
183 if (marketObjectData[i].obj == MarketObject::CapFloorVol ||
184 marketObjectData[i].obj == MarketObject::SwaptionVol) {
186 n, marketObjectData[i].xmlSingleName.first, "currency", false);
187 if (!mp2.empty()) {
188 mp.insert(mp2.begin(), mp2.end());
189 WLOG("TodaysMarketParameters: the attribute 'currency' is deprecated for '" +
190 marketObjectData[i].xmlName + "', use 'key' instead.");
191 }
192 }
193 Size nc = XMLUtils::getChildrenNodes(n, "").size();
194 QL_REQUIRE(mp.size() == nc, "TodaysMarketParameters::fromXML(): possible duplicate entry in node "
195 << marketObjectData[i].xmlName << ", check for XMLUtils warnings.");
196 addMarketObject(marketObjectData[i].obj, id, mp);
197 }
198 break;
199 }
200 }
201 QL_REQUIRE(i < marketObjectData.size(),
202 "TodaysMarketParameters::fromXML(): node not recognized: " << XMLUtils::getNodeName(n));
203 }
205 } // while(n)
206}
static const string defaultConfiguration
Default configuration label.
Definition: market.hpp:296
void addMarketObject(const MarketObject o, const string &id, const map< string, string > &assignments)
void addConfiguration(const string &name, const MarketConfiguration &configuration)
static string getAttribute(XMLNode *node, const string &attrName)
Definition: xmlutils.cpp:419
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
Definition: xmlutils.cpp:428
static string getNodeName(XMLNode *n)
Get and set a node's name.
Definition: xmlutils.cpp:473
static map< string, string > getChildrenAttributesAndValues(XMLNode *parent, const string &names, const string &attributeName, bool mandatory=false)
Definition: xmlutils.cpp:365
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
Definition: xmlutils.cpp:484
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
pair< string, string > xmlSingleName
string name
string xmlName
MarketObject obj
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 208 of file todaysmarketparameters.cpp.

208 {
209
210 XMLNode* todaysMarketNode = doc.allocNode("TodaysMarket");
211
212 // configurations
213 if (configurations_.size() > 0) {
214 for (auto iterator = configurations_.begin(); iterator != configurations_.end(); iterator++) {
215 XMLNode* configurationsNode = XMLUtils::addChild(doc, todaysMarketNode, "Configuration");
216 XMLUtils::addAttribute(doc, configurationsNode, "id", iterator->first.c_str());
217 for (Size i = 0; i < marketObjectData.size(); ++i) {
218 XMLUtils::addChild(doc, configurationsNode, marketObjectData[i].xmlName + "Id",
219 iterator->second(marketObjectData[i].obj)); // Added the "Id" for schema test
220 }
221 }
222 }
223
224 for (Size i = 0; i < marketObjectData.size(); ++i) {
225 if (marketObjects_.find(marketObjectData[i].obj) != marketObjects_.end()) {
226 auto mapping = marketObjects_.at(marketObjectData[i].obj);
227 for (auto mappingSetIterator = mapping.begin(); mappingSetIterator != mapping.end(); mappingSetIterator++) {
228
229 XMLNode* node = XMLUtils::addChild(doc, todaysMarketNode, marketObjectData[i].xmlName);
230 XMLUtils::addAttribute(doc, node, "id", mappingSetIterator->first.c_str());
231
232 for (auto singleMappingIterator = mappingSetIterator->second.begin();
233 singleMappingIterator != mappingSetIterator->second.end(); singleMappingIterator++) {
234 // Again, swap indices are different...
235 if (marketObjectData[i].obj == MarketObject::SwapIndexCurve) {
236 XMLNode* swapIndexNode = XMLUtils::addChild(doc, node, marketObjectData[i].xmlSingleName.first);
237 XMLUtils::addAttribute(doc, swapIndexNode, marketObjectData[i].xmlSingleName.second,
238 singleMappingIterator->first.c_str());
239 XMLUtils::addChild(doc, swapIndexNode, "Discounting",
240 (string)singleMappingIterator->second.c_str());
241 } else {
242 XMLNode* singleMappingNode =
243 doc.allocNode(marketObjectData[i].xmlSingleName.first, singleMappingIterator->second);
244 XMLUtils::appendNode(node, singleMappingNode);
245 XMLUtils::addAttribute(doc, singleMappingNode, marketObjectData[i].xmlSingleName.second,
246 singleMappingIterator->first);
247 }
248 }
249 }
250 }
251 }
252 return todaysMarketNode;
253}
const map< string, string > & mapping(const MarketObject o, const string &configuration) const
EUR => Yield/EUR/EUR6M, USD => Yield/USD/USD3M etc.
static void addAttribute(XMLDocument &doc, XMLNode *node, const string &attrName, const string &attrValue)
Definition: xmlutils.cpp:412
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
+ Here is the call graph for this function:

◆ curveSpecs() [2/2]

void curveSpecs ( const map< string, map< string, string > > &  m,
const string &  id,
vector< string > &  specs 
) const
private

Definition at line 255 of file todaysmarketparameters.cpp.

256 {
257 // extract all the curve specs
258 auto it = m.find(id);
259 if (it != m.end()) {
260 for (auto kv : it->second) {
261 specs.push_back(kv.second);
262 DLOG("Add spec " << kv.second);
263 }
264 }
265}

Member Data Documentation

◆ configurations_

vector<pair<string, MarketConfiguration> > configurations_
private

Definition at line 136 of file todaysmarketparameters.hpp.

◆ marketObjects_

map<MarketObject, map<string, map<string, string> > > marketObjects_
private

Definition at line 148 of file todaysmarketparameters.hpp.