Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
FloatingLegData Class Reference

Serializable Floating Leg Data. More...

#include <ored/portfolio/legdata.hpp>

+ Inheritance diagram for FloatingLegData:
+ Collaboration diagram for FloatingLegData:

Public Member Functions

 FloatingLegData ()
 Default constructor. More...
 
 FloatingLegData (const string &index, QuantLib::Size fixingDays, bool isInArrears, const vector< double > &spreads, const vector< string > &spreadDates=vector< string >(), const vector< double > &caps=vector< double >(), const vector< string > &capDates=vector< string >(), const vector< double > &floors=vector< double >(), const vector< string > &floorDates=vector< string >(), const vector< double > &gearings=vector< double >(), const vector< string > &gearingDates=vector< string >(), bool isAveraged=false, bool nakedOption=false, bool hasSubPeriods=false, bool includeSpread=false, QuantLib::Period lookback=0 *Days, const Size rateCutoff=Null< Size >(), bool localCapFloor=false, const boost::optional< Period > &lastRecentPeriod=boost::none, const std::string &lastRecentPeriodCalendar=std::string(), bool telescopicValueDates=false, const std::map< QuantLib::Date, double > &historicalFixings={})
 Constructor. More...
 
Inspectors
const string & index () const
 
QuantLib::Size fixingDays () const
 
QuantLib::Period lookback () const
 
QuantLib::Size rateCutoff () const
 
boost::optional< boolisInArrears () const
 
bool isAveraged () const
 
bool hasSubPeriods () const
 
bool includeSpread () const
 
const vector< double > & spreads () const
 
const vector< string > & spreadDates () const
 
const vector< double > & caps () const
 
const vector< string > & capDates () const
 
const vector< double > & floors () const
 
const vector< string > & floorDates () const
 
const vector< double > & gearings () const
 
const vector< string > & gearingDates () const
 
bool nakedOption () const
 
bool localCapFloor () const
 
const boost::optional< Period > & lastRecentPeriod () const
 
const std::string & lastRecentPeriodCalendar () const
 
bool telescopicValueDates () const
 
ScheduleData fixingSchedule () const
 
ScheduleData resetSchedule () const
 
const std::map< QuantLib::Date, double > & historicalFixings () const
 
Modifiers
vector< double > & caps ()
 
vector< string > & capDates ()
 
vector< double > & floors ()
 
vector< string > & floorDates ()
 
boolnakedOption ()
 
boollocalCapFloor ()
 
booltelescopicValueDates ()
 
- Public Member Functions inherited from LegAdditionalData
 LegAdditionalData (const string &legType, const string &legNodeName)
 
 LegAdditionalData (const string &legType)
 
const string & legType () const
 
const string & legNodeName () const
 
const std::set< std::string > & indices () const
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const =0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 Parse from XML string. More...
 
std::string toXMLString () const
 Parse from XML string. More...
 

Serialisation

string index_
 
QuantLib::Size fixingDays_ = Null<Size>()
 
QuantLib::Period lookback_ = 0 * Days
 
QuantLib::Size rateCutoff_ = Null<Size>()
 
boost::optional< boolisInArrears_
 
bool isAveraged_ = false
 
bool hasSubPeriods_ = false
 
bool includeSpread_ = false
 
vector< double > spreads_
 
vector< string > spreadDates_
 
vector< double > caps_
 
vector< string > capDates_
 
vector< double > floors_
 
vector< string > floorDates_
 
vector< double > gearings_
 
vector< string > gearingDates_
 
bool nakedOption_ = false
 
bool localCapFloor_ = false
 
boost::optional< Period > lastRecentPeriod_
 
std::string lastRecentPeriodCalendar_
 
bool telescopicValueDates_ = false
 
ScheduleData fixingSchedule_
 
ScheduleData resetSchedule_
 
std::map< QuantLib::Date, double > historicalFixings_
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 

Additional Inherited Members

- Protected Attributes inherited from LegAdditionalData
std::set< std::string > indices_
 

Detailed Description

Serializable Floating Leg Data.

Definition at line 179 of file legdata.hpp.

Constructor & Destructor Documentation

◆ FloatingLegData() [1/2]

Default constructor.

Definition at line 182 of file legdata.hpp.

182: LegAdditionalData("Floating") {}
LegAdditionalData(const string &legType, const string &legNodeName)
Definition: legdata.hpp:65

◆ FloatingLegData() [2/2]

