Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
optionpaymentdata.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <oret/datapaths.hpp>
#include <oret/toplevelfixture.hpp>
#include <ored/portfolio/optionpaymentdata.hpp>
#include <ql/time/calendars/unitedstates.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testDefaultConstruction)
 
 BOOST_AUTO_TEST_CASE (testDatesBasedConstruction)
 
 BOOST_AUTO_TEST_CASE (testDatesBasedFromXml)
 
 BOOST_AUTO_TEST_CASE (testDatesBasedToXml)
 
 BOOST_AUTO_TEST_CASE (testRulesBasedConstruction)
 
 BOOST_AUTO_TEST_CASE (testRulesBasedFromXml)
 
 BOOST_AUTO_TEST_CASE (testRulesBasedToXml)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/7]

BOOST_AUTO_TEST_CASE ( testDefaultConstruction  )

Definition at line 35 of file optionpaymentdata.cpp.

35 {
36
37 BOOST_TEST_MESSAGE("Testing default construction...");
38
40
41 BOOST_CHECK(!opd.rulesBased());
42 BOOST_CHECK(opd.dates().empty());
43 BOOST_CHECK_EQUAL(opd.lag(), 0);
44 BOOST_CHECK_EQUAL(opd.calendar(), Calendar());
45 BOOST_CHECK_EQUAL(opd.convention(), Following);
46 BOOST_CHECK_EQUAL(opd.relativeTo(), OptionPaymentData::RelativeTo::Expiry);
47}
QuantLib::BusinessDayConvention convention() const
QuantLib::Natural lag() const
const QuantLib::Calendar & calendar() const
const std::vector< QuantLib::Date > & dates() const
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/7]

BOOST_AUTO_TEST_CASE ( testDatesBasedConstruction  )

Definition at line 49 of file optionpaymentdata.cpp.

49 {
50
51 BOOST_TEST_MESSAGE("Testing dates based construction...");
52
53 vector<string> strDates{"2020-06-08", "2020-09-08"};
54 OptionPaymentData opd(strDates);
55
56 vector<Date> expDates{Date(8, Jun, 2020), Date(8, Sep, 2020)};
57 BOOST_CHECK(!opd.rulesBased());
58 BOOST_CHECK_EQUAL_COLLECTIONS(opd.dates().begin(), opd.dates().end(), expDates.begin(), expDates.end());
59 BOOST_CHECK_EQUAL(opd.lag(), 0);
60 BOOST_CHECK_EQUAL(opd.calendar(), Calendar());
61 BOOST_CHECK_EQUAL(opd.convention(), Following);
62 BOOST_CHECK_EQUAL(opd.relativeTo(), OptionPaymentData::RelativeTo::Expiry);
63}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/7]

BOOST_AUTO_TEST_CASE ( testDatesBasedFromXml  )

Definition at line 65 of file optionpaymentdata.cpp.

65 {
66
67 BOOST_TEST_MESSAGE("Testing dates based fromXML...");
68
69 // XML input
70 string xml;
71 xml.append("<PaymentData>");
72 xml.append(" <Dates>");
73 xml.append(" <Date>2020-06-08</Date>");
74 xml.append(" <Date>2020-09-08</Date>");
75 xml.append(" </Dates>");
76 xml.append("</PaymentData>");
77
78 // Load OptionPaymentData from XML
80 opd.fromXMLString(xml);
81
82 // Check is as expected.
83 vector<Date> expDates{Date(8, Jun, 2020), Date(8, Sep, 2020)};
84 BOOST_CHECK(!opd.rulesBased());
85 BOOST_CHECK_EQUAL_COLLECTIONS(opd.dates().begin(), opd.dates().end(), expDates.begin(), expDates.end());
86 BOOST_CHECK_EQUAL(opd.lag(), 0);
87 BOOST_CHECK_EQUAL(opd.calendar(), Calendar());
88 BOOST_CHECK_EQUAL(opd.convention(), Following);
89 BOOST_CHECK_EQUAL(opd.relativeTo(), OptionPaymentData::RelativeTo::Expiry);
90}
void fromXMLString(const std::string &xml)
Parse from XML string.
Definition: xmlutils.cpp:162
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/7]

BOOST_AUTO_TEST_CASE ( testDatesBasedToXml  )

Definition at line 92 of file optionpaymentdata.cpp.

