Skip to content

Commit 467b7a3

Browse files
Farah Khashmanjenkins
authored andcommitted
QPR-12055: Fix unit test
1 parent 65e1e0c commit 467b7a3

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

OREData/test/fittedbondcurve.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <ored/marketdata/fittedbondcurvehelpermarket.hpp>
2525
#include <ored/portfolio/enginefactory.hpp>
2626
#include <ored/portfolio/portfolio.hpp>
27+
#include <ored/portfolio/trade.hpp>
2728

2829
#include <ql/pricingengines/bond/discountingbondengine.hpp>
2930
#include <ql/termstructures/yield/bondhelpers.hpp>
@@ -38,37 +39,37 @@ BOOST_AUTO_TEST_SUITE(FittedBondCurveTests)
3839

3940
BOOST_AUTO_TEST_CASE(testCurveFromFixedRateBonds) {
4041

41-
#if QL_HEX_VERSION >= 0x01190000 || defined(QL_ORE_PATCH)
42+
4243
// will work in QL 1.19
4344
Date asof(6, April, 2020);
4445
Settings::instance().evaluationDate() = asof;
4546

4647
BOOST_TEST_MESSAGE("read pricing engine config");
47-
auto engineData = QuantLib::ext::make_shared<EngineData>();
48+
QuantLib::ext::shared_ptr<EngineData> engineData = QuantLib::ext::make_shared<EngineData>();
4849
engineData->fromFile(TEST_INPUT_FILE("pricingengine.xml"));
4950

5051
BOOST_TEST_MESSAGE("read portfolio of bonds");
51-
auto portfolio = QuantLib::ext::make_shared<Portfolio>();
52-
portfolio->load(TEST_INPUT_FILE("portfolio1.xml"));
52+
QuantLib::ext::shared_ptr<Portfolio> portfolio = QuantLib::ext::make_shared<Portfolio>();
53+
portfolio->fromFile(TEST_INPUT_FILE("portfolio1.xml"));
5354

5455
BOOST_TEST_MESSAGE("build portfolio against FittedBondCurveHelperMarket");
55-
auto engineFactory =
56+
QuantLib::ext::shared_ptr < EngineFactory> engineFactory =
5657
QuantLib::ext::make_shared<EngineFactory>(engineData, QuantLib::ext::make_shared<FittedBondCurveHelperMarket>());
5758
portfolio->build(engineFactory);
5859

5960
BOOST_TEST_MESSAGE("set up bond helpers");
6061
std::vector<QuantLib::ext::shared_ptr<Bond>> bonds;
6162
std::vector<QuantLib::ext::shared_ptr<BondHelper>> helpers;
62-
for (auto const& t : portfolio->trades()) {
63-
auto bond = QuantLib::ext::dynamic_pointer_cast<Bond>(t->instrument()->qlInstrument());
63+
for (auto const& [tradeId, trade] : portfolio->trades()) {
64+
QuantLib::ext::shared_ptr<QuantLib::Bond> bond =
65+
QuantLib::ext::dynamic_pointer_cast<Bond>(trade->instrument()->qlInstrument());
6466
BOOST_REQUIRE(bond);
6567
bonds.push_back(bond);
6668
helpers.push_back(QuantLib::ext::make_shared<BondHelper>(Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(100.0)), bond));
6769
}
6870

6971
BOOST_TEST_MESSAGE("build fitted bond curve");
70-
Array guess(4);
71-
guess << 0.03, 0.03, 0.03, 0.5;
72+
Array guess({0.03, 0.03, 0.03, 0.5});
7273
NelsonSiegelFitting method((Array(), QuantLib::ext::shared_ptr<OptimizationMethod>(), Array()));
7374
auto curve =
7475
QuantLib::ext::make_shared<FittedBondDiscountCurve>(asof, helpers, Actual365Fixed(), method, 1E-10, 10000, guess);
@@ -82,7 +83,6 @@ BOOST_AUTO_TEST_CASE(testCurveFromFixedRateBonds) {
8283
<< " discount factor is " << curve->discount(b->maturityDate()));
8384
BOOST_CHECK_CLOSE(b->cleanPrice(), 100.0, 0.01); // 1bp tolerance in absolute price
8485
}
85-
#endif
8686
}
8787

8888
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)