25#include <ql/quotes/simplequote.hpp>
26#include <ql/utilities/dataformatters.hpp>
28#include <boost/algorithm/string/case_conv.hpp>
29#include <boost/lexical_cast.hpp>
73 WLOG(
"HwModelData: attribute ccy is deprecated, use key instead.");
88 LOG(
"Hull White Kappa param type = " << kappaCalibrationString);
92 LOG(
"Hull White Reversion time grid size = " <<
kappaTimes_.size());
98 kappaValues_.push_back(Array(kappa_t.begin(), kappa_t.end()));
101 QL_REQUIRE(!
kappaValues_.empty(),
"No initial mean reversion values given");
104 QL_REQUIRE(nFactors ==
kappaValues_[i].
size(),
"expect " << nFactors <<
" factors but got "
115 QL_REQUIRE(!
calibrateSigma_,
"Calibration of kappa not supported yet");
119 LOG(
"Hull White Volatility param type = " << sigmaParameterTypeString);
123 LOG(
"Hull White volatility time grid size = " <<
sigmaTimes_.size());
128 std::vector<std::vector<double>> matrix;
132 QL_REQUIRE(matrix.back().size() == nFactors,
"Mismatch between kappa and sigma");
134 QL_REQUIRE(!matrix.empty(),
"Sigma not provided");
135 QL_REQUIRE(!matrix.front().empty(),
"Sigma not provided");
136 Matrix sigma(matrix.size(), matrix.front().size(), 0.0);
137 for (
size_t i = 0; i < matrix.size(); ++i) {
138 for (
size_t j = 0; j < nFactors; ++j)
139 sigma[i][j] = matrix[i][j];
144 QL_REQUIRE(!
sigmaValues_.empty(),
"need at least one sigma matrix");
147 QL_REQUIRE(
sigmaValues_[i].rows() == m_brownians,
"all sigma matrixes need to have the same row dimension");
151 LOG(
"HwModelData done");
165 std::ostringstream oss;
166 if (kappa.size() == 0) {
170 for (Size i = 1; i < kappa.size(); i++) {
171 oss <<
", " << kappa[i];
186 for (
size_t row = 0; row < sigma.rows(); ++row) {
187 std::ostringstream oss;
188 if (sigma.columns() == 0) {
191 oss << sigma[row][0];
192 for (Size col = 0; col < sigma.columns(); col++) {
193 oss <<
", " << sigma[row][col];
Hull White Model Parameters.
std::vector< QuantLib::Matrix > & sigmaValues()
std::vector< QuantLib::Array > kappaValues_
std::vector< std::string > optionTerms_
bool operator==(const HwModelData &rhs)
std::vector< std::string > optionExpiries_
std::vector< QuantLib::Matrix > sigmaValues_
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
std::vector< Time > kappaTimes_
std::vector< Time > sigmaTimes_
bool operator!=(const HwModelData &rhs)
void reset() override
Reset member variables to defaults.
void clear() override
Clear list of calibration instruments.
std::vector< std::string > optionStrikes_
CalibrationType calibrationType_
virtual std::string ccy() const
virtual void fromXML(XMLNode *node) override
virtual XMLNode * toXML(XMLDocument &doc) const override
virtual void reset()
Reset member variables to defaults.
Small XML Document wrapper class.
static string getAttribute(XMLNode *node, const string &attrName)
static void addGenericChildAsList(XMLDocument &doc, XMLNode *n, const string &name, const vector< T > &values, const string &attrName="", const string &attr="")
static void addGenericChild(XMLDocument &doc, XMLNode *n, const char *name, const T &value)
Adds <Name>p1,p2,p3</Name>
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static XMLNode * getNextSibling(XMLNode *node, const string &name="")
Get a node's next sibling node.
static vector< Real > getChildrenValuesAsDoublesCompact(XMLNode *node, const string &name, bool mandatory=false)
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static vector< Real > getNodeValueAsDoublesCompact(XMLNode *node)
Get a node's compact values as vector of doubles.
configuration class for building correlation matrices
Classes and functions for log message handling.
#define LOG(text)
Logging Macro (Level = Notice)
#define WLOG(text)
Logging Macro (Level = Warning)
ParamType parseParamType(const string &s)
Convert parameter type string into enumerated class value.
Size size(const ValueType &v)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
string conversion utilities