Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cpicapfloor.cpp
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
22
23using QuantLib::CapFloor;
24using QuantLib::Date;
25using QuantLib::Period;
26
27namespace ore {
28namespace data {
29
31
32CpiCapFloor::CpiCapFloor(CapFloor::Type type,
33 const boost::variant<QuantLib::Date, Period> & maturity,
34 const QuantLib::ext::shared_ptr<BaseStrike>& strike)
35 : CalibrationInstrument("CpiCapFloor"),
36 type_(type),
37 maturity_(maturity),
38 strike_(strike) {}
39
40CapFloor::Type CpiCapFloor::type() const {
41 return type_;
42}
43
44const boost::variant<Date, Period>& CpiCapFloor::maturity() const {
45 return maturity_;
46}
47
48const QuantLib::ext::shared_ptr<BaseStrike>& CpiCapFloor::strike() const { return strike_; }
49
52 type_ = parseCapFloorType(XMLUtils::getChildValue(node, "Type", true));
53 maturity_ = parseDateOrPeriod(XMLUtils::getChildValue(node, "Maturity", true));
54 strike_ = parseBaseStrike(XMLUtils::getChildValue(node, "Strike", true));
55}
56
59 XMLUtils::addChild(doc, node, "Type", to_string(type_));
60 XMLUtils::addChild(doc, node, "Maturity", to_string(maturity_));
61 XMLUtils::addChild(doc, node, "Strike", strike_->toString());
62 return node;
63}
64
65} // namespace data
66} // namespace ore
Serializable cap, floor, collar.
Definition: capfloor.hpp:37
QuantLib::CapFloor::Type type_
Definition: cpicapfloor.hpp:64
QuantLib::ext::shared_ptr< BaseStrike > strike_
Definition: cpicapfloor.hpp:66
void fromXML(XMLNode *node) override
Definition: cpicapfloor.cpp:50
XMLNode * toXML(XMLDocument &doc) const override
Definition: cpicapfloor.cpp:57
const QuantLib::ext::shared_ptr< BaseStrike > & strike() const
Definition: cpicapfloor.cpp:48
boost::variant< QuantLib::Date, QuantLib::Period > maturity_
Definition: cpicapfloor.hpp:65
CpiCapFloor()
Default constructor.
Definition: cpicapfloor.cpp:30
const boost::variant< QuantLib::Date, QuantLib::Period > & maturity() const
Definition: cpicapfloor.cpp:44
QuantLib::CapFloor::Type type() const
Definition: cpicapfloor.cpp:40
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 checkNode(XMLNode *n, const string &expectedName)
Definition: xmlutils.cpp:175
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
Definition: xmlutils.cpp:277
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
boost::variant< QuantLib::Date, QuantLib::Period > parseDateOrPeriod(const string &s)
Convert text to QuantLib::Period or QuantLib::Date.
Definition: parsers.cpp:493
CapFloor::Type parseCapFloorType(const string &s)
Definition: parsers.cpp:815
@ data
Definition: log.hpp:77
class for holding details of a zero coupon CPI cap floor calibration instrument.
Time maturity
Definition: utilities.cpp:66
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
QuantLib::ext::shared_ptr< BaseStrike > parseBaseStrike(const string &strStrike)
Parse a Strike from its string representation, strStrike.
Definition: strike.cpp:262
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.
string conversion utilities