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

#include <ored/portfolio/optionpaymentdata.hpp>

+ Inheritance diagram for OptionPaymentData:
+ Collaboration diagram for OptionPaymentData:

Public Types

enum class  RelativeTo { Expiry , Exercise }
 When we have payment rules, specifies what date the payment is relative to. More...
 

Public Member Functions

 OptionPaymentData ()
 Default constructor. More...
 
 OptionPaymentData (const std::vector< std::string > &dates)
 Constructor taking an explicit set of payment dates. More...
 
 OptionPaymentData (const std::string &lag, const std::string &calendar, const std::string &convention, const std::string &relativeTo="Expiry")
 Constructor taking a set of payment rules. More...
 
bool rulesBased () const
 
Inspectors
const std::vector< QuantLib::Date > & dates () const
 
QuantLib::Natural lag () const
 
const QuantLib::Calendar & calendar () const
 
QuantLib::BusinessDayConvention convention () const
 
RelativeTo relativeTo () 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

std::vector< std::string > strDates_
 
std::string strLag_
 
std::string strCalendar_
 
std::string strConvention_
 
std::string strRelativeTo_
 
bool rulesBased_
 
std::vector< QuantLib::Date > dates_
 
QuantLib::Natural lag_
 
QuantLib::Calendar calendar_
 
QuantLib::BusinessDayConvention convention_
 
RelativeTo relativeTo_
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 
void init ()
 Initialisation. More...
 
void populateRelativeTo ()
 Populate the value of relativeTo_ member from string. More...
 

Detailed Description

Serializable object holding option payment data for cash settled options.

Definition at line 36 of file optionpaymentdata.hpp.

Member Enumeration Documentation

◆ RelativeTo

enum class RelativeTo
strong

When we have payment rules, specifies what date the payment is relative to.

Enumerator
Expiry 
Exercise 

Definition at line 39 of file optionpaymentdata.hpp.

Constructor & Destructor Documentation

◆ OptionPaymentData() [1/3]

Default constructor.

Definition at line 31 of file optionpaymentdata.cpp.

◆ OptionPaymentData() [2/3]

OptionPaymentData ( const std::vector< std::string > &  dates)

Constructor taking an explicit set of payment dates.

Definition at line 34 of file optionpaymentdata.cpp.

36 init();
37}
const std::vector< QuantLib::Date > & dates() const
std::vector< std::string > strDates_
+ Here is the call graph for this function:

◆ OptionPaymentData() [3/3]

OptionPaymentData ( const std::string &  lag,
const std::string &  calendar,
const std::string &  convention,
const std::string &  relativeTo = "Expiry" 
)

Constructor taking a set of payment rules.

Definition at line 39 of file optionpaymentdata.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ rulesBased()

bool rulesBased ( ) const

Returns true if the OptionPaymentData was constructed using rules and false if it was constructed using explicit payment dates.

Definition at line 54 of file optionpaymentdata.hpp.

54{ return rulesBased_; }
+ Here is the caller graph for this function:

◆ dates()

const std::vector< QuantLib::Date > & dates ( ) const

Definition at line 58 of file optionpaymentdata.hpp.

58{ return dates_; }
std::vector< QuantLib::Date > dates_
+ Here is the caller graph for this function:

◆ lag()

QuantLib::Natural lag ( ) const

Definition at line 59 of file optionpaymentdata.hpp.

59{ return lag_; }
+ Here is the caller graph for this function:

◆ calendar()

const QuantLib::Calendar & calendar ( ) const

Definition at line 60 of file optionpaymentdata.hpp.

60{ return calendar_; }
+ Here is the caller graph for this function:

◆ convention()

QuantLib::BusinessDayConvention convention ( ) const

Definition at line 61 of file optionpaymentdata.hpp.

61{ return convention_; }
+ Here is the caller graph for this function:

◆ relativeTo()

RelativeTo relativeTo ( ) const

Definition at line 62 of file optionpaymentdata.hpp.

62{ return relativeTo_; }
+ Here is the caller graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Implements XMLSerializable.

Definition at line 46 of file optionpaymentdata.cpp.

