Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
curvespec.cpp
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
21
22namespace ore {
23namespace data {
24
26
27bool operator<(const CurveSpec& lhs, const CurveSpec& rhs) {
28 if (lhs == rhs) {
29 /* If CurveSpecs are equal (i.e. have same name), return false. */
30 return false;
31 } else if (lhs.baseType() != rhs.baseType()) {
32 /* If types are not the same, use the enum value for ordering along type.
33 * The enum order in the header file is deliberate, it ensures that FX comes before FXVol
34 * this property is used in data::order() (see curveloader.hpp)
35 */
36 return lhs.baseType() < rhs.baseType();
37 } else {
38 /* If types are the same and CurveSpecs are different, use default < for string */
39 return lhs.name() < rhs.name();
40 }
41}
42
43bool operator==(const CurveSpec& lhs, const CurveSpec& rhs) {
44 /* We consider two CurveSpecs equal if they have the same name. */
45 return lhs.name() == rhs.name();
46}
47
48bool operator<(const QuantLib::ext::shared_ptr<CurveSpec>& lhs, const QuantLib::ext::shared_ptr<CurveSpec>& rhs) { return *lhs < *rhs; }
49
50bool operator==(const QuantLib::ext::shared_ptr<CurveSpec>& lhs, const QuantLib::ext::shared_ptr<CurveSpec>& rhs) {
51 return *lhs == *rhs;
52}
53
54std::ostream& operator<<(std::ostream& os, const CurveSpec& spec) { return os << spec.name(); }
55
56std::ostream& operator<<(std::ostream& os, const CurveSpec::CurveType& t) {
57 switch (t) {
59 return os << "Yield";
61 return os << "CapFloorVolatility";
63 return os << "SwaptionVolatility";
65 return os << "YieldVolatility";
67 return os << "FX";
69 return os << "FXVolatility";
71 return os << "Security";
73 return os << "Default";
75 return os << "CDSVolatility";
77 return os << "Inflation";
79 return os << "InflationCapFloorVolatility";
81 return os << "Equity";
83 return os << "EquityVolatility";
85 return os << "BaseCorrelation";
87 return os << "Commodity";
89 return os << "CommodityVolatility";
91 return os << "Correlation";
92 default:
93 return os << "N/A";
94 }
95}
96} // namespace data
97} // namespace ore
Curve Specification.
Definition: curvespec.hpp:40
CurveType
Supported curve types.
Definition: curvespec.hpp:43
virtual CurveType baseType() const =0
string baseName() const
Definition: curvespec.cpp:25
string name() const
returns the unique curve name
Definition: curvespec.hpp:78
Curve requirements specification.
@ 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)
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
Serializable Credit Default Swap.
Definition: namespaces.docs:23
string conversion utilities