FloatingLegData ( const string &  index,
QuantLib::Size  fixingDays,
bool  isInArrears,
const vector< double > &  spreads,
const vector< string > &  spreadDates = vector<string>(),
const vector< double > &  caps = vector<double>(),
const vector< string > &  capDates = vector<string>(),
const vector< double > &  floors = vector<double>(),
const vector< string > &  floorDates = vector<string>(),
const vector< double > &  gearings = vector<double>(),
const vector< string > &  gearingDates = vector<string>(),
bool  isAveraged = false,
bool  nakedOption = false,
bool  hasSubPeriods = false,
bool  includeSpread = false,
QuantLib::Period  lookback = 0 * Days,
const Size  rateCutoff = Null<Size>(),
bool  localCapFloor = false,
const boost::optional< Period > &  lastRecentPeriod = boost::none,
const std::string &  lastRecentPeriodCalendar = std::string(),
bool  telescopicValueDates = false,
const std::map< QuantLib::Date, double > &  historicalFixings = {} 
)

Constructor.

Definition at line 184 of file legdata.hpp.

194 {})
202 indices_.insert(index_);
203 }
const vector< double > & floors() const
Definition: legdata.hpp:219
QuantLib::Period lookback() const
Definition: legdata.hpp:209
QuantLib::Size rateCutoff() const
Definition: legdata.hpp:210
const std::map< QuantLib::Date, double > & historicalFixings() const
Definition: legdata.hpp:230
vector< string > gearingDates_
Definition: legdata.hpp:265
std::map< QuantLib::Date, double > historicalFixings_
Definition: legdata.hpp:273
bool nakedOption() const
Definition: legdata.hpp:223
const vector< double > & spreads() const
Definition: legdata.hpp:215
QuantLib::Size fixingDays() const
Definition: legdata.hpp:208
bool includeSpread() const
Definition: legdata.hpp:214
vector< double > gearings_
Definition: legdata.hpp:264
const vector< string > & gearingDates() const
Definition: legdata.hpp:222
QuantLib::Size rateCutoff_
Definition: legdata.hpp:253
const string & index() const
Definition: legdata.hpp:207
vector< double > floors_
Definition: legdata.hpp:262
vector< string > floorDates_
Definition: legdata.hpp:263
boost::optional< Period > lastRecentPeriod_
Definition: legdata.hpp:268
boost::optional< bool > isInArrears_
Definition: legdata.hpp:254
boost::optional< bool > isInArrears() const
Definition: legdata.hpp:211
vector< double > spreads_
Definition: legdata.hpp:258
std::string lastRecentPeriodCalendar_
Definition: legdata.hpp:269
const vector< double > & caps() const
Definition: legdata.hpp:217
QuantLib::Size fixingDays_
Definition: legdata.hpp:251
bool localCapFloor() const
Definition: legdata.hpp:224
const vector< string > & spreadDates() const
Definition: legdata.hpp:216
const vector< string > & floorDates() const
Definition: legdata.hpp:220
const boost::optional< Period > & lastRecentPeriod() const
Definition: legdata.hpp:225
const vector< double > & gearings() const
Definition: legdata.hpp:221
const std::string & lastRecentPeriodCalendar() const
Definition: legdata.hpp:226
bool hasSubPeriods() const
Definition: legdata.hpp:213
const vector< string > & capDates() const
Definition: legdata.hpp:218
vector< string > capDates_
Definition: legdata.hpp:261
vector< double > caps_
Definition: legdata.hpp:260
QuantLib::Period lookback_
Definition: legdata.hpp:252
bool telescopicValueDates() const
Definition: legdata.hpp:227
vector< string > spreadDates_
Definition: legdata.hpp:259
std::set< std::string > indices_
Definition: legdata.hpp:77
string internalIndexName(const string &indexName)

Member Function Documentation

◆ index()

const string & index ( ) const

Definition at line 207 of file legdata.hpp.

207{ return index_; }

◆ fixingDays()

QuantLib::Size fixingDays ( ) const

Definition at line 208 of file legdata.hpp.

208{ return fixingDays_; }

◆ lookback()

QuantLib::Period lookback ( ) const

Definition at line 209 of file legdata.hpp.

209{ return lookback_; }

◆ rateCutoff()

QuantLib::Size rateCutoff ( ) const

Definition at line 210 of file legdata.hpp.

210{ return rateCutoff_; }

◆ isInArrears()

boost::optional< bool > isInArrears ( ) const

Definition at line 211 of file legdata.hpp.

211{ return isInArrears_; }

◆ isAveraged()

bool isAveraged ( ) const

