Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
adjustmentfactors.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <ored/marketdata/adjustmentfactors.hpp>
#include <oret/toplevelfixture.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testAdjustmentFactors)
 
 BOOST_AUTO_TEST_CASE (testAdjustmentFactorsFromXml)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( testAdjustmentFactors  )

Definition at line 31 of file adjustmentfactors.cpp.

31 {
32 BOOST_TEST_MESSAGE("Testing AdjustmentFactors...");
33
34 Date asof(28, September, 2018);
35
36 AdjustmentFactors adjFactors(asof);
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);
40
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);
45}
Class to hold market data adjustment factors - for example equity stock splits.
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( testAdjustmentFactorsFromXml  )

Definition at line 47 of file adjustmentfactors.cpp.

47 {
48 BOOST_TEST_MESSAGE("Testing parsing of Adjustment Factors from XML");
49
50 // Create an XML string representation of the Adjustment Factors curve configuration
51 string factorsXml;
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>");
61
62 // Create the XMLNode
63 XMLDocument doc;
64 doc.fromXMLString(factorsXml);
65 XMLNode* factorsNode = doc.getFirstNode("AdditionalData");
66
67 Date asof(30, September, 2018);
68
69 // Parse Adjustment Factors curve configuration from XML
70 AdjustmentFactors adjFactors(asof);
71 adjFactors.fromXML(factorsNode);
72
73 // Check fields
74 BOOST_CHECK_EQUAL(adjFactors.getFactor("Equity1", Date(27, September, 2018)), 0.5);
75}
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
void fromXMLString(const string &xmlString)
load a document from a hard-coded string
Definition: xmlutils.cpp:103
XMLNode * getFirstNode(const string &name) const
Definition: xmlutils.cpp:116
+ Here is the call graph for this function: