Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
securityconfig.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file ored/configuration/securityconfig.hpp
20 \brief security spread configuration classes
21 \ingroup configuration
22*/
23
24#pragma once
25
27#include <ql/types.hpp>
28
29namespace ore {
30namespace data {
32using std::string;
33using std::vector;
34
35//! Security configuration
36/*!
37 \ingroup configuration
38*/
40public:
41 //! \name Constructors/Destructors
42 //@{
43 //! Detailed constructor
44 SecurityConfig(const string& curveID, const string& curveDescription, const string& spreadQuote = "",
45 const string& recoveryQuote = "", const string& cprQuote = "", const string& priceQuote = "")
48 setQuotes();
49 };
50 //! Default constructor
52 //@}
53
54 //! \name Inspectors
55 //@{
56 const string& spreadQuote() { return spreadQuote_; }
57 const string& recoveryRatesQuote() { return recoveryQuote_; }
58 const string& cprQuote() { return cprQuote_; }
59 const string& priceQuote() { return priceQuote_; }
60 //@}
61
62 void fromXML(XMLNode* node) override {
63 XMLUtils::checkNode(node, "Security");
64
65 curveID_ = XMLUtils::getChildValue(node, "CurveId", true);
66 curveDescription_ = XMLUtils::getChildValue(node, "CurveDescription", true);
67 spreadQuote_ = XMLUtils::getChildValue(node, "SpreadQuote", false);
68 recoveryQuote_ = XMLUtils::getChildValue(node, "RecoveryRateQuote", false);
69 cprQuote_ = XMLUtils::getChildValue(node, "CPRQuote", false);
70 priceQuote_ = XMLUtils::getChildValue(node, "PriceQuote", false);
71 setQuotes();
72 }
73
74 XMLNode* toXML(XMLDocument& doc) const override {
75 XMLNode* node = doc.allocNode("Security");
76
77 XMLUtils::addChild(doc, node, "CurveId", curveID_);
78 XMLUtils::addChild(doc, node, "CurveDescription", curveDescription_);
79 if (!spreadQuote_.empty())
80 XMLUtils::addChild(doc, node, "SpreadQuote", spreadQuote_);
81 if (!recoveryQuote_.empty())
82 XMLUtils::addChild(doc, node, "RecoveryRateQuote", recoveryQuote_);
83 if (!cprQuote_.empty())
84 XMLUtils::addChild(doc, node, "CPRQuote", cprQuote_);
85 if (!priceQuote_.empty())
86 XMLUtils::addChild(doc, node, "PriceQuote", priceQuote_);
87 return node;
88 }
89
90private:
91 void setQuotes() {
92 quotes_.clear();
93 if (!spreadQuote_.empty())
94 quotes_.push_back(spreadQuote_);
95 if (!recoveryQuote_.empty())
96 quotes_.push_back(recoveryQuote_);
97 if (!cprQuote_.empty())
98 quotes_.push_back(cprQuote_);
99 if (!priceQuote_.empty())
100 quotes_.push_back(priceQuote_);
101 }
103};
104} // namespace data
105} // namespace ore
Base curve configuration.
Definition: curveconfig.hpp:41
vector< string > quotes_
Definition: curveconfig.hpp:74
const string & curveDescription() const
Definition: curveconfig.hpp:55
const string & curveID() const
Definition: curveconfig.hpp:54
Security configuration.
const string & priceQuote()
const string & spreadQuote()
const string & recoveryRatesQuote()
SecurityConfig()
Default constructor.
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
SecurityConfig(const string &curveID, const string &curveDescription, const string &spreadQuote="", const string &recoveryQuote="", const string &cprQuote="", const string &priceQuote="")
Detailed constructor.
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static void checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
Base curve configuration classes.
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23