Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
defaultcurveconfig.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/defaultcurveconfig.hpp
20 \brief Default curve configuration classes
21 \ingroup configuration
22*/
23
24#pragma once
25
26#include <boost/optional.hpp>
29#include <ql/time/calendar.hpp>
30#include <ql/time/date.hpp>
31#include <ql/time/daycounter.hpp>
32#include <ql/time/period.hpp>
33#include <ql/types.hpp>
34
35namespace ore {
36namespace data {
38using QuantLib::BusinessDayConvention;
40using QuantLib::DayCounter;
41using QuantLib::Period;
42using std::string;
43using std::vector;
44
45//! Default curve configuration
46/*!
47 \ingroup configuration
48*/
50public:
51 class Config : public XMLSerializable {
52 public:
53 //! Supported default curve types
55 Config(const Type& type, const string& discountCurveID, const string& recoveryRateQuote,
56 const DayCounter& dayCounter, const string& conventionID,
57 const std::vector<std::pair<std::string, bool>>& cdsQuotes = {}, bool extrapolation = true,
58 const string& benchmarkCurveID = "", const string& sourceCurveID = "",
59 const std::vector<string>& pillars = std::vector<string>(), const Calendar& calendar = Calendar(),
60 const Size spotLag = 0, const QuantLib::Date& startDate = QuantLib::Date(),
62 QuantLib::Real runningSpread = QuantLib::Null<Real>(),
63 const QuantLib::Period& indexTerm = 0 * QuantLib::Days,
64 const boost::optional<bool>& implyDefaultFromMarket = boost::none, const bool allowNegativeRates = false,
65 const int priority = 0);
67 : extrapolation_(true), spotLag_(0), runningSpread_(QuantLib::Null<Real>()), indexTerm_(0 * QuantLib::Days),
68 allowNegativeRates_(false) {}
69
70 void fromXML(XMLNode* node) override;
71 XMLNode* toXML(XMLDocument& doc) const override;
72
73 //! \name Inspectors
74 //@{
75 const int priority() const { return priority_; }
76 const Type& type() const { return type_; }
77 const string& discountCurveID() const { return discountCurveID_; }
78 const string& benchmarkCurveID() const { return benchmarkCurveID_; }
79 const string& sourceCurveID() const { return sourceCurveID_; }
80 const string& recoveryRateQuote() const { return recoveryRateQuote_; }
81 const string& conventionID() const { return conventionID_; }
82 const DayCounter& dayCounter() const { return dayCounter_; }
83 const std::vector<string>& pillars() const { return pillars_; }
84 const Calendar& calendar() const { return calendar_; }
85 const Size& spotLag() const { return spotLag_; }
86 bool extrapolation() const { return extrapolation_; }
87 const std::vector<std::pair<std::string, bool>>& cdsQuotes() const { return cdsQuotes_; }
88 const QuantLib::Date& startDate() const { return startDate_; }
90 const Real runningSpread() const { return runningSpread_; }
91 const QuantLib::Period& indexTerm() const { return indexTerm_; }
92 const boost::optional<bool>& implyDefaultFromMarket() const { return implyDefaultFromMarket_; }
93 const vector<string>& multiSectionSourceCurveIds() const { return multiSectionSourceCurveIds_; }
94 const vector<string>& multiSectionSwitchDates() const { return multiSectionSwitchDates_; }
95 const bool allowNegativeRates() const { return allowNegativeRates_; }
96 const string& initialState() const { return initialState_; }
97 const vector<string>& states() const { return states_; }
98 //@}
99
100 //! \name Setters
101 //@{
102 int& priority() { return priority_; }
103 Type& type() { return type_; }
104 string& discountCurveID() { return discountCurveID_; }
106 string& sourceCurveID() { return sourceCurveID_; }
108 string& conventionID() { return conventionID_; }
109 DayCounter& dayCounter() { return dayCounter_; }
110 std::vector<string> pillars() { return pillars_; }
111 Calendar calendar() { return calendar_; }
112 Size spotLag() { return spotLag_; }
113 bool& extrapolation() { return extrapolation_; }
114 QuantLib::Date& startDate() { return startDate_; }
116 Real& runningSpread() { return runningSpread_; }
117 QuantLib::Period& indexTerm() { return indexTerm_; }
118 boost::optional<bool>& implyDefaultFromMarket() { return implyDefaultFromMarket_; }
120 //@}
121
122 private:
123 //! Quote and optional flag pair
124 std::vector<std::pair<std::string, bool>> cdsQuotes_;
128 DayCounter dayCounter_;
133 vector<string> pillars_;
134 Calendar calendar_;
136 QuantLib::Date startDate_;
139 QuantLib::Period indexTerm_;
143 vector<string> states_;
144
145 /*! Indicates if the reference entity's default status should be implied from the market data. If \c true, this
146 behaviour is active and if \c false it is not. If not explicitly set, it is assumed to be \c false.
147
148 When a default credit event has been determined for an entity, certain market data providers continue to
149 supply a recovery rate from the credit event determination date up to the credit event auction settlement
150 date. In this period, no CDS spreads or upfront prices are provided.
151
152 When this flag is \c true, we assume an entity is in default if we find a recovery rate in the market but no
153 CDS spreads or upfront prices. In this case, we build a survival probability curve with a value of 0.0
154 tomorrow. This will give some approximation to the correct price for CDS and index CDS in these cases.
155
156 When this flag is \c false, we make no such assumption and the default curve building fails.
157 */
158 boost::optional<bool> implyDefaultFromMarket_;
159
160 /*! If this flag is set to true, the checks for negative hazard rates are disabled when building a curve of type
161 - HazardRate
162 - Benchmark
163 */
165
166 int priority_ = 0;
167 };
168
169 //! the curve builder will try to build the configs by ascending key in the map, first success wins
170 DefaultCurveConfig(const string& curveId, const string& curveDescription, const string& currency,
171 const std::map<int, Config>& configs);
172 //! single config ctor
173 DefaultCurveConfig(const string& curveID, const string& curveDescription, const string& currency,
174 const Config& config)
176 //! default ctor
178
179 //! \name Serialisation
180 //@{
181 void fromXML(XMLNode* node) override;
182 XMLNode* toXML(XMLDocument& doc) const override;
183 //@}
184
185 const string& currency() const { return currency_; }
186 const std::map<int, Config>& configs() const { return configs_; }
187
188private:
189 void populateQuotes();
191 void populateRequiredCurveIds(const std::string& discountCurveID, const std::string& benchmarkCurveID,
192 const std::string& sourceCurveID,
193 const std::vector<std::string>& multiSectionSourceCurveIds);
194 std::string currency_;
195 std::map<int, Config> configs_;
196};
197
198} // namespace data
199} // namespace ore
Class for holding bootstrap configurations.
Base curve configuration.
Definition: curveconfig.hpp:41
const string & curveDescription() const
Definition: curveconfig.hpp:55
const string & curveID() const
Definition: curveconfig.hpp:54
Type
Supported default curve types.
const QuantLib::Period & indexTerm() const
const QuantLib::Date & startDate() const
const vector< string > & multiSectionSwitchDates() const
const boost::optional< bool > & implyDefaultFromMarket() const
boost::optional< bool > & implyDefaultFromMarket()
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
void setBootstrapConfig(const BootstrapConfig &bootstrapConfig)
const std::vector< string > & pillars() const
const vector< string > & states() const
const std::vector< std::pair< std::string, bool > > & cdsQuotes() const
Config(const Type &type, const string &discountCurveID, const string &recoveryRateQuote, const DayCounter &dayCounter, const string &conventionID, const std::vector< std::pair< std::string, bool > > &cdsQuotes={}, bool extrapolation=true, const string &benchmarkCurveID="", const string &sourceCurveID="", const std::vector< string > &pillars=std::vector< string >(), const Calendar &calendar=Calendar(), const Size spotLag=0, const QuantLib::Date &startDate=QuantLib::Date(), const BootstrapConfig &bootstrapConfig=BootstrapConfig(), QuantLib::Real runningSpread=QuantLib::Null< Real >(), const QuantLib::Period &indexTerm=0 *QuantLib::Days, const boost::optional< bool > &implyDefaultFromMarket=boost::none, const bool allowNegativeRates=false, const int priority=0)
const vector< string > & multiSectionSourceCurveIds() const
boost::optional< bool > implyDefaultFromMarket_
const BootstrapConfig & bootstrapConfig() const
std::vector< std::pair< std::string, bool > > cdsQuotes_
Quote and optional flag pair.
Default curve configuration.
DefaultCurveConfig(const string &curveID, const string &curveDescription, const string &currency, const Config &config)
single config 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.
Definition: xmlutils.hpp:65
Base class for all serializable classes.
Definition: xmlutils.hpp:101
Base curve configuration classes.
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23