Definition at line 212 of file legdata.hpp.

212{ return isAveraged_; }

◆ hasSubPeriods()

bool hasSubPeriods ( ) const

Definition at line 213 of file legdata.hpp.

213{ return hasSubPeriods_; }

◆ includeSpread()

bool includeSpread ( ) const

Definition at line 214 of file legdata.hpp.

214{ return includeSpread_; }

◆ spreads()

const vector< double > & spreads ( ) const

Definition at line 215 of file legdata.hpp.

215{ return spreads_; }

◆ spreadDates()

const vector< string > & spreadDates ( ) const

Definition at line 216 of file legdata.hpp.

216{ return spreadDates_; }

◆ caps() [1/2]

const vector< double > & caps ( ) const

Definition at line 217 of file legdata.hpp.

217{ return caps_; }

◆ capDates() [1/2]

const vector< string > & capDates ( ) const

Definition at line 218 of file legdata.hpp.

218{ return capDates_; }

◆ floors() [1/2]

const vector< double > & floors ( ) const

Definition at line 219 of file legdata.hpp.

219{ return floors_; }

◆ floorDates() [1/2]

const vector< string > & floorDates ( ) const

Definition at line 220 of file legdata.hpp.

220{ return floorDates_; }

◆ gearings()

const vector< double > & gearings ( ) const

Definition at line 221 of file legdata.hpp.

221{ return gearings_; }

◆ gearingDates()

const vector< string > & gearingDates ( ) const

Definition at line 222 of file legdata.hpp.

222{ return gearingDates_; }

◆ nakedOption() [1/2]

bool nakedOption ( ) const

Definition at line 223 of file legdata.hpp.

223{ return nakedOption_; }

◆ localCapFloor() [1/2]

bool localCapFloor ( ) const

Definition at line 224 of file legdata.hpp.

224{ return localCapFloor_; }

◆ lastRecentPeriod()

const boost::optional< Period > & lastRecentPeriod ( ) const

Definition at line 225 of file legdata.hpp.

225{ return lastRecentPeriod_; }

◆ lastRecentPeriodCalendar()

const std::string & lastRecentPeriodCalendar ( ) const

Definition at line 226 of file legdata.hpp.

◆ telescopicValueDates() [1/2]

bool telescopicValueDates ( ) const

Definition at line 227 of file legdata.hpp.

227{ return telescopicValueDates_; }

◆ fixingSchedule()

ScheduleData fixingSchedule ( ) const

Definition at line 228 of file legdata.hpp.

228{ return fixingSchedule_; }
ScheduleData fixingSchedule_
Definition: legdata.hpp:271

◆ resetSchedule()

ScheduleData resetSchedule ( ) const

Definition at line 229 of file legdata.hpp.

229{ return resetSchedule_; }
ScheduleData resetSchedule_
Definition: legdata.hpp:272

◆ historicalFixings()

const std::map< QuantLib::Date, double > & historicalFixings ( ) const

Definition at line 230 of file legdata.hpp.

230{ return historicalFixings_; }

◆ caps() [2/2]

vector< double > & caps ( )

Definition at line 235 of file legdata.hpp.

235{ return caps_; }

◆ capDates() [2/2]

vector< string > & capDates ( )

Definition at line 236 of file legdata.hpp.

236{ return capDates_; }

◆ floors() [2/2]

vector< double > & floors ( )

Definition at line 237 of file legdata.hpp.

237{ return floors_; }

◆ floorDates() [2/2]

vector< string > & floorDates ( )

Definition at line 238 of file legdata.hpp.

238{ return floorDates_; }

◆ nakedOption() [2/2]

bool & nakedOption ( )

Definition at line 239 of file legdata.hpp.

239{ return nakedOption_; }

◆ localCapFloor() [2/2]

bool & localCapFloor ( )

Definition at line 240 of file legdata.hpp.

240{ return localCapFloor_; }

◆ telescopicValueDates() [2/2]

bool & telescopicValueDates ( )

Definition at line 241 of file legdata.hpp.

241{ return telescopicValueDates_; }

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 151 of file legdata.cpp.

