19#include <boost/test/unit_test.hpp>
20#include <oret/datapaths.hpp>
21#include <oret/toplevelfixture.hpp>
24#include <ql/time/calendars/unitedstates.hpp>
27using namespace boost::unit_test_framework;
31BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
33BOOST_AUTO_TEST_SUITE(OptionPaymentDataTests)
37 BOOST_TEST_MESSAGE(
"Testing default construction...");
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);
51 BOOST_TEST_MESSAGE(
"Testing dates based construction...");
53 vector<string> strDates{
"2020-06-08",
"2020-09-08"};
56 vector<Date> expDates{Date(8, Jun, 2020), Date(8, Sep, 2020)};
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);
67 BOOST_TEST_MESSAGE(
"Testing dates based fromXML...");
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>");
83 vector<Date> expDates{Date(8, Jun, 2020), Date(8, Sep, 2020)};
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);
94 BOOST_TEST_MESSAGE(
"Testing dates based toXML...");
97 vector<string> strDates{
"2020-06-08",
"2020-09-08"};
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);
116 BOOST_TEST_MESSAGE(
"Testing rules based construction...");
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);
130 BOOST_TEST_MESSAGE(
"Testing rules based fromXML...");
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>");
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);
158 BOOST_TEST_MESSAGE(
"Testing rules based toXML...");
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);
176BOOST_AUTO_TEST_SUITE_END()
178BOOST_AUTO_TEST_SUITE_END()
QuantLib::BusinessDayConvention convention() const
QuantLib::Natural lag() const
RelativeTo relativeTo() const
const QuantLib::Calendar & calendar() const
const std::vector< QuantLib::Date > & dates() const
std::string toXMLString() const
Parse from XML string.
void fromXMLString(const std::string &xml)
Parse from XML string.
option payment data model and serialization
BOOST_AUTO_TEST_CASE(testDefaultConstruction)