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

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testConstructionQuotes)
 
 BOOST_AUTO_TEST_CASE (testParseFromXml)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/2]

BOOST_AUTO_TEST_CASE ( testConstructionQuotes  )

Definition at line 33 of file commoditycurveconfig.cpp.

33 {
34
35 BOOST_TEST_MESSAGE("Testing commodity curve configuration quote vector construction");
36
37 // Main thing to check here is that the spot quote gets
38 // inserted at the beginning of the vector of quotes
39 string curveId = "GOLD_USD";
40 string curveDescription = "Value of troy ounce of gold in USD";
41 string currency = "USD";
42 string commoditySpotQuote = "COMMODITY/PRICE/GOLD/USD";
43 vector<string> quotes = {"COMMODITY_FWD/PRICE/GOLD/USD/2016-02-29", "COMMODITY_FWD/PRICE/GOLD/USD/2017-02-28"};
44
45 // Create configuration
46 CommodityCurveConfig config(curveId, curveDescription, currency, quotes, commoditySpotQuote);
47
48 // Check quotes vector from config (none of the other members have logic)
49 quotes.insert(quotes.begin(), commoditySpotQuote);
50 BOOST_CHECK_EQUAL_COLLECTIONS(quotes.begin(), quotes.end(), config.quotes().begin(), config.quotes().end());
51}
Commodity curve configuration.
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/2]

BOOST_AUTO_TEST_CASE ( testParseFromXml  )

Definition at line 53 of file commoditycurveconfig.cpp.

53 {
54
55 BOOST_TEST_MESSAGE("Testing parsing of commodity curve configuration from XML");
56
57 // Create an XML string representation of the commodity curve configuration
58 string configXml;
59 configXml.append("<CommodityCurve>");
60 configXml.append(" <CurveId>GOLD_USD</CurveId>");
61 configXml.append(" <CurveDescription>Gold USD price curve</CurveDescription>");
62 configXml.append(" <Currency>USD</Currency>");
63 configXml.append(" <SpotQuote>COMMODITY/PRICE/GOLD/USD</SpotQuote>");
64 configXml.append(" <Quotes>");
65 configXml.append(" <Quote>COMMODITY_FWD/PRICE/GOLD/USD/2016-02-29</Quote>");
66 configXml.append(" <Quote>COMMODITY_FWD/PRICE/GOLD/USD/2017-02-28</Quote>");
67 configXml.append(" </Quotes>");
68 configXml.append(" <DayCounter>A365</DayCounter>");
69 configXml.append(" <InterpolationMethod>Linear</InterpolationMethod>");
70 configXml.append(" <Extrapolation>true</Extrapolation>");
71 configXml.append("</CommodityCurve>");
72
73 // Create the XMLNode
74 XMLDocument doc;
75 doc.fromXMLString(configXml);
76 XMLNode* configNode = doc.getFirstNode("CommodityCurve");
77
78 // Parse commodity curve configuration from XML
80 config.fromXML(configNode);
81
82 // Expected vector of quotes
83 vector<string> quotes = {"COMMODITY/PRICE/GOLD/USD", "COMMODITY_FWD/PRICE/GOLD/USD/2016-02-29",
84 "COMMODITY_FWD/PRICE/GOLD/USD/2017-02-28"};
85
86 // Check fields
87 BOOST_CHECK_EQUAL(config.curveID(), "GOLD_USD");
88 BOOST_CHECK_EQUAL(config.curveDescription(), "Gold USD price curve");
89 BOOST_CHECK_EQUAL(config.currency(), "USD");
90 BOOST_CHECK_EQUAL(config.commoditySpotQuoteId(), "COMMODITY/PRICE/GOLD/USD");
91 BOOST_CHECK_EQUAL_COLLECTIONS(quotes.begin(), quotes.end(), config.quotes().begin(), config.quotes().end());
92 BOOST_CHECK_EQUAL(config.dayCountId(), "A365");
93 BOOST_CHECK_EQUAL(config.interpolationMethod(), "Linear");
94 BOOST_CHECK_EQUAL(config.extrapolation(), true);
95}
const std::string & currency() const
void fromXML(XMLNode *node) override
const std::string & interpolationMethod() const
const std::string & dayCountId() const
const std::string & commoditySpotQuoteId() const
const string & curveDescription() const
Definition: curveconfig.hpp:55
const string & curveID() const
Definition: curveconfig.hpp:54
virtual const vector< string > & quotes()
Return all the market quotes required for this config.
Definition: curveconfig.hpp:69
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: