Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
yoycapfloor.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::Period;
25
26namespace ore {
27namespace data {
28
30 : CalibrationInstrument("YoYCapFloor"), type_(YoYInflationCapFloor::Floor) {}
31
32YoYCapFloor::YoYCapFloor(YoYInflationCapFloor::Type type,
33 const Period& tenor,
34 const QuantLib::ext::shared_ptr<BaseStrike>& strike)
35 : CalibrationInstrument("YoYCapFloor"),
36 type_(type),
37 tenor_(tenor),
38 strike_(strike) {}
39
40YoYInflationCapFloor::Type YoYCapFloor::type() const {
41 return type_;
42}
43
44const QuantLib::Period& YoYCapFloor::tenor() const {
45 return tenor_;
46}
47
48const QuantLib::ext::shared_ptr<BaseStrike>& YoYCapFloor::strike() const {
49 return strike_;
50}
51
55 tenor_ = parsePeriod(XMLUtils::getChildValue(node, "Tenor", true));
56 strike_ = parseBaseStrike(XMLUtils::getChildValue(node, "Strike", true));
57}
58
61 if (type_ == YoYInflationCapFloor::Cap)
62 XMLUtils::addChild(doc, node, "Type", "Cap");
63 else if (type_ == YoYInflationCapFloor::Floor)
64 XMLUtils::addChild(doc, node, "Type", "Floor");
65 else
66 QL_FAIL("Failure in YoYCapFloor::toXML, unsupported YoY cap floor type.");
67 XMLUtils::addChild(doc, node, "Tenor", to_string(tenor_));
68 XMLUtils::addChild(doc, node, "Strike", strike_->toString());
69 return node;
70}
71
72}
73}
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
QuantLib::YoYInflationCapFloor::Type type() const
Definition: yoycapfloor.cpp:40
QuantLib::YoYInflationCapFloor::Type type_
Definition: yoycapfloor.hpp:61
QuantLib::ext::shared_ptr< BaseStrike > strike_
Definition: yoycapfloor.hpp:63
YoYCapFloor()
Default constructor.
Definition: yoycapfloor.cpp:29
void fromXML(XMLNode *node) override
Definition: yoycapfloor.cpp:52
XMLNode * toXML(XMLDocument &doc) const override
Definition: yoycapfloor.cpp:59
const QuantLib::ext::shared_ptr< BaseStrike > & strike() const
Definition: yoycapfloor.cpp:48
const QuantLib::Period & tenor() const
Definition: yoycapfloor.cpp:44
QuantLib::Period tenor_
Definition: yoycapfloor.hpp:62
YoYInflationCapFloor::Type parseYoYInflationCapFloorType(const string &s)
Definition: parsers.cpp:827
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Definition: parsers.cpp:171
@ data
Definition: log.hpp:77
class for holding details of a year on year inflation cap floor calibration instrument.
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