46 {
47 XMLUtils::checkNode(node, "PaymentData");
48 if (XMLUtils::getChildNode(node, "Dates")) {
49 strDates_ = XMLUtils::getChildrenValues(node, "Dates", "Date", true);
50 rulesBased_ = false;
51 } else if (XMLNode* n = XMLUtils::getChildNode(node, "Rules")) {
52 strLag_ = XMLUtils::getChildValue(n, "Lag", true);
53 strCalendar_ = XMLUtils::getChildValue(n, "Calendar", true);
54 strConvention_ = XMLUtils::getChildValue(n, "Convention", true);
55 strRelativeTo_ = "Expiry";
56 if (XMLNode* rtNode = XMLUtils::getChildNode(n, "RelativeTo"))
58 rulesBased_ = true;
59 } else {
60 QL_FAIL("Expected that PaymentData node has a PaymentDates or PaymentRules child node.");
61 }
62 init();
63}
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 * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static string getNodeValue(XMLNode *node)
Get a node's value.
Definition: xmlutils.cpp:489
static vector< string > getChildrenValues(XMLNode *node, const string &names, const string &name, bool mandatory=false)
Definition: xmlutils.cpp:306
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 65 of file optionpaymentdata.cpp.

65 {
66 XMLNode* node = doc.allocNode("PaymentData");
67
68 if (rulesBased_) {
69 XMLNode* rulesNode = doc.allocNode("Rules");
70 XMLUtils::addChild(doc, rulesNode, "Lag", strLag_);
71 XMLUtils::addChild(doc, rulesNode, "Calendar", strCalendar_);
72 XMLUtils::addChild(doc, rulesNode, "Convention", strConvention_);
73 XMLUtils::addChild(doc, rulesNode, "RelativeTo", strRelativeTo_);
74 XMLUtils::appendNode(node, rulesNode);
75 } else {
76 XMLUtils::addChildren(doc, node, "Dates", "Date", strDates_);
77 }
78
79 return node;
80}
static void addChildren(XMLDocument &doc, XMLNode *n, const string &names, const string &name, const vector< T > &values)
Definition: xmlutils.cpp:502
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
+ Here is the call graph for this function:

◆ init()

void init ( )
private

Initialisation.

Definition at line 82 of file optionpaymentdata.cpp.

82 {
83 if (rulesBased_) {
88 } else {
89 QL_REQUIRE(strDates_.size() > 0, "Expected at least 1 option payment date.");
90 dates_.reserve(strDates_.size());
91 for (const string& d : strDates_) {
92 dates_.push_back(parseDate(d));
93 }
94 }
95}
void populateRelativeTo()
Populate the value of relativeTo_ member from string.
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
Definition: parsers.cpp:157
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
BusinessDayConvention parseBusinessDayConvention(const string &s)
Convert text to QuantLib::BusinessDayConvention.
Definition: parsers.cpp:173
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
Definition: parsers.cpp:136
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateRelativeTo()

void populateRelativeTo ( )
private

Populate the value of relativeTo_ member from string.

Definition at line 97 of file optionpaymentdata.cpp.

97 {
98 if (strRelativeTo_ == "Expiry") {
100 } else if (strRelativeTo_ == "Exercise") {
102 } else {
103 QL_FAIL("Could not convert string " << strRelativeTo_ << " to a valid RelativeTo value.");
104 }
105}
+ Here is the caller graph for this function:

Member Data Documentation

◆ strDates_

std::vector<std::string> strDates_
private

Definition at line 72 of file optionpaymentdata.hpp.

◆ strLag_

std::string strLag_
private

Definition at line 73 of file optionpaymentdata.hpp.

◆ strCalendar_

std::string strCalendar_
private

Definition at line 74 of file optionpaymentdata.hpp.

◆ strConvention_

std::string strConvention_
private

Definition at line 75 of file optionpaymentdata.hpp.

◆ strRelativeTo_

std::string strRelativeTo_
private

Definition at line 76 of file optionpaymentdata.hpp.

◆ rulesBased_

bool rulesBased_
private

Definition at line 78 of file optionpaymentdata.hpp.

◆ dates_

std::vector<QuantLib::Date> dates_
private

Definition at line 79 of file optionpaymentdata.hpp.

◆ lag_

QuantLib::Natural lag_
private

Definition at line 80 of file optionpaymentdata.hpp.

◆ calendar_

QuantLib::Calendar calendar_
private

Definition at line 81 of file optionpaymentdata.hpp.

◆ convention_

QuantLib::BusinessDayConvention convention_
private

Definition at line 82 of file optionpaymentdata.hpp.

◆ relativeTo_

RelativeTo relativeTo_
private

Definition at line 83 of file optionpaymentdata.hpp.