Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
curvespec.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/marketdata/curvespec.hpp
20 \brief Curve requirements specification
21 \ingroup curves
22*/
23
24#pragma once
25
26#include <ql/shared_ptr.hpp>
27
28#include <ostream>
29#include <string>
30
31namespace ore {
32namespace data {
33using std::string;
34
35//! Curve Specification
36/*!
37 Base class for curve descriptions
38 \ingroup curves
39 */
40class CurveSpec {
41public:
42 //! Supported curve types
43 enum class CurveType {
44 FX,
45 Yield,
50 Default,
54 Equity,
61 };
62
63 //! Default constructor
65
66 //! Constructor that takes an underlying CurveConfig id
68
69 //! Default destructor
70 virtual ~CurveSpec() {}
71
72 //! \name Interface
73 //@{
74 virtual CurveType baseType() const = 0;
75 virtual string subName() const = 0;
76
77 //! returns the unique curve name
78 string name() const { return baseName() + "/" + subName(); }
79
80 /*! Returns the id of the CurveConfig associated with the CurveSpec. If there is no CurveConfig associated
81 with the CurveSpec, it returns the default empty string.
82 */
83 const std::string& curveConfigID() const { return curveConfigID_; }
84
85 string baseName() const;
86 //@}
87private:
88 //! The id of the CurveConfig associated with the CurveSpec, if any.
89 std::string curveConfigID_;
90};
91
92//! Stream operator for CurveSpec
93std::ostream& operator<<(std::ostream& os, const CurveSpec& spec);
94//! Stream operator for CurveType
95std::ostream& operator<<(std::ostream& os, const CurveSpec::CurveType& t);
96
97//! Relational operators for CurveSpecs
98//@{
99bool operator<(const CurveSpec& lhs, const CurveSpec& rhs);
100bool operator==(const CurveSpec& lhs, const CurveSpec& rhs);
101bool operator<(const QuantLib::ext::shared_ptr<CurveSpec>& lhs, const QuantLib::ext::shared_ptr<CurveSpec>& rhs);
102bool operator==(const QuantLib::ext::shared_ptr<CurveSpec>& lhs, const QuantLib::ext::shared_ptr<CurveSpec>& rhs);
103//@}
104
105//! Yield curve description
106/*! \ingroup curves
107 */
108class YieldCurveSpec : public CurveSpec {
109public:
110 //! \name Constructors
111 //@{
112 //! Detailed constructor
113 YieldCurveSpec(const string& ccy, const string& curveConfigID) : CurveSpec(curveConfigID), ccy_(ccy) {}
114 //! Default constructor
116 //@}
117
118 //! \name Inspectors
119 //@{
120 CurveType baseType() const override { return CurveType::Yield; }
121 const string& ccy() const { return ccy_; }
122 string subName() const override { return ccy_ + "/" + curveConfigID(); }
123 //@}
124
125protected:
126 string ccy_;
127};
128
129//! Default curve description
130/*! \ingroup curves
131 */
133public:
134 //! \name Constructors
135 //@{
136 //! Detailed constructor
137 DefaultCurveSpec(const string& ccy, const string& curveConfigID) : CurveSpec(curveConfigID), ccy_(ccy) {}
138 //! Default constructor
140 //@}
141
142 //! \name Inspectors
143 //@{
144 CurveType baseType() const override { return CurveType::Default; }
145 const string& ccy() const { return ccy_; }
146 string subName() const override { return ccy_ + "/" + curveConfigID(); }
147 //@}
148
149private:
150 string ccy_;
151};
152
153//! CDS Volatility curve description
154/*! \ingroup curves
155 */
157public:
158 //! \name Constructors
159 //@{
160 //! Default constructor
162 //! Detailed constructor
164 //@}
165
166 //! \name Inspectors
167 //@{
168 CurveType baseType() const override { return CurveType::CDSVolatility; }
169 string subName() const override { return curveConfigID(); }
170 //@}
171private:
172 string ccy_;
174};
175
176//! Base Correlation surface description
177/*! \ingroup curves
178 */
180public:
181 //! \name Constructors
182 //@{
183 //! Default constructor
185 //! Detailed constructor
187 //@}
188
189 //! \name Inspectors
190 //@{
191 CurveType baseType() const override { return CurveType::BaseCorrelation; }
192 string subName() const override { return curveConfigID(); }
193 //@}
194};
195
196//! Swaption Volatility curve description
197/*! \ingroup curves
198 */
200public:
201 //! \name Constructors
202 //@{
203 //! Default constructor
205 //! Detailed constructor
207 //@}
208
209 //! \name Inspectors
210 //@{
212 const string& key() const { return key_; }
213 string subName() const override { return key() + "/" + curveConfigID(); }
214 //@}
215private:
216 string key_;
217};
218
219//! Yield volatility curve description
220/*! \ingroup curves
221 */
223public:
224 //! \name Constructors
225 //@{
226 //! Default constructor
228 //! Detailed constructor
230 //@}
231 //! \name Inspectors
232 //@{
233 CurveType baseType() const override { return CurveType::YieldVolatility; }
234 string subName() const override { return curveConfigID(); }
235 //@}
236};
237
238//! Cap/Floor Volatility curve description
240public:
242 // key is an index name (Ibor, OIS) or a currency
244
245 //! \name CurveSpec interface
246 //@{
248 string subName() const override { return key() + "/" + curveConfigID(); }
249 //@}
250
251 //! \name Inspectors
252 //@{
253 const string& key() const { return key_; }
254 //@}
255
256private:
257 string key_;
258};
259
260//! FX Spot description
261/*! \ingroup curves
262 */
263class FXSpotSpec : public CurveSpec {
264public:
265 //! \name Constructors
266 //@{
267 //! Default constructor
269 //! Detailed constructor
270 FXSpotSpec(string unitCcy, string ccy) : unitCcy_(unitCcy), ccy_(ccy) {}
271 //@}
272
273 //! \name Inspectors
274 //@{
275 CurveType baseType() const override { return CurveType::FX; }
276 const string& unitCcy() const { return unitCcy_; }
277 const string& ccy() const { return ccy_; }
278 string subName() const override { return unitCcy() + "/" + ccy(); }
279 //@}
280private:
281 string unitCcy_;
282 string ccy_;
283};
284
285//! FX Volatility curve description
286/*! \ingroup curves
287 */
289public:
290 //! \name Constructors
291 //@{
292 //! Default constructor
294 //! Detailed constructor
295 FXVolatilityCurveSpec(const string& unitCcy, const string& ccy, const string& curveConfigID)
297 //@}
298
299 //! \name Inspectors
300 //@{
301 CurveType baseType() const override { return CurveType::FXVolatility; }
302 const string& unitCcy() const { return unitCcy_; }
303 const string& ccy() const { return ccy_; }
304 string subName() const override { return unitCcy() + "/" + ccy() + "/" + curveConfigID(); }
305 //@}
306private:
307 string unitCcy_;
308 string ccy_;
309};
310
311//! Inflation curve description
312/*! \ingroup curves
313 */
315public:
318
319 CurveType baseType() const override { return CurveType::Inflation; }
320 const string& index() const { return index_; }
321
322 string subName() const override { return index() + "/" + curveConfigID(); }
323
324private:
325 string index_;
326};
327
328//! Inflation cap floor volatility description
329/*! \ingroup curves
330 */
332public:
336
338 const string& index() const { return index_; }
339
340 string subName() const override { return index() + "/" + curveConfigID(); }
341
342private:
343 string index_;
344};
345
346//! Equity curve description
347/*! \ingroup curves
348 */
350
351public:
352 //! \name Constructors
353 //@{
354 //! Detailed constructor
355 EquityCurveSpec(const string& ccy, const string& curveConfigID) : CurveSpec(curveConfigID), ccy_(ccy) {}
356 //! Default constructor
358
359 //@}
360
361 //! \name Inspectors
362 //@{
363 CurveType baseType() const override { return CurveType::Equity; }
364 const string& ccy() const { return ccy_; }
365 string subName() const override { return ccy_ + "/" + curveConfigID(); }
366 //@}
367
368private:
369 string ccy_;
370};
371
372//! Equity Volatility curve description
373/*! \ingroup curves
374 */
376public:
377 //! \name Constructors
378 //@{
379 //! Default constructor
381 //! Detailed constructor
383 //@}
384
385 //! \name Inspectors
386 //@{
387 CurveType baseType() const override { return CurveType::EquityVolatility; }
388 const string& ccy() const { return ccy_; }
389 string subName() const override { return ccy() + "/" + curveConfigID(); }
390 //@}
391private:
392 string ccy_;
393};
394
395//! Security description
396class SecuritySpec : public CurveSpec {
397public:
399 //! Default constructor
401 CurveType baseType() const override { return CurveType::Security; }
402 string subName() const override { return securityID_; }
403 const string& securityID() const { return securityID_; }
404 //@}
405
406protected:
408};
409
410//! Commodity curve description
411/*! \ingroup curves
412 */
414
415public:
416 //! \name Constructors
417 //@{
418 //! Default constructor
420
421 //! Detailed constructor
422 CommodityCurveSpec(const std::string& currency, const std::string& curveConfigID)
424 //@}
425
426 //! \name Inspectors
427 //@{
428 CurveType baseType() const override { return CurveType::Commodity; }
429 const std::string& currency() const { return currency_; }
430 std::string subName() const override { return currency_ + "/" + curveConfigID(); }
431 //@}
432
433private:
434 std::string currency_;
435};
436
437//! Commodity volatility description
438/*! \ingroup curves
439 */
441public:
442 //! \name Constructors
443 //@{
444 //! Default constructor
446
447 //! Detailed constructor
448 CommodityVolatilityCurveSpec(const std::string& currency, const std::string& curveConfigID)
450 //@}
451
452 //! \name Inspectors
453 //@{
455 const std::string& currency() const { return currency_; }
456 std::string subName() const override { return currency_ + "/" + curveConfigID(); }
457 //@}
458
459private:
460 std::string currency_;
461 std::string curveConfigId_;
462};
463
464//! Correlation curve description
465/*! \ingroup curves
466 */
468public:
469 //! \name Constructors
470 //@{
471 //! Default constructor
473 //! Detailed constructor
475 //@}
476
477 //! \name Inspectors
478 //@{
479 CurveType baseType() const override { return CurveType::Correlation; }
480 string subName() const override { return curveConfigID(); }
481 //@}
482private:
483};
484
485} // namespace data
486} // namespace ore
Base Correlation surface description.
Definition: curvespec.hpp:179
BaseCorrelationCurveSpec(const string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:186
string subName() const override
Definition: curvespec.hpp:192
BaseCorrelationCurveSpec()
Default constructor.
Definition: curvespec.hpp:184
CurveType baseType() const override
Definition: curvespec.hpp:191
CDS Volatility curve description.
Definition: curvespec.hpp:156
string subName() const override
Definition: curvespec.hpp:169
CurveType baseType() const override
Definition: curvespec.hpp:168
CDSVolatilityCurveSpec()
Default constructor.
Definition: curvespec.hpp:161
CDSVolatilityCurveSpec(const string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:163
Cap/Floor Volatility curve description.
Definition: curvespec.hpp:239
string subName() const override
Definition: curvespec.hpp:248
CapFloorVolatilityCurveSpec(const string &key, const string &curveConfigID)
Definition: curvespec.hpp:243
CurveType baseType() const override
Definition: curvespec.hpp:247
Commodity curve description.
Definition: curvespec.hpp:413
const std::string & currency() const
Definition: curvespec.hpp:429
std::string subName() const override
Definition: curvespec.hpp:430
CurveType baseType() const override
Definition: curvespec.hpp:428
CommodityCurveSpec()
Default constructor.
Definition: curvespec.hpp:419
CommodityCurveSpec(const std::string &currency, const std::string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:422
Commodity volatility description.
Definition: curvespec.hpp:440
const std::string & currency() const
Definition: curvespec.hpp:455
CommodityVolatilityCurveSpec()
Default constructor.
Definition: curvespec.hpp:445
std::string subName() const override
Definition: curvespec.hpp:456
CurveType baseType() const override
Definition: curvespec.hpp:454
CommodityVolatilityCurveSpec(const std::string &currency, const std::string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:448
Correlation curve description.
Definition: curvespec.hpp:467
string subName() const override
Definition: curvespec.hpp:480
CurveType baseType() const override
Definition: curvespec.hpp:479
CorrelationCurveSpec()
Default constructor.
Definition: curvespec.hpp:472
CorrelationCurveSpec(const string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:474
Curve Specification.
Definition: curvespec.hpp:40
CurveType
Supported curve types.
Definition: curvespec.hpp:43
virtual CurveType baseType() const =0
const std::string & curveConfigID() const
Definition: curvespec.hpp:83
virtual ~CurveSpec()
Default destructor.
Definition: curvespec.hpp:70
string baseName() const
Definition: curvespec.cpp:25
virtual string subName() const =0
std::string curveConfigID_
The id of the CurveConfig associated with the CurveSpec, if any.
Definition: curvespec.hpp:89
CurveSpec(const std::string &curveConfigID)
Constructor that takes an underlying CurveConfig id.
Definition: curvespec.hpp:67
CurveSpec()
Default constructor.
Definition: curvespec.hpp:64
string name() const
returns the unique curve name
Definition: curvespec.hpp:78
Default curve description.
Definition: curvespec.hpp:132
DefaultCurveSpec(const string &ccy, const string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:137
string subName() const override
Definition: curvespec.hpp:146
const string & ccy() const
Definition: curvespec.hpp:145
CurveType baseType() const override
Definition: curvespec.hpp:144
DefaultCurveSpec()
Default constructor.
Definition: curvespec.hpp:139
Equity curve description.
Definition: curvespec.hpp:349
string subName() const override
Definition: curvespec.hpp:365
const string & ccy() const
Definition: curvespec.hpp:364
CurveType baseType() const override
Definition: curvespec.hpp:363
EquityCurveSpec()
Default constructor.
Definition: curvespec.hpp:357
EquityCurveSpec(const string &ccy, const string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:355
Equity Volatility curve description.
Definition: curvespec.hpp:375
string subName() const override
Definition: curvespec.hpp:389
EquityVolatilityCurveSpec()
Default constructor.
Definition: curvespec.hpp:380
CurveType baseType() const override
Definition: curvespec.hpp:387
EquityVolatilityCurveSpec(const string &ccy, const string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:382
FX Spot description.
Definition: curvespec.hpp:263
string subName() const override
Definition: curvespec.hpp:278
FXSpotSpec()
Default constructor.
Definition: curvespec.hpp:268
const string & ccy() const
Definition: curvespec.hpp:277
FXSpotSpec(string unitCcy, string ccy)
Detailed constructor.
Definition: curvespec.hpp:270
CurveType baseType() const override
Definition: curvespec.hpp:275
const string & unitCcy() const
Definition: curvespec.hpp:276
FX Volatility curve description.
Definition: curvespec.hpp:288
string subName() const override
Definition: curvespec.hpp:304
const string & ccy() const
Definition: curvespec.hpp:303
CurveType baseType() const override
Definition: curvespec.hpp:301
const string & unitCcy() const
Definition: curvespec.hpp:302
FXVolatilityCurveSpec(const string &unitCcy, const string &ccy, const string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:295
FXVolatilityCurveSpec()
Default constructor.
Definition: curvespec.hpp:293
Inflation cap floor volatility description.
Definition: curvespec.hpp:331
InflationCapFloorVolatilityCurveSpec(const string &index, const string &curveConfigID)
Definition: curvespec.hpp:334
Inflation curve description.
Definition: curvespec.hpp:314
string subName() const override
Definition: curvespec.hpp:322
const string & index() const
Definition: curvespec.hpp:320
InflationCurveSpec(const string &index, const string &curveConfigID)
Definition: curvespec.hpp:317
CurveType baseType() const override
Definition: curvespec.hpp:319
Security description.
Definition: curvespec.hpp:396
string subName() const override
Definition: curvespec.hpp:402
SecuritySpec()
Default constructor.
Definition: curvespec.hpp:400
SecuritySpec(const string &securityID)
Definition: curvespec.hpp:398
CurveType baseType() const override
Definition: curvespec.hpp:401
const string & securityID() const
Definition: curvespec.hpp:403
Swaption Volatility curve description.
Definition: curvespec.hpp:199
string subName() const override
Definition: curvespec.hpp:213
SwaptionVolatilityCurveSpec()
Default constructor.
Definition: curvespec.hpp:204
CurveType baseType() const override
Definition: curvespec.hpp:211
SwaptionVolatilityCurveSpec(const string &key, const string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:206
Yield curve description.
Definition: curvespec.hpp:108
string subName() const override
Definition: curvespec.hpp:122
const string & ccy() const
Definition: curvespec.hpp:121
YieldCurveSpec()
Default constructor.
Definition: curvespec.hpp:115
CurveType baseType() const override
Definition: curvespec.hpp:120
YieldCurveSpec(const string &ccy, const string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:113
Yield volatility curve description.
Definition: curvespec.hpp:222
YieldVolatilityCurveSpec(const string &curveConfigID)
Detailed constructor.
Definition: curvespec.hpp:229
string subName() const override
Definition: curvespec.hpp:234
CurveType baseType() const override
Definition: curvespec.hpp:233
YieldVolatilityCurveSpec()
Default constructor.
Definition: curvespec.hpp:227
@ data
Definition: log.hpp:77
bool operator<(const Dividend &d1, const Dividend &d2)
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
bool operator==(const Dividend &d1, const Dividend &d)
Serializable Credit Default Swap.
Definition: namespaces.docs:23