92 {
93
94 BOOST_TEST_MESSAGE("Testing dates based toXML...");
95
96 // Construct explicitly
97 vector<string> strDates{"2020-06-08", "2020-09-08"};
98 OptionPaymentData inOpd(strDates);
99
100 // Write to XML and read the result from XML to populate new object
101 OptionPaymentData outOpd;
102 outOpd.fromXMLString(inOpd.toXMLString());
103
104 // Check is as expected.
105 BOOST_CHECK(!outOpd.rulesBased());
106 BOOST_CHECK_EQUAL_COLLECTIONS(outOpd.dates().begin(), outOpd.dates().end(), inOpd.dates().begin(),
107 inOpd.dates().end());
108 BOOST_CHECK_EQUAL(outOpd.lag(), 0);
109 BOOST_CHECK_EQUAL(outOpd.calendar(), Calendar());
110 BOOST_CHECK_EQUAL(outOpd.convention(), Following);
111 BOOST_CHECK_EQUAL(outOpd.relativeTo(), OptionPaymentData::RelativeTo::Expiry);
112}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/7]

BOOST_AUTO_TEST_CASE ( testRulesBasedConstruction  )

Definition at line 114 of file optionpaymentdata.cpp.

114 {
115
116 BOOST_TEST_MESSAGE("Testing rules based construction...");
117
118 OptionPaymentData opd("5", "USD", "Following", "Exercise");
119
120 BOOST_CHECK(opd.rulesBased());
121 BOOST_CHECK(opd.dates().empty());
122 BOOST_CHECK_EQUAL(opd.lag(), 5);
123 BOOST_CHECK_EQUAL(opd.calendar(), UnitedStates(UnitedStates::Settlement));
124 BOOST_CHECK_EQUAL(opd.convention(), Following);
125 BOOST_CHECK_EQUAL(opd.relativeTo(), OptionPaymentData::RelativeTo::Exercise);
126}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/7]

BOOST_AUTO_TEST_CASE ( testRulesBasedFromXml  )

Definition at line 128 of file optionpaymentdata.cpp.

128 {
129
130 BOOST_TEST_MESSAGE("Testing rules based fromXML...");
131
132 // XML input
133 string xml;
134 xml.append("<PaymentData>");
135 xml.append(" <Rules>");
136 xml.append(" <Lag>3</Lag>");
137 xml.append(" <Calendar>US</Calendar>");
138 xml.append(" <Convention>ModifiedFollowing</Convention>");
139 xml.append(" <RelativeTo>Expiry</RelativeTo>");
140 xml.append(" </Rules>");
141 xml.append("</PaymentData>");
142
143 // Load OptionPaymentData from XML
145 opd.fromXMLString(xml);
146
147 // Check is as expected.
148 BOOST_CHECK(opd.rulesBased());
149 BOOST_CHECK(opd.dates().empty());
150 BOOST_CHECK_EQUAL(opd.lag(), 3);
151 BOOST_CHECK_EQUAL(opd.calendar(), UnitedStates(UnitedStates::Settlement));
152 BOOST_CHECK_EQUAL(opd.convention(), ModifiedFollowing);
153 BOOST_CHECK_EQUAL(opd.relativeTo(), OptionPaymentData::RelativeTo::Expiry);
154}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/7]

BOOST_AUTO_TEST_CASE ( testRulesBasedToXml  )

Definition at line 156 of file optionpaymentdata.cpp.

156 {
157
158 BOOST_TEST_MESSAGE("Testing rules based toXML...");
159
160 // Construct explicitly
161 OptionPaymentData inOpd("3", "USD", "ModifiedFollowing", "Exercise");
162
163 // Write to XML and read the result from XML to populate new object
164 OptionPaymentData outOpd;
165 outOpd.fromXMLString(inOpd.toXMLString());
166
167 // Check is as expected.
168 BOOST_CHECK(outOpd.rulesBased());
169 BOOST_CHECK(outOpd.dates().empty());
170 BOOST_CHECK_EQUAL(outOpd.lag(), 3);
171 BOOST_CHECK_EQUAL(outOpd.calendar(), UnitedStates(UnitedStates::Settlement));
172 BOOST_CHECK_EQUAL(outOpd.convention(), ModifiedFollowing);
173 BOOST_CHECK_EQUAL(outOpd.relativeTo(), OptionPaymentData::RelativeTo::Exercise);
174}
+ Here is the call graph for this function: