157 {
158
159 BOOST_TEST_MESSAGE("Testing parsing of commodity vol surface configuration from XML");
160
161
162 string configXml;
163 configXml.append("<CommodityVolatility>");
164 configXml.append(" <CurveId>WTI_USD_VOLS</CurveId>");
165 configXml.append(" <CurveDescription/>");
166 configXml.append(" <Currency>USD</Currency>");
167 configXml.append(" <StrikeSurface>");
168 configXml.append(" <Strikes>30.0,40.0,60.0</Strikes>");
169 configXml.append(" <Expiries>1Y,5Y,10Y</Expiries>");
170 configXml.append(" <TimeInterpolation>Linear</TimeInterpolation>");
171 configXml.append(" <StrikeInterpolation>Linear</StrikeInterpolation>");
172 configXml.append(" <Extrapolation>true</Extrapolation>");
173 configXml.append(" <TimeExtrapolation>Flat</TimeExtrapolation>");
174 configXml.append(" <StrikeExtrapolation>Flat</StrikeExtrapolation>");
175 configXml.append(" </StrikeSurface>");
176 configXml.append("</CommodityVolatility>");
177
178
182
183
186
187
188 vector<string> quotes = {"COMMODITY_OPTION/RATE_LNVOL/WTI_USD_VOLS/USD/1Y/30.0",
189 "COMMODITY_OPTION/RATE_LNVOL/WTI_USD_VOLS/USD/1Y/40.0",
190 "COMMODITY_OPTION/RATE_LNVOL/WTI_USD_VOLS/USD/1Y/60.0",
191 "COMMODITY_OPTION/RATE_LNVOL/WTI_USD_VOLS/USD/5Y/30.0",
192 "COMMODITY_OPTION/RATE_LNVOL/WTI_USD_VOLS/USD/5Y/40.0",
193 "COMMODITY_OPTION/RATE_LNVOL/WTI_USD_VOLS/USD/5Y/60.0",
194 "COMMODITY_OPTION/RATE_LNVOL/WTI_USD_VOLS/USD/10Y/30.0",
195 "COMMODITY_OPTION/RATE_LNVOL/WTI_USD_VOLS/USD/10Y/40.0",
196 "COMMODITY_OPTION/RATE_LNVOL/WTI_USD_VOLS/USD/10Y/60.0"};
197
198
199 BOOST_CHECK_EQUAL(config.
curveID(),
"WTI_USD_VOLS");
200 BOOST_CHECK_EQUAL(config.
currency(),
"USD");
201
202 QuantLib::ext::shared_ptr<VolatilityStrikeSurfaceConfig> vc;
204 if ((vc = QuantLib::ext::dynamic_pointer_cast<VolatilityStrikeSurfaceConfig>(v)))
205 break;
206 }
207 BOOST_REQUIRE(vc);
208 BOOST_CHECK_EQUAL(vc->timeInterpolation(), "Linear");
209 BOOST_CHECK_EQUAL(vc->strikeInterpolation(), "Linear");
210 BOOST_CHECK(vc->extrapolation());
211 BOOST_CHECK_EQUAL(vc->timeExtrapolation(), "Flat");
212 BOOST_CHECK_EQUAL(vc->strikeExtrapolation(), "Flat");
213 BOOST_CHECK_EQUAL(config.
quotes().size(), 9);
214 BOOST_CHECK_EQUAL_COLLECTIONS(quotes.begin(), quotes.end(), config.
quotes().begin(), config.
quotes().end());
215
216
217 BOOST_CHECK_EQUAL(config.
dayCounter(),
"A365");
218 BOOST_CHECK_EQUAL(config.
calendar(),
"NullCalendar");
221}