Skip to content

Commit 2a9e211

Browse files
committed
QPR-13744 fix unit test failures
1 parent cafb4a0 commit 2a9e211

4 files changed

Lines changed: 15 additions & 5 deletions

File tree

OREData/ored/portfolio/referencedata.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,11 @@ void PortfolioBasketReferenceDatum::fromXML(XMLNode* node) {
517517
QL_REQUIRE(componentsNode, "No Components node");
518518

519519
auto portfolio = QuantLib::ext::make_shared<Portfolio>();
520-
auto c = XMLUtils::getChildrenNodes(componentsNode, "Trade");
520+
auto c = XMLUtils::getAnyChildrenNodes(componentsNode, {"Trade", "SubTrade"});
521521
int k = 0;
522522
for (auto const n : c) {
523523

524-
string tradeType = XMLUtils::getChildValue(n, "TradeType", true);
524+
string tradeType = XMLUtils::getAnyChildValue(n, {"TradeType", "SubTradeType"}, true);
525525
string id = XMLUtils::getAttribute(n, "id");
526526
if (id == "") {
527527
id = std::to_string(k);

OREData/ored/utilities/xmlutils.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,15 @@ vector<XMLNode*> XMLUtils::getChildrenNodes(XMLNode* node, const string& name) {
472472
return res;
473473
}
474474

475+
vector<XMLNode*> XMLUtils::getAnyChildrenNodes(XMLNode* node, const std::vector<string>& names) {
476+
vector<XMLNode*> res;
477+
for (auto const& n : names) {
478+
auto tmp = getChildrenNodes(node, n);
479+
res.insert(res.end(), tmp.begin(), tmp.end());
480+
}
481+
return res;
482+
}
483+
475484
vector<XMLNode*> XMLUtils::getChildrenNodesWithAttributes(XMLNode* parent, const string& names, const string& name,
476485
const string& attrName, vector<string>& attrs,
477486
bool mandatory) {

OREData/ored/utilities/xmlutils.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ class XMLUtils {
254254
//! Returns all the children with a given name
255255
// To get all children, set name equal to ""
256256
static vector<XMLNode*> getChildrenNodes(XMLNode* node, const string& name);
257+
static vector<XMLNode*> getAnyChildrenNodes(XMLNode* node, const std::vector<string>& names);
257258

258259
static vector<XMLNode*> getChildrenNodesWithAttributes(XMLNode* node, const string& names, const string& name,
259260
const string& attrName, vector<string>& attrs,

OREData/test/localvol.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void testCalibrationInstrumentRepricing(const Model::Type type, const std::vecto
7575
params.regressionOrder = 1;
7676
auto localVol = QuantLib::ext::make_shared<BlackScholes>(
7777
type, size, "EUR", process->riskFreeRate(), "EQ-DUMMY", "EUR", builder.model(), simDates,
78-
QuantLib::ext::make_shared<IborFallbackConfig>(IborFallbackConfig::defaultConfig()), "LocalVol",
78+
QuantLib::ext::make_shared<IborFallbackConfig>(IborFallbackConfig::defaultConfig()), "Smile",
7979
std::vector<Real>{}, params);
8080

8181
// loop over the calibration options and price them in the local vol model using MC
@@ -205,8 +205,8 @@ BOOST_AUTO_TEST_CASE(testSabrVols) {
205205

206206
auto process = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(spot, q, r, vol);
207207

208-
testCalibrationInstrumentRepricing(Model::Type::MC, expiries, moneyness, process, 20, 10000, 0.30);
209-
testCalibrationInstrumentRepricing(Model::Type::FD, expiries, moneyness, process, 20, 100, 0.30);
208+
testCalibrationInstrumentRepricing(Model::Type::MC, expiries, moneyness, process, 20, 10000, 0.35);
209+
testCalibrationInstrumentRepricing(Model::Type::FD, expiries, moneyness, process, 20, 100, 0.35);
210210
}
211211

212212
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)