Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
modelparameter.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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/model/modelparameter.hpp
20 \brief class for holding model parameter data
21 \ingroup models
22*/
23
24#pragma once
25
26#include <ql/types.hpp>
29#include <boost/optional.hpp>
30#include <vector>
31
32namespace ore {
33namespace data {
34
35/*! Abstract base class for holding model parameter data.
36 \ingroup models
37*/
39public:
40 //! Default constructor
42
43 //! Detailed constructor
44 ModelParameter(bool calibrate, ParamType type, std::vector<QuantLib::Time> times,
45 std::vector<QuantLib::Real> values);
46
47 //! \name Inspectors
48 //@{
49 bool calibrate() const;
50 ParamType type() const;
51 const std::vector<QuantLib::Time>& times() const;
52 const std::vector<QuantLib::Real>& values() const;
53 //@}
54
55 //! \name Setters / Modifiers
56
57 //@{
58 void setTimes(std::vector<Real> times);
59 void setValues(std::vector<Real> values);
60 void mult(const Real f);
61 void setCalibrate(const bool b);
62 //@}
63
64 //! \name Serialisation
65 //@{
66 void fromXML(XMLNode* node) override;
67 //@}
68
69protected:
70 //! Method used by toXML in derived classes to add the members here to a node.
71 void append(XMLDocument& doc, XMLNode* node) const;
72
73 //! Perform some checks on the parameters
74 virtual void check() const;
75
76private:
79 std::vector<QuantLib::Time> times_;
80 std::vector<QuantLib::Real> values_;
81};
82
83/*! Volatility model parameter with optional volatility type.
84
85 \note
86 The volatility type is currently an LGM volatility type. We may want to broaden this in future.
87
88 \ingroup models
89*/
91public:
92 //! Default constructor
94
95 //! Constructor for piecewise volatility with an explicit volatility type.
97 std::vector<QuantLib::Time> times, std::vector<QuantLib::Real> values);
98
99 //! Constructor for constant volatility with an explicit volatility type.
101 bool calibrate,
102 QuantLib::Real value);
103
104 //! Constructor for piecewise volatility without an explicit volatility type.
105 VolatilityParameter(bool calibrate, ParamType type, std::vector<QuantLib::Real> times,
106 std::vector<QuantLib::Real> values);
107
108 //! Constructor for constant volatility without an explicit volatility type.
109 VolatilityParameter(bool calibrate, QuantLib::Real value);
110
111 //! \name Inspectors
112 //@{
113 const boost::optional<LgmData::VolatilityType>& volatilityType() const;
114 //@}
115
116 //! \name Serialisation
117 //@{
118 void fromXML(XMLNode* node) override;
119 XMLNode* toXML(XMLDocument& doc) const override;
120 //@}
121
122private:
123 boost::optional<LgmData::VolatilityType> volatilityType_;
124};
125
126/*! Reversion model parameter with specified reversion type.
127
128 \note
129 The reversion type is currently an LGM reversion type. We may want to broaden this in future.
130
131 \ingroup models
132*/
134public:
135 //! Default constructor
137
138 //! Constructor for piecewise reversion
140 std::vector<QuantLib::Time> times, std::vector<QuantLib::Real> values);
141
142 //! Constructor for constant reversion
144
145 //! \name Inspectors
146 //@{
148 //@}
149
150 //! \name Serialisation
151 //@{
152 void fromXML(XMLNode* node) override;
153 XMLNode* toXML(XMLDocument& doc) const override;
154 //@}
155
156private:
158};
159
160}
161}
ReversionType
Supported mean reversion types.
Definition: lgmdata.hpp:56
VolatilityType
Supported volatility types.
Definition: lgmdata.hpp:67
const std::vector< QuantLib::Time > & times() const
virtual void check() const
Perform some checks on the parameters.
void setValues(std::vector< Real > values)
void mult(const Real f)
std::vector< QuantLib::Real > values_
void append(XMLDocument &doc, XMLNode *node) const
Method used by toXML in derived classes to add the members here to a node.
ModelParameter()
Default constructor.
void fromXML(XMLNode *node) override
void setTimes(std::vector< Real > times)
std::vector< QuantLib::Time > times_
ModelParameter(bool calibrate, ParamType type, std::vector< QuantLib::Time > times, std::vector< QuantLib::Real > values)
Detailed constructor.
const std::vector< QuantLib::Real > & values() const
void setCalibrate(const bool b)
LgmData::ReversionType reversionType_
ReversionParameter(LgmData::ReversionType reversionType, bool calibrate, QuantLib::Real value)
Constructor for constant reversion.
ReversionParameter(LgmData::ReversionType reversionType, bool calibrate, ParamType type, std::vector< QuantLib::Time > times, std::vector< QuantLib::Real > values)
Constructor for piecewise reversion.
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
LgmData::ReversionType reversionType() const
ReversionParameter()
Default constructor.
const boost::optional< LgmData::VolatilityType > & volatilityType() const
VolatilityParameter(bool calibrate, ParamType type, std::vector< QuantLib::Real > times, std::vector< QuantLib::Real > values)
Constructor for piecewise volatility without an explicit volatility type.
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
VolatilityParameter()
Default constructor.
VolatilityParameter(LgmData::VolatilityType volatilityType, bool calibrate, ParamType type, std::vector< QuantLib::Time > times, std::vector< QuantLib::Real > values)
Constructor for piecewise volatility with an explicit volatility type.
boost::optional< LgmData::VolatilityType > volatilityType_
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
Base class for all serializable classes.
Definition: xmlutils.hpp:101
SafeStack< ValueType > value
Linear Gauss Markov model data.
@ data
Definition: log.hpp:77
ParamType
Supported calibration parameter type.
Definition: irmodeldata.hpp:35
Serializable Credit Default Swap.
Definition: namespaces.docs:23
XML utility functions.