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

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testParseCMSSpreadPriceQuoteCorrelationFromXml)
 
 BOOST_AUTO_TEST_CASE (testParseGenericCorrelationFromXml)
 
 BOOST_AUTO_TEST_CASE (testParseGenericCorrelationNullQuoteFromXml)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( testParseCMSSpreadPriceQuoteCorrelationFromXml  )

Definition at line 33 of file correlationcurveconfig.cpp.

33 {
34
35 BOOST_TEST_MESSAGE("Testing parsing of correlation curve configuration from XML");
36
37 // Create an XML string representation of the correlation curve configuration
38 string configXml;
39 configXml.append("<Correlation>");
40 configXml.append(" <CurveId>EUR-CMS-10Y/EUR-CMS-1Y</CurveId>");
41 configXml.append(" <CurveDescription>EUR CMS correlations</CurveDescription>");
42 configXml.append(" <CorrelationType>CMSSpread</CorrelationType>");
43 configXml.append(" <Currency>EUR</Currency>");
44 configXml.append(" <Dimension>ATM</Dimension>");
45 configXml.append(" <QuoteType>PRICE</QuoteType>");
46 configXml.append(" <Extrapolation>true</Extrapolation>");
47 configXml.append(" <Conventions>EUR-CMS-10Y-1Y-CONVENTION</Conventions>");
48 configXml.append(" <SwaptionVolatility>EUR</SwaptionVolatility>");
49 configXml.append(" <DiscountCurve>EUR-EONIA</DiscountCurve>");
50 configXml.append(" <Calendar>TARGET</Calendar>");
51 configXml.append(" <DayCounter>A365</DayCounter>");
52 configXml.append(" <BusinessDayConvention>Following</BusinessDayConvention>");
53 configXml.append(" <OptionTenors>1Y,2Y</OptionTenors>");
54 configXml.append(" <Index1>EUR-CMS-10Y</Index1>");
55 configXml.append(" <Index2>EUR-CMS-1Y</Index2>");
56 configXml.append("</CorrelationCurve>");
57
58 // Create the XMLNode
59 XMLDocument doc;
60 doc.fromXMLString(configXml);
61 XMLNode* configNode = doc.getFirstNode("Correlation");
62
63 // Parse correlation curve configuration from XML
65 config.fromXML(configNode);
66
67 // Expected vector of quotes
68 vector<string> quotes = {"CORRELATION/PRICE/EUR-CMS-10Y/EUR-CMS-1Y/1Y/ATM",
69 "CORRELATION/PRICE/EUR-CMS-10Y/EUR-CMS-1Y/2Y/ATM"};
70
71 // Check fields
72 BOOST_CHECK_EQUAL(config.curveID(), "EUR-CMS-10Y/EUR-CMS-1Y");
73 BOOST_CHECK_EQUAL(config.curveDescription(), "EUR CMS correlations");
74 BOOST_CHECK_EQUAL(config.index1(), "EUR-CMS-10Y");
75 BOOST_CHECK_EQUAL(config.index2(), "EUR-CMS-1Y");
76 BOOST_CHECK_EQUAL_COLLECTIONS(quotes.begin(), quotes.end(), config.quotes().begin(), config.quotes().end());
77 BOOST_CHECK_EQUAL(config.extrapolate(), true);
78 BOOST_CHECK_EQUAL(config.conventions(), "EUR-CMS-10Y-1Y-CONVENTION");
79 BOOST_CHECK_EQUAL(config.swaptionVolatility(), "EUR");
80 BOOST_CHECK_EQUAL(config.discountCurve(), "EUR-EONIA");
81 BOOST_CHECK_EQUAL(config.dayCounter().name(), "Actual/365 (Fixed)");
82 BOOST_CHECK_EQUAL(config.calendar().name(), "TARGET");
83 BOOST_CHECK_EQUAL(config.businessDayConvention(), BusinessDayConvention::Following);
84
85 vector<string> p;
86 p.push_back("1Y");
87 p.push_back("2Y");
88
89 BOOST_CHECK_EQUAL_COLLECTIONS(p.begin(), p.end(), config.optionTenors().begin(), config.optionTenors().end());
90}
Correlation curve configuration.
const vector< string > & optionTenors() const
void fromXML(XMLNode *node) override
const vector< string > & quotes() override
Return all the market quotes required for this config.
const BusinessDayConvention & businessDayConvention() const
const string & curveDescription() const
Definition: curveconfig.hpp:55
const string & curveID() const
Definition: curveconfig.hpp:54
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:

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( testParseGenericCorrelationFromXml  )

