18#include <boost/test/unit_test.hpp>
20#include <oret/toplevelfixture.hpp>
24using namespace boost::unit_test_framework;
27BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
29BOOST_AUTO_TEST_SUITE(AdjustmentFactorsTest)
32 BOOST_TEST_MESSAGE(
"Testing AdjustmentFactors...");
34 Date asof(28, September, 2018);
37 adjFactors.
addFactor(
"Equity1", Date(1, January, 2010), 0.5);
38 adjFactors.
addFactor(
"Equity1", Date(8, November, 2013), 5);
39 adjFactors.
addFactor(
"Equity1", Date(14, October, 2017), 0.1);
41 BOOST_CHECK_EQUAL(adjFactors.
getFactor(
"Equity1", Date(10, December, 2009)), 0.25);
42 BOOST_CHECK_EQUAL(adjFactors.
getFactor(
"Equity1", Date(12, February, 2012)), 0.5);
43 BOOST_CHECK_EQUAL(adjFactors.
getFactor(
"Equity1", Date(6, October, 2015)), 0.10);
44 BOOST_CHECK_EQUAL(adjFactors.
getFactor(
"Equity1", Date(27, September, 2018)), 1.0);
48 BOOST_TEST_MESSAGE(
"Testing parsing of Adjustment Factors from XML");
52 factorsXml.append(
"<AdditionalData>");
53 factorsXml.append(
" <AdjustmentFactors>");
54 factorsXml.append(
" <AdjustmentFactor>");
55 factorsXml.append(
" <Date>2018-09-28</Date>");
56 factorsXml.append(
" <Quote>Equity1</Quote>");
57 factorsXml.append(
" <Factor>0.5</Factor>");
58 factorsXml.append(
" </AdjustmentFactor>");
59 factorsXml.append(
" </AdjustmentFactors>");
60 factorsXml.append(
"</AdditionalData>");
67 Date asof(30, September, 2018);
71 adjFactors.
fromXML(factorsNode);
74 BOOST_CHECK_EQUAL(adjFactors.
getFactor(
"Equity1", Date(27, September, 2018)), 0.5);
77BOOST_AUTO_TEST_SUITE_END()
79BOOST_AUTO_TEST_SUITE_END()
Class to hold market data adjustment factors - for example equity stock splits.
QuantLib::Real getFactor(const std::string &name, const QuantLib::Date &d) const
Returns the adjustment factor for a name on a given date.
virtual void fromXML(ore::data::XMLNode *node) override
void addFactor(std::string name, QuantLib::Date d, QuantLib::Real factor)
Add an adjustment factor.
Small XML Document wrapper class.
void fromXMLString(const string &xmlString)
load a document from a hard-coded string
XMLNode * getFirstNode(const string &name) const
BOOST_AUTO_TEST_CASE(testAdjustmentFactors)