24#include <ql/errors.hpp>
26#include <boost/algorithm/string.hpp>
34 const std::map<int, Config>& configs)
35 :
CurveConfig(curveId, curveDescription), currency_(currency), configs_(configs) {
40 c.second.priority() = c.first;
44 const std::string& benchmarkCurveID,
const std::string& sourceCurveID,
45 const std::vector<std::string>& multiSectionSourceCurveIds) {
46 if (!discountCurveID.empty())
48 if (!benchmarkCurveID.empty())
50 if (!sourceCurveID.empty())
52 for (
auto const& s : multiSectionSourceCurveIds) {
59 for (
auto const& config :
configs_) {
61 config.second.sourceCurveID(), config.second.multiSectionSourceCurveIds());
67 for (
auto const& config :
configs_) {
68 for (
const auto& kv : config.second.cdsQuotes()) {
73 if (!config.second.recoveryRateQuote().empty() && !
tryParseReal(config.second.recoveryRateQuote(), dummy))
74 quotes_.insert(
quotes_.begin(), config.second.recoveryRateQuote());
88 "DefaultCurveConfig::fromXML(): several configurations with same priority '" << tmp.
priority()
117 const DayCounter& dayCounter,
const string& conventionID,
118 const std::vector<std::pair<std::string, bool>>& cdsQuotes,
bool extrapolation,
119 const string& benchmarkCurveID,
const string& sourceCurveID,
120 const std::vector<string>& pillars,
const Calendar&
calendar,
const Size spotLag,
122 QuantLib::Real runningSpread,
const QuantLib::Period& indexTerm,
123 const boost::optional<bool>& implyDefaultFromMarket,
const bool allowNegativeRates,
125 : cdsQuotes_(cdsQuotes), type_(type), discountCurveID_(discountCurveID), recoveryRateQuote_(recoveryRateQuote),
126 dayCounter_(dayCounter), conventionID_(conventionID), extrapolation_(extrapolation),
127 benchmarkCurveID_(benchmarkCurveID), sourceCurveID_(sourceCurveID), pillars_(pillars), calendar_(
calendar),
128 spotLag_(spotLag), startDate_(startDate), bootstrapConfig_(bootstrapConfig), runningSpread_(runningSpread),
129 indexTerm_(indexTerm), implyDefaultFromMarket_(implyDefaultFromMarket), allowNegativeRates_(allowNegativeRates),
130 priority_(priority) {}
134 if (!prioStr.empty())
138 if (
type ==
"SpreadCDS") {
140 }
else if (
type ==
"HazardRate") {
142 }
else if (
type ==
"Price") {
144 }
else if (
type ==
"Benchmark") {
146 }
else if (
type ==
"MultiSection") {
148 }
else if (
type ==
"TransitionMatrix") {
150 }
else if (
type ==
"Null") {
153 QL_FAIL(
"Type " <<
type <<
" not recognized");
182 bool opt = (!attr.empty() &&
parseBool(attr));
194 bool opt = (!attr.empty() &&
parseBool(attr));
209 WLOG(
"'StartDate' is only used when type is 'SpreadCDS' or 'Price'");
214 DLOG(
"'RunningSpread' is empty and type is 'Price' for default curve "
215 "so the running spread will need to be provided in the market quote.");
235 if (type_ == Type::SpreadCDS || type_ == Type::HazardRate || type_ == Type::Price) {
236 if (type_ == Type::SpreadCDS) {
238 }
else if (type_ == Type::HazardRate) {
247 for (
auto q : cdsQuotes_) {
253 }
else if (type_ == Type::Benchmark) {
262 }
else if (type_ == Type::MultiSection) {
266 }
else if ( type_ == Type::TransitionMatrix) {
269 }
else if (type_ == Type::Null) {
274 QL_FAIL(
"Unknown type in DefaultCurveConfig::toXML()");
278 if (startDate_ != Date())
280 if (runningSpread_ != QuantLib::Null<Real>())
282 if (indexTerm_ != 0 * Days) {
285 if (implyDefaultFromMarket_)
void fromXML(ore::data::XMLNode *node) override
Base curve configuration.
map< CurveSpec::CurveType, set< string > > requiredCurveIds_
string recoveryRateQuote_
const Type & type() const
vector< string > multiSectionSourceCurveIds_
vector< string > pillars_
void fromXML(XMLNode *node) override
BootstrapConfig bootstrapConfig_
vector< string > multiSectionSwitchDates_
XMLNode * toXML(XMLDocument &doc) const override
boost::optional< bool > implyDefaultFromMarket_
std::vector< std::pair< std::string, bool > > cdsQuotes_
Quote and optional flag pair.
const int priority() const
QuantLib::Date startDate_
QuantLib::Period indexTerm_
void populateRequiredCurveIds()
DefaultCurveConfig()
default ctor
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
const std::map< int, Config > & configs() const
std::map< int, Config > configs_
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 void addChildren(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values)
static string getAttribute(XMLNode *node, const string &attrName)
static void addGenericChildAsList(XMLDocument &doc, XMLNode *n, const string &name, const vector< T > &values, const string &attrName="", const string &attr="")
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 getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static string getNodeValue(XMLNode *node)
Get a node's value.
static vector< string > getChildrenValuesAsStrings(XMLNode *node, const string &name, bool mandatory=false)
static vector< string > getChildrenValues(XMLNode *node, const string &names, const string &name, bool mandatory=false)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
Default curve configuration classes.
QuantLib::ext::shared_ptr< CurveSpec > parseCurveSpec(const string &s)
function to convert a string into a curve spec
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
bool tryParseReal(const string &s, QuantLib::Real &result)
Attempt to convert text to Real.
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
bool parseBool(const string &s)
Convert text to bool.
Real parseReal(const string &s)
Convert text to Real.
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
DayCounter parseDayCounter(const string &s)
Convert text to QuantLib::DayCounter.
Classes and functions for log message handling.
#define DLOG(text)
Logging Macro (Level = Debug)
#define WLOG(text)
Logging Macro (Level = Warning)
std::vector< string > parseListOfValues(string s, const char escape, const char delim, const char quote)
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
string conversion utilities