Definition at line 92 of file correlationcurveconfig.cpp.

92 {
93
94 BOOST_TEST_MESSAGE("Testing parsing of correlation curve configuration from XML");
95
96 // Create an XML string representation of the correlation curve configuration
97 string configXml;
98 configXml.append("<Correlation>");
99 configXml.append(" <CurveId>EUR-CMS-10Y/EUR-CMS-1Y</CurveId>");
100 configXml.append(" <CurveDescription>EUR CMS correlations</CurveDescription>");
101 configXml.append(" <CorrelationType>Generic</CorrelationType>");
102 configXml.append(" <Dimension>ATM</Dimension>");
103 configXml.append(" <QuoteType>RATE</QuoteType>");
104 configXml.append(" <Extrapolation>true</Extrapolation>");
105 configXml.append(" <Calendar>TARGET</Calendar>");
106 configXml.append(" <DayCounter>A365</DayCounter>");
107 configXml.append(" <BusinessDayConvention>Following</BusinessDayConvention>");
108 configXml.append(" <OptionTenors>1Y,2Y</OptionTenors>");
109 configXml.append(" <Index1/>");
110 configXml.append(" <Index2/>");
111 configXml.append(" <Currency/>");
112 configXml.append("</CorrelationCurve>");
113
114 // Create the XMLNode
115 XMLDocument doc;
116 doc.fromXMLString(configXml);
117 XMLNode* configNode = doc.getFirstNode("Correlation");
118
119 // Parse correlation curve configuration from XML
121 config.fromXML(configNode);
122
123 // Check fields
124 BOOST_CHECK_EQUAL(config.curveID(), "EUR-CMS-10Y/EUR-CMS-1Y");
125 BOOST_CHECK_EQUAL(config.curveDescription(), "EUR CMS correlations");
126 BOOST_CHECK_EQUAL(config.extrapolate(), true);
127
128 BOOST_CHECK_EQUAL(config.dayCounter().name(), "Actual/365 (Fixed)");
129 BOOST_CHECK_EQUAL(config.calendar().name(), "TARGET");
130 BOOST_CHECK_EQUAL(config.businessDayConvention(), BusinessDayConvention::Following);
131
132 vector<string> p;
133 p.push_back("1Y");
134 p.push_back("2Y");
135
136 BOOST_CHECK_EQUAL_COLLECTIONS(p.begin(), p.end(), config.optionTenors().begin(), config.optionTenors().end());
137}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( testParseGenericCorrelationNullQuoteFromXml  )

Definition at line 139 of file correlationcurveconfig.cpp.

139 {
140
141 BOOST_TEST_MESSAGE("Testing parsing of correlation curve configuration from XML");
142
143 // Create an XML string representation of the correlation curve configuration
144 string configXml;
145 configXml.append("<Correlation>");
146 configXml.append(" <CurveId>EUR-CMS-10Y/EUR-CMS-1Y</CurveId>");
147 configXml.append(" <CurveDescription>EUR CMS correlations</CurveDescription>");
148 configXml.append(" <CorrelationType>Generic</CorrelationType>");
149 configXml.append(" <QuoteType>NULL</QuoteType>");
150 configXml.append(" <Dimension/>");
151 configXml.append(" <Extrapolation/>");
152 configXml.append(" <Calendar>TARGET</Calendar>");
153 configXml.append(" <DayCounter>A365</DayCounter>");
154 configXml.append(" <BusinessDayConvention/>");
155 configXml.append(" <OptionTenors/>");
156 configXml.append(" <Index1/>");
157 configXml.append(" <Index2/>");
158 configXml.append(" <Currency/>");
159 configXml.append("</CorrelationCurve>");
160
161 // Create the XMLNode
162 XMLDocument doc;
163 doc.fromXMLString(configXml);
164 XMLNode* configNode = doc.getFirstNode("Correlation");
165
166 // Parse correlation curve configuration from XML
168 config.fromXML(configNode);
169
170 // Check fields
171 BOOST_CHECK_EQUAL(config.curveID(), "EUR-CMS-10Y/EUR-CMS-1Y");
172 BOOST_CHECK_EQUAL(config.curveDescription(), "EUR CMS correlations");
173
174 BOOST_CHECK_EQUAL(config.dayCounter().name(), "Actual/365 (Fixed)");
175 BOOST_CHECK_EQUAL(config.calendar().name(), "TARGET");
176}
+ Here is the call graph for this function: