@@ -343,8 +343,7 @@ BOOST_AUTO_TEST_CASE(testZeroTermStructure) {
343343 202.7 , 201.6 , 203.1 , 204.4 , 205.4 , 206.2 ,
344344 207.3 };
345345
346- RelinkableHandle<ZeroInflationTermStructure> hz;
347- auto ii = ext::make_shared<UKRPI >(hz);
346+ auto ii = ext::make_shared<UKRPI >();
348347 for (Size i=0 ; i<std::size (fixData); i++) {
349348 ii->addFixing (rpiSchedule[i], fixData[i]);
350349 }
@@ -390,7 +389,6 @@ BOOST_AUTO_TEST_CASE(testZeroTermStructure) {
390389 ext::shared_ptr<PiecewiseZeroInflationCurve<Linear> > pZITS =
391390 ext::make_shared<PiecewiseZeroInflationCurve<Linear>>(
392391 evaluationDate, baseDate, frequency, dc, helpers);
393- hz.linkTo (pZITS);
394392
395393 // ===========================================================================================
396394 // first check that the quoted swaps are repriced correctly
@@ -399,6 +397,9 @@ BOOST_AUTO_TEST_CASE(testZeroTermStructure) {
399397 const Spread basisPoint = 1.0e-4 ;
400398 auto engine = ext::make_shared<DiscountingSwapEngine>(nominalTS);
401399
400+ Handle<ZeroInflationTermStructure> hz (pZITS);
401+ ii = ext::make_shared<UKRPI >(hz);
402+
402403 for (const auto & datum: zcData) {
403404 ZeroCouponInflationSwap nzcis (Swap::Payer,
404405 1000000.0 ,
@@ -505,9 +506,6 @@ BOOST_AUTO_TEST_CASE(testZeroTermStructure) {
505506 << " \n maturity: " << nzcis.maturityDate ()
506507 << " \n rate: " << datum.rate );
507508 }
508-
509- // remove circular refernce
510- hz.reset ();
511509}
512510
513511BOOST_AUTO_TEST_CASE (testZeroTermStructureLazyBaseDate) {
@@ -618,8 +616,7 @@ BOOST_AUTO_TEST_CASE(testSeasonalityCorrection) {
618616 202.7 , 201.6 , 203.1 , 204.4 , 205.4 , 206.2 ,
619617 207.3 };
620618
621- RelinkableHandle<ZeroInflationTermStructure> hz;
622- auto ii = ext::make_shared<UKRPI >(hz);
619+ auto ii = ext::make_shared<UKRPI >();
623620 for (Size i=0 ; i<std::size (fixData); i++) {
624621 ii->addFixing (rpiSchedule[i], fixData[i]);
625622 }
@@ -667,9 +664,10 @@ BOOST_AUTO_TEST_CASE(testSeasonalityCorrection) {
667664
668665 auto zeroCurve = ext::make_shared<InterpolatedZeroInflationCurve<Linear>>(
669666 evaluationDate, nodes, rates, frequency, dc);
670- hz.linkTo (zeroCurve);
671667
672- // Perform checks on the seasonality for this non-interpolated index
668+ Handle<ZeroInflationTermStructure> hz (zeroCurve);
669+ ii = ext::make_shared<UKRPI >(hz);
670+
673671 checkSeasonality (hz, ii);
674672}
675673
@@ -961,9 +959,8 @@ BOOST_AUTO_TEST_CASE(testYYTermStructure) {
961959 207.3
962960 };
963961
964- RelinkableHandle<YoYInflationTermStructure> hy;
965962 auto rpi = ext::make_shared<UKRPI >();
966- auto iir = ext::make_shared<YoYInflationIndex>(rpi, hy );
963+ auto iir = ext::make_shared<YoYInflationIndex>(rpi);
967964 for (Size i=0 ; i<std::size (fixData); i++) {
968965 rpi->addFixing (rpiSchedule[i], fixData[i]);
969966 }
@@ -1022,7 +1019,8 @@ BOOST_AUTO_TEST_CASE(testYYTermStructure) {
10221019 ext::shared_ptr<PricingEngine> sppe (new DiscountingSwapEngine (hTS));
10231020
10241021 // make sure that the index has the latest yoy term structure
1025- hy.linkTo (pYYTS);
1022+ Handle<YoYInflationTermStructure> hy (pYYTS);
1023+ iir = ext::make_shared<YoYInflationIndex>(rpi, hy);
10261024
10271025 for (Size j = 1 ; j < yyData.size (); j++) {
10281026
@@ -1093,8 +1091,6 @@ BOOST_AUTO_TEST_CASE(testYYTermStructure) {
10931091 <<" , legs " << yyS3.legNPV (0 ) << " and " << yyS3.legNPV (1 )
10941092 );
10951093 }
1096- // remove circular refernce
1097- hy.reset ();
10981094}
10991095
11001096BOOST_AUTO_TEST_CASE (testZeroBpsYoYInflationSwapFairRateAndSpread) {
@@ -1120,9 +1116,8 @@ BOOST_AUTO_TEST_CASE(testZeroBpsYoYInflationSwapFairRateAndSpread) {
11201116 199.2 , 200.1 , 200.4 , 201.1 , 202.7 , 201.6 , 203.1 , 204.4 , 205.4 , 206.2 ,
11211117 207.3 };
11221118
1123- RelinkableHandle<YoYInflationTermStructure> hy;
11241119 auto rpi = ext::make_shared<UKRPI >();
1125- auto iir = ext::make_shared<YoYInflationIndex>(rpi, hy );
1120+ auto iir = ext::make_shared<YoYInflationIndex>(rpi);
11261121 for (Size i = 0 ; i < std::size (fixData); i++) {
11271122 rpi->addFixing (rpiSchedule[i], fixData[i]);
11281123 }
@@ -1140,7 +1135,9 @@ BOOST_AUTO_TEST_CASE(testZeroBpsYoYInflationSwapFairRateAndSpread) {
11401135 auto yoyTs = ext::make_shared<InterpolatedYoYInflationCurve<Linear>>(
11411136 evaluationDate, yoyDates, yoyRates, iir->frequency (), dc);
11421137 yoyTs->enableExtrapolation ();
1143- hy.linkTo (yoyTs);
1138+
1139+ Handle<YoYInflationTermStructure> hy (yoyTs);
1140+ iir = ext::make_shared<YoYInflationIndex>(rpi, hy);
11441141
11451142 Schedule yoySchedule =
11461143 MakeSchedule ().from (nominalTS->referenceDate ())
@@ -1166,8 +1163,6 @@ BOOST_AUTO_TEST_CASE(testZeroBpsYoYInflationSwapFairRateAndSpread) {
11661163 BOOST_CHECK_EXCEPTION (
11671164 swap.fairSpread (), Error,
11681165 ExpectedErrorMessage (" result not available" ));
1169-
1170- hy.reset ();
11711166}
11721167
11731168BOOST_AUTO_TEST_CASE (testExpiredYoYInflationSwapFairRateAndSpread) {
@@ -1193,9 +1188,8 @@ BOOST_AUTO_TEST_CASE(testExpiredYoYInflationSwapFairRateAndSpread) {
11931188 199.2 , 200.1 , 200.4 , 201.1 , 202.7 , 201.6 , 203.1 , 204.4 , 205.4 , 206.2 ,
11941189 207.3 };
11951190
1196- RelinkableHandle<YoYInflationTermStructure> hy;
11971191 auto rpi = ext::make_shared<UKRPI >();
1198- auto iir = ext::make_shared<YoYInflationIndex>(rpi, hy );
1192+ auto iir = ext::make_shared<YoYInflationIndex>(rpi);
11991193 for (Size i = 0 ; i < std::size (fixData); i++) {
12001194 rpi->addFixing (rpiSchedule[i], fixData[i]);
12011195 }
@@ -1214,7 +1208,9 @@ BOOST_AUTO_TEST_CASE(testExpiredYoYInflationSwapFairRateAndSpread) {
12141208 auto yoyTs = ext::make_shared<InterpolatedYoYInflationCurve<Linear>>(
12151209 evaluationDate, yoyDates, yoyRates, iir->frequency (), dc);
12161210 yoyTs->enableExtrapolation ();
1217- hy.linkTo (yoyTs);
1211+
1212+ Handle<YoYInflationTermStructure> hy (yoyTs);
1213+ iir = ext::make_shared<YoYInflationIndex>(rpi, hy);
12181214
12191215 Schedule yoySchedule =
12201216 MakeSchedule ().from (nominalTS->referenceDate ())
@@ -1239,8 +1235,6 @@ BOOST_AUTO_TEST_CASE(testExpiredYoYInflationSwapFairRateAndSpread) {
12391235 BOOST_CHECK_EXCEPTION (
12401236 swap.fairSpread (), Error,
12411237 ExpectedErrorMessage (" result not available" ));
1242-
1243- hy.reset ();
12441238}
12451239
12461240BOOST_AUTO_TEST_CASE (testPeriod) {
@@ -1748,8 +1742,7 @@ BOOST_AUTO_TEST_CASE(testUsCpiLinearBootstrapAtMonthStart) {
17481742
17491743 Settings::instance ().evaluationDate () = evalDate;
17501744
1751- RelinkableHandle<ZeroInflationTermStructure> hz;
1752- auto index = ext::make_shared<USCPI >(hz);
1745+ auto index = ext::make_shared<USCPI >();
17531746
17541747 for (auto & [d, v] : fixings)
17551748 index->addFixing (d, v);
@@ -1767,7 +1760,6 @@ BOOST_AUTO_TEST_CASE(testUsCpiLinearBootstrapAtMonthStart) {
17671760 try {
17681761 auto curve = ext::make_shared<PiecewiseZeroInflationCurve<Linear>>(
17691762 evalDate, baseDate, Monthly, dc, helpers);
1770- hz.linkTo (curve);
17711763 curve->zeroRate (evalDate + 1 *Years);
17721764 } catch (const std::exception&) {
17731765 failureCount++;
@@ -1826,8 +1818,7 @@ BOOST_AUTO_TEST_CASE(testEuHicpFlatBootstrapAtMonthStart) {
18261818
18271819 Settings::instance ().evaluationDate () = evalDate;
18281820
1829- RelinkableHandle<ZeroInflationTermStructure> hz;
1830- auto index = ext::make_shared<EUHICPXT >(hz);
1821+ auto index = ext::make_shared<EUHICPXT >();
18311822
18321823 for (auto & [d, v] : fixings)
18331824 index->addFixing (d, v);
@@ -1846,20 +1837,16 @@ BOOST_AUTO_TEST_CASE(testEuHicpFlatBootstrapAtMonthStart) {
18461837 try {
18471838 auto curve = ext::make_shared<PiecewiseZeroInflationCurve<Linear>>(
18481839 evalDate, baseDate, Monthly, dc, helpers);
1849- hz.linkTo (curve);
18501840 curve->zeroRate (evalDate + 1 *Years);
18511841 } catch (const std::exception&) {
18521842 failureCount++;
18531843 }
18541844
1855- hz.linkTo (ext::shared_ptr<ZeroInflationTermStructure>());
1856-
18571845 // GlobalBootstrap
18581846 try {
18591847 auto curve = ext::make_shared<
18601848 PiecewiseZeroInflationCurve<Linear, GlobalBootstrap>>(
18611849 evalDate, baseDate, Monthly, dc, helpers);
1862- hz.linkTo (curve);
18631850 curve->zeroRate (evalDate + 1 *Years);
18641851 } catch (const std::exception&) {
18651852 globalFailureCount++;
@@ -1919,8 +1906,7 @@ BOOST_AUTO_TEST_CASE(testUkRpiFlatBootstrapAtMonthStart) {
19191906
19201907 Settings::instance ().evaluationDate () = evalDate;
19211908
1922- RelinkableHandle<ZeroInflationTermStructure> hz;
1923- auto index = ext::make_shared<UKRPI >(hz);
1909+ auto index = ext::make_shared<UKRPI >();
19241910
19251911 for (auto & [d, v] : fixings)
19261912 index->addFixing (d, v);
@@ -1940,20 +1926,16 @@ BOOST_AUTO_TEST_CASE(testUkRpiFlatBootstrapAtMonthStart) {
19401926 try {
19411927 auto curve = ext::make_shared<PiecewiseZeroInflationCurve<Linear>>(
19421928 evalDate, baseDate, Monthly, dc, helpers);
1943- hz.linkTo (curve);
19441929 curve->zeroRate (evalDate + 1 *Years);
19451930 } catch (const std::exception&) {
19461931 failureCount++;
19471932 }
19481933
1949- hz.linkTo (ext::shared_ptr<ZeroInflationTermStructure>());
1950-
19511934 // GlobalBootstrap
19521935 try {
19531936 auto curve = ext::make_shared<
19541937 PiecewiseZeroInflationCurve<Linear, GlobalBootstrap>>(
19551938 evalDate, baseDate, Monthly, dc, helpers);
1956- hz.linkTo (curve);
19571939 curve->zeroRate (evalDate + 1 *Years);
19581940 } catch (const std::exception&) {
19591941 globalFailureCount++;
@@ -2012,8 +1994,7 @@ BOOST_AUTO_TEST_CASE(testUsCpiLinearGlobalBootstrapAtMonthStart) {
20121994
20131995 Settings::instance ().evaluationDate () = evalDate;
20141996
2015- RelinkableHandle<ZeroInflationTermStructure> hz;
2016- auto index = ext::make_shared<USCPI >(hz);
1997+ auto index = ext::make_shared<USCPI >();
20171998
20181999 for (auto & [d, v] : fixings)
20192000 index->addFixing (d, v);
@@ -2032,7 +2013,6 @@ BOOST_AUTO_TEST_CASE(testUsCpiLinearGlobalBootstrapAtMonthStart) {
20322013 auto curve = ext::make_shared<
20332014 PiecewiseZeroInflationCurve<Linear, GlobalBootstrap>>(
20342015 evalDate, baseDate, Monthly, dc, helpers);
2035- hz.linkTo (curve);
20362016 curve->zeroRate (evalDate + 1 *Years);
20372017 } catch (const std::exception&) {
20382018 failureCount++;
@@ -2103,8 +2083,7 @@ BOOST_AUTO_TEST_CASE(testPillarCollisionWithDifferentMonthLengths) {
21032083
21042084 Settings::instance ().evaluationDate () = evalDate;
21052085
2106- RelinkableHandle<ZeroInflationTermStructure> hz;
2107- auto index = ext::make_shared<USCPI >(hz);
2086+ auto index = ext::make_shared<USCPI >();
21082087
21092088 for (auto & [d, v] : fixings)
21102089 index->addFixing (d, v);
@@ -2122,7 +2101,6 @@ BOOST_AUTO_TEST_CASE(testPillarCollisionWithDifferentMonthLengths) {
21222101 try {
21232102 auto curve = ext::make_shared<PiecewiseZeroInflationCurve<Linear>>(
21242103 evalDate, baseDate, Monthly, dc, helpers);
2125- hz.linkTo (curve);
21262104 curve->zeroRate (evalDate + 1 *Years);
21272105 } catch (const std::exception&) {
21282106 failureCount++;
0 commit comments