151 {
153 index_ = internalIndexName(XMLUtils::getChildValue(node, "Index", true));
154 indices_.insert(index_);
155 // These are all optional
156 spreads_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Spreads", "Spread", "startDate", spreadDates_,
157 &parseReal);
158 isInArrears_ = boost::none;
159 lastRecentPeriod_ = boost::none;
161 if (XMLNode* arrNode = XMLUtils::getChildNode(node, "IsInArrears"))
163 if (XMLNode* lrNode = XMLUtils::getChildNode(node, "LastRecentPeriod"))
165 lastRecentPeriodCalendar_ = XMLUtils::getChildValue(node, "LastRecentPeriodCalendar", false);
166 if (XMLNode* avgNode = XMLUtils::getChildNode(node, "IsAveraged"))
168 if (XMLNode* spNode = XMLUtils::getChildNode(node, "HasSubPeriods"))
170 if (XMLNode* incSpNode = XMLUtils::getChildNode(node, "IncludeSpread"))
172 if (auto n = XMLUtils::getChildNode(node, "FixingDays"))
174 else
175 fixingDays_ = Null<Size>();
176 if (auto n = XMLUtils::getChildNode(node, "Lookback"))
178 else
179 lookback_ = 0 * Days;
180 if (auto n = XMLUtils::getChildNode(node, "RateCutoff"))
182 else
183 rateCutoff_ = Null<Size>();
184 caps_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Caps", "Cap", "startDate", capDates_, &parseReal);
185 floors_ =
186 XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Floors", "Floor", "startDate", floorDates_, &parseReal);
187 gearings_ = XMLUtils::getChildrenValuesWithAttributes<Real>(node, "Gearings", "Gearing", "startDate", gearingDates_,
188 &parseReal, false);
189 if (XMLUtils::getChildNode(node, "NakedOption"))
190 nakedOption_ = XMLUtils::getChildValueAsBool(node, "NakedOption", false);
191 else
192 nakedOption_ = false;
193
194 if (XMLUtils::getChildNode(node, "LocalCapFloor"))
195 localCapFloor_ = XMLUtils::getChildValueAsBool(node, "LocalCapFloor", false);
196 else
197 localCapFloor_ = false;
198
199 if (auto tmp = XMLUtils::getChildNode(node, "FixingSchedule")) {
201 }
202 if (auto tmp = XMLUtils::getChildNode(node, "ResetSchedule")) {
204 }
205 vector<std::string> histFixingDates;
206 vector<QuantLib::Real> histFixingValues = XMLUtils::getChildrenValuesWithAttributes<Real>(
207 node, "HistoricalFixings", "Fixing", "fixingDate", histFixingDates,
208 &parseReal);
209
210 QL_REQUIRE(histFixingDates.size() == histFixingValues.size(), "Mismatch Fixing values and dates");
211 for (size_t i = 0; i < histFixingDates.size(); ++i) {
212 auto dt = parseDate(histFixingDates[i]);
213 historicalFixings_[dt] = histFixingValues[i];
214 }
215}
const string & legNodeName() const
Definition: legdata.hpp:70
virtual void fromXML(XMLNode *node) override
Definition: schedule.cpp:179
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 bool getChildValueAsBool(XMLNode *node, const string &name, bool mandatory=false, bool defaultValue=true)
Definition: xmlutils.cpp:296
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Definition: parsers.cpp:171
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Implements XMLSerializable.

Definition at line 217 of file legdata.cpp.

