19#include <boost/test/unit_test.hpp>
20#include <oret/toplevelfixture.hpp>
25using namespace boost::unit_test_framework;
29BOOST_FIXTURE_TEST_SUITE(OREDataTestSuite, ore::test::TopLevelFixture)
31BOOST_AUTO_TEST_SUITE(CommodityCurveConfigTests)
35 BOOST_TEST_MESSAGE(
"Testing commodity curve configuration quote vector construction");
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"};
49 quotes.insert(quotes.begin(), commoditySpotQuote);
50 BOOST_CHECK_EQUAL_COLLECTIONS(quotes.begin(), quotes.end(), config.
quotes().begin(), config.
quotes().end());
55 BOOST_TEST_MESSAGE(
"Testing parsing of commodity curve configuration from XML");
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>");
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"};
87 BOOST_CHECK_EQUAL(config.
curveID(),
"GOLD_USD");
89 BOOST_CHECK_EQUAL(config.
currency(),
"USD");
91 BOOST_CHECK_EQUAL_COLLECTIONS(quotes.begin(), quotes.end(), config.
quotes().begin(), config.
quotes().end());
92 BOOST_CHECK_EQUAL(config.
dayCountId(),
"A365");
97BOOST_AUTO_TEST_SUITE_END()
99BOOST_AUTO_TEST_SUITE_END()
Commodity curve configuration.
const std::string & currency() const
void fromXML(XMLNode *node) override
bool extrapolation() const
const std::string & interpolationMethod() const
const std::string & dayCountId() const
const std::string & commoditySpotQuoteId() const
const string & curveDescription() const
const string & curveID() const
virtual const vector< string > & quotes()
Return all the market quotes required for this config.
Small XML Document wrapper class.
void fromXMLString(const string &xmlString)
load a document from a hard-coded string
XMLNode * getFirstNode(const string &name) const
Commodity curve configuration class.
BOOST_AUTO_TEST_CASE(testConstructionQuotes)