Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
irmodeldata.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 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
20#include <boost/algorithm/string/case_conv.hpp>
21#include <boost/lexical_cast.hpp>
24
25namespace ore {
26namespace data {
27
28std::ostream& operator<<(std::ostream& oss, const ParamType& type) {
29 if (type == ParamType::Constant)
30 oss << "CONSTANT";
31 else if (type == ParamType::Piecewise)
32 oss << "PIECEWISE";
33 else
34 QL_FAIL("Parameter type not covered by <<");
35 return oss;
36}
37
38ParamType parseParamType(const string& s) {
39 if (boost::algorithm::to_upper_copy(s) == "CONSTANT")
41 else if (boost::algorithm::to_upper_copy(s) == "PIECEWISE")
43 else
44 QL_FAIL("Parameter type " << s << " not recognized");
45}
46
48 if (boost::algorithm::to_upper_copy(s) == "BOOTSTRAP")
50 else if (boost::algorithm::to_upper_copy(s) == "BESTFIT")
52 else if (boost::algorithm::to_upper_copy(s) == "NONE")
54 else
55 QL_FAIL("Calibration type " << s << " not recognized");
56}
57
58std::ostream& operator<<(std::ostream& oss, const CalibrationType& type) {
60 oss << "BOOTSTRAP";
61 else if (type == CalibrationType::BestFit)
62 oss << "BESTFIT";
63 else if (type == CalibrationType::None)
64 oss << "NONE";
65 else
66 QL_FAIL("Calibration type not covered");
67 return oss;
68}
69
71 if (boost::algorithm::to_upper_copy(s) == "COTERMINALATM")
73 else if (boost::algorithm::to_upper_copy(s) == "COTERMINALDEALSTRIKE")
75 else if (boost::algorithm::to_upper_copy(s) == "UNDERLYINGATM")
77 else if (boost::algorithm::to_upper_copy(s) == "UNDERLYINGDEALSTRIKE")
79 else if (boost::algorithm::to_upper_copy(s) == "NONE")
81 else
82 QL_FAIL("Calibration strategy " << s << " not recognized");
83}
84
85std::ostream& operator<<(std::ostream& oss, const CalibrationStrategy& type) {
87 oss << "COTERMINALATM";
89 oss << "COTERMINALDEALSTRIKE";
91 oss << "UNDERLYINGATM";
93 oss << "UNDERLYINGDEALSTRIKE";
94 else if (type == CalibrationStrategy::None)
95 oss << "NONE";
96 else
97 QL_FAIL("Calibration strategy not covered");
98 return oss;
99}
100
102
104 clear();
105 qualifier_ = "";
107}
108
110 std::string calibTypeString = XMLUtils::getChildValue(node, "CalibrationType", true);
111
112 calibrationType_ = parseCalibrationType(calibTypeString);
113 LOG(name_ + " with calibrationType_ = " << qualifier_);
114}
115
117
118 XMLNode* irModelNode = doc.allocNode(name_);
119
120 XMLUtils::addGenericChild(doc, irModelNode, "CalibrationType", calibrationType_);
121 return irModelNode;
122}
123
124std::string IrModelData::ccy() const{
125 QuantLib::ext::shared_ptr<QuantLib::IborIndex> index;
126 return tryParseIborIndex(qualifier_, index) ? index->currency().code() : qualifier_;
127}
128
129} // namespace data
130} // namespace ore
CalibrationType calibrationType_
virtual std::string ccy() const
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
virtual void clear()
Clear list of calibration instruments.
virtual void reset()
Reset member variables to defaults.
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 addGenericChild(XMLDocument &doc, XMLNode *n, const char *name, const T &value)
Adds <Name>p1,p2,p3</Name>
Definition: xmlutils.hpp:137
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
bool tryParseIborIndex(const string &s, QuantLib::ext::shared_ptr< IborIndex > &index)
Try to convert std::string to QuantLib::IborIndex.
Map text representations to QuantLib/QuantExt types.
Generic interest rate model data.
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
CalibrationType
Supported calibration types.
Definition: irmodeldata.hpp:46
ParamType
Supported calibration parameter type.
Definition: irmodeldata.hpp:35
CalibrationType parseCalibrationType(const string &s)
Convert calibration type string into enumerated class value.
Definition: irmodeldata.cpp:47
CalibrationStrategy parseCalibrationStrategy(const string &s)
Convert calibration strategy string into enumerated class value.
Definition: irmodeldata.cpp:70
ParamType parseParamType(const string &s)
Convert parameter type string into enumerated class value.
Definition: irmodeldata.cpp:38
CalibrationStrategy
Supported calibration strategies.
Definition: irmodeldata.hpp:69
Serializable Credit Default Swap.
Definition: namespaces.docs:23