217 {
218 XMLNode* node = doc.allocNode(legNodeName());
219 XMLUtils::addChild(doc, node, "Index", index_);
220 if (isInArrears_)
221 XMLUtils::addChild(doc, node, "IsInArrears", *isInArrears_);
223 XMLUtils::addChild(doc, node, "LastRecentPeriod", *lastRecentPeriod_);
224 if (!lastRecentPeriodCalendar_.empty())
225 XMLUtils::addChild(doc, node, "LastRecentPeriodCalendar", lastRecentPeriodCalendar_);
226 XMLUtils::addChild(doc, node, "IsAveraged", isAveraged_);
227 XMLUtils::addChild(doc, node, "HasSubPeriods", hasSubPeriods_);
228 XMLUtils::addChild(doc, node, "IncludeSpread", includeSpread_);
229 if (fixingDays_ != Null<Size>())
230 XMLUtils::addChild(doc, node, "FixingDays", static_cast<int>(fixingDays_));
231 if (lookback_ != 0 * Days)
232 XMLUtils::addChild(doc, node, "Lookback", ore::data::to_string(lookback_));
233 if (rateCutoff_ != Null<Size>())
234 XMLUtils::addChild(doc, node, "RateCutoff", static_cast<int>(rateCutoff_));
235 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Caps", "Cap", caps_, "startDate", capDates_);
236 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Floors", "Floor", floors_, "startDate", floorDates_);
237 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Gearings", "Gearing", gearings_, "startDate",
239 XMLUtils::addChildrenWithOptionalAttributes(doc, node, "Spreads", "Spread", spreads_, "startDate", spreadDates_);
240 XMLUtils::addChild(doc, node, "NakedOption", nakedOption_);
241 if (localCapFloor_)
242 XMLUtils::addChild(doc, node, "LocalCapFloor", localCapFloor_);
243 if (fixingSchedule_.hasData()) {
244 auto tmp = fixingSchedule_.toXML(doc);
245 XMLUtils::setNodeName(doc, tmp, "FixingSchedule");
246 XMLUtils::appendNode(node, tmp);
247 }
248 if (resetSchedule_.hasData()) {
249 auto tmp = resetSchedule_.toXML(doc);
250 XMLUtils::setNodeName(doc, tmp, "ResetSchedule");
251 XMLUtils::appendNode(node, tmp);
252 }
253 if (!historicalFixings_.empty()) {
254 auto histFixings = XMLUtils::addChild(doc, node, "HistoricalFixings");
255 for (const auto& [fixingDate, fixingValue] : historicalFixings_) {
256 XMLUtils::addChild(doc, histFixings, "Fixing", to_string(fixingValue), "fixingDate", to_string(fixingDate));
257 }
258 }
259 return node;
260}
bool hasData() const
Check if has any dates/rules/derived schedules.
Definition: schedule.hpp:223
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: schedule.cpp:198
static void addChildrenWithOptionalAttributes(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values, const string &attrName, const vector< string > &attrs)
Definition: xmlutils.cpp:542
static void setNodeName(XMLDocument &doc, XMLNode *node, const string &name)
Definition: xmlutils.cpp:478
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
Definition: xmlutils.cpp:181
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
+ Here is the call graph for this function:

Member Data Documentation

◆ index_

string index_
private

Definition at line 250 of file legdata.hpp.

◆ fixingDays_

QuantLib::Size fixingDays_ = Null<Size>()
private

Definition at line 251 of file legdata.hpp.

◆ lookback_

QuantLib::Period lookback_ = 0 * Days
private

Definition at line 252 of file legdata.hpp.

◆ rateCutoff_

QuantLib::Size rateCutoff_ = Null<Size>()
private

Definition at line 253 of file legdata.hpp.

◆ isInArrears_

boost::optional<bool> isInArrears_
private

Definition at line 254 of file legdata.hpp.

◆ isAveraged_

bool isAveraged_ = false
private

Definition at line 255 of file legdata.hpp.

◆ hasSubPeriods_

bool hasSubPeriods_ = false
private

Definition at line 256 of file legdata.hpp.

◆ includeSpread_

bool includeSpread_ = false
private

Definition at line 257 of file legdata.hpp.

◆ spreads_

vector<double> spreads_
private

Definition at line 258 of file legdata.hpp.

◆ spreadDates_

vector<string> spreadDates_
private

Definition at line 259 of file legdata.hpp.

◆ caps_

vector<double> caps_
private

Definition at line 260 of file legdata.hpp.

◆ capDates_

vector<string> capDates_
private

Definition at line 261 of file legdata.hpp.

◆ floors_

vector<double> floors_
private

Definition at line 262 of file legdata.hpp.

◆ floorDates_

vector<string> floorDates_
private

Definition at line 263 of file legdata.hpp.

◆ gearings_

vector<double> gearings_
private

Definition at line 264 of file legdata.hpp.

◆ gearingDates_

vector<string> gearingDates_
private

Definition at line 265 of file legdata.hpp.

◆ nakedOption_

bool nakedOption_ = false
private

Definition at line 266 of file legdata.hpp.

◆ localCapFloor_

bool localCapFloor_ = false
private

Definition at line 267 of file legdata.hpp.

◆ lastRecentPeriod_

boost::optional<Period> lastRecentPeriod_
private

Definition at line 268 of file legdata.hpp.

◆ lastRecentPeriodCalendar_

std::string lastRecentPeriodCalendar_
private

Definition at line 269 of file legdata.hpp.

◆ telescopicValueDates_

bool telescopicValueDates_ = false
private

Definition at line 270 of file legdata.hpp.

◆ fixingSchedule_

ScheduleData fixingSchedule_
private

Definition at line 271 of file legdata.hpp.

◆ resetSchedule_

ScheduleData resetSchedule_
private

Definition at line 272 of file legdata.hpp.

◆ historicalFixings_

std::map<QuantLib::Date, double> historicalFixings_
private

Definition at line 273 of file legdata.hpp.