Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Functions
riskparticipationagreement.cpp File Reference
#include <boost/test/unit_test.hpp>
#include <oret/toplevelfixture.hpp>
#include <ored/scripting/engines/analyticblackriskparticipationagreementengine.hpp>
#include <ored/scripting/engines/numericlgmriskparticipationagreementengine.hpp>
#include <qle/methods/multipathgeneratorbase.hpp>
#include <qle/models/irlgm1fconstantparametrization.hpp>
#include <qle/models/lgm.hpp>
#include <qle/models/lgmimpliedyieldtermstructure.hpp>
#include <qle/pricingengines/analyticlgmswaptionengine.hpp>
#include <ql/cashflows/couponpricer.hpp>
#include <ql/cashflows/iborcoupon.hpp>
#include <ql/currencies/europe.hpp>
#include <ql/exercise.hpp>
#include <ql/experimental/coupons/strippedcapflooredcoupon.hpp>
#include <ql/indexes/ibor/euribor.hpp>
#include <ql/indexes/iborindex.hpp>
#include <ql/indexes/swap/euriborswap.hpp>
#include <ql/instruments/makevanillaswap.hpp>
#include <ql/instruments/nonstandardswap.hpp>
#include <ql/math/optimization/levenbergmarquardt.hpp>
#include <ql/models/shortrate/calibrationhelpers/swaptionhelper.hpp>
#include <ql/pricingengines/swaption/blackswaptionengine.hpp>
#include <ql/termstructures/credit/flathazardrate.hpp>
#include <ql/termstructures/volatility/swaption/swaptionconstantvol.hpp>
#include <ql/termstructures/yield/flatforward.hpp>
#include <ql/time/calendars/target.hpp>
#include <ql/time/daycounters/actualactual.hpp>
#include <ql/timegrid.hpp>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/mean.hpp>
#include <boost/accumulators/statistics/stats.hpp>
#include <boost/timer/timer.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (testStandardPayerSwap)
 
 BOOST_AUTO_TEST_CASE (testStandardReceiverSwap)
 
 BOOST_AUTO_TEST_CASE (testAmortisingPayerSwap)
 
 BOOST_AUTO_TEST_CASE (testAmortisingReceiverSwap)
 
 BOOST_AUTO_TEST_CASE (testAccretingPayerSwap)
 
 BOOST_AUTO_TEST_CASE (testAccretingReceiverSwap)
 
 BOOST_AUTO_TEST_CASE (testCapFloors)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/7]

BOOST_AUTO_TEST_CASE ( testStandardPayerSwap  )

Definition at line 321 of file riskparticipationagreement.cpp.

321 {
322 runTest({10000.0}, true, 10.0,
323 {0, 1.94889, 15.7715, 24.0619, 54.8255, 55.7279, 95.6096, 91.7498, 133.741, 123.373,
324 164.17, 147.664, 189.878, 166.109, 207.458, 179.875, 220.102, 187.612, 226.417, 190.731,
325 227.738, 188.212, 222.535, 180.287, 214.038, 169.203, 200.895, 154.238, 183.085, 133.985,
326 161.588, 111.699, 135.997, 85.3633, 107.052, 56.2545, 74.7086, 25.7101, 38.9068, 1.31757});
327}

◆ BOOST_AUTO_TEST_CASE() [2/7]

BOOST_AUTO_TEST_CASE ( testStandardReceiverSwap  )

Definition at line 329 of file riskparticipationagreement.cpp.

329 {
330 runTest({10000.0}, false, 10.0,
331 {1776.41, 1878.45, 1694.92, 1802.31, 1637.38, 1736.49, 1582.74, 1677.57, 1526.22, 1611.41,
332 1463.59, 1542.34, 1396.47, 1467.08, 1322.19, 1388.18, 1244.17, 1303.92, 1159.84, 1214.88,
333 1072.06, 1122.67, 978.803, 1026.29, 882.843, 926.86, 783.296, 824.455, 679.52, 718.399,
334 572.469, 608.334, 463.113, 497.353, 351.281, 384.799, 236.4, 271.088, 119.076, 164.356});
335}

◆ BOOST_AUTO_TEST_CASE() [3/7]

BOOST_AUTO_TEST_CASE ( testAmortisingPayerSwap  )

Definition at line 337 of file riskparticipationagreement.cpp.

337 {
338 runTest({10000.0, 9500.0, 9000.0, 8500.0, 8000.0, 7500.0, 7000.0, 6500.0, 6000.0, 5500.0, 5000.0,
339 4500.0, 4000.0, 3500.0, 3000.0, 2500.0, 2000.0, 1500.0, 1000.0, 500.0, 0.0},
340 true, 5.0, {0, 0.58703, 8.11856, 8.93971, 26.7995, 20.7611, 44.169, 33.6139, 58.2056, 43.9656,
341 67.223, 49.9792, 72.8682, 52.7195, 74.1339, 53.0533, 72.9152, 51.5704, 69.0406, 47.9078,
342 63.6394, 42.9462, 56.4375, 36.8842, 48.762, 30.607, 40.6079, 24.2613, 32.3475, 17.8779,
343 24.4077, 12.3198, 17.092, 7.4161, 10.7417, 3.56567, 5.61611, 1.08903, 1.94534, 0.0658784});
344}

◆ BOOST_AUTO_TEST_CASE() [4/7]

BOOST_AUTO_TEST_CASE ( testAmortisingReceiverSwap  )

Definition at line 346 of file riskparticipationagreement.cpp.

346 {
347 runTest({10000.0, 9500.0, 9000.0, 8500.0, 8000.0, 7500.0, 7000.0, 6500.0, 6000.0, 5500.0, 5000.0,
348 4500.0, 4000.0, 3500.0, 3000.0, 2500.0, 2000.0, 1500.0, 1000.0, 500.0, 0.0},
349 false, 50.0, {962.21, 1062.92, 873.019, 967.955, 799.857, 882.248, 731.282, 804.481, 664.708, 726.901,
350 599.229, 653.365, 535.172, 581.061, 472.101, 511.799, 411.877, 445.908, 353.651, 382.434,
351 299.225, 323.595, 247.998, 268.821, 200.983, 218.353, 158.261, 172.636, 119.932, 131.857,
352 86.3659, 95.7154, 58.1326, 65.4286, 35.2337, 40.7063, 17.7519, 21.5932, 5.95378, 8.21779});
353}

◆ BOOST_AUTO_TEST_CASE() [5/7]

BOOST_AUTO_TEST_CASE ( testAccretingPayerSwap  )

Definition at line 355 of file riskparticipationagreement.cpp.

355 {
356 runTest({10000.0, 11000.0, 12000.0, 13000.0, 14000.0, 15000.0, 16000.0, 17000.0, 18000.0, 19000.0,
357 20000.0, 21000.0, 22000.0, 23000.0, 24000.0, 25000.0, 26000.0, 27000.0, 28000.0, 29000.0},
358 true, 20.0, {0, 5.03316, 31.0906, 56.0286, 110.937, 128.441, 198.589, 210.596, 284.946, 284.878,
359 358.21, 345.452, 424.04, 395.573, 474.253, 435.555, 514.612, 461.857, 541.256, 478.229,
360 556.038, 480.233, 554.782, 468.493, 544.637, 447.635, 521.492, 415.265, 484.579, 367.228,
361 435.953, 311.242, 373.81, 241.924, 299.673, 162.093, 212.894, 75.2118, 112.83, 3.82094});
362}

◆ BOOST_AUTO_TEST_CASE() [6/7]

BOOST_AUTO_TEST_CASE ( testAccretingReceiverSwap  )

Definition at line 364 of file riskparticipationagreement.cpp.

364 {
365 runTest({10000.0, 11000.0, 12000.0, 13000.0, 14000.0, 15000.0, 16000.0, 17000.0, 18000.0, 19000.0,
366 20000.0, 21000.0, 22000.0, 23000.0, 24000.0, 25000.0, 26000.0, 27000.0, 28000.0, 29000.0},
367 false, 20.0, {3404.82, 3509.87, 3338.75, 3472.73, 3312.48, 3447.74, 3285.74, 3426.31, 3249.38, 3383.13,
368 3192.44, 3322.71, 3119.21, 3241.8, 3022.51, 3142.98, 2908.89, 3022.1, 2772.3, 2881.64,
369 2617.82, 2722.29, 2440.46, 2542.63, 2246.61, 2345.11, 2033.39, 2129.17, 1798.72, 1892.51,
370 1544.68, 1634.35, 1273.08, 1361.87, 983.376, 1073.45, 673.695, 770.339, 345.319, 476.632});
371}

◆ BOOST_AUTO_TEST_CASE() [7/7]

BOOST_AUTO_TEST_CASE ( testCapFloors  )

Definition at line 423 of file riskparticipationagreement.cpp.

423 {
424
425 constexpr Real tol = 1E-10;
426
427 // underlying is receiver
428
429 // no cap/floor
430 Real plain = computeUnderlyingNpv(false, Null<Real>(), Null<Real>(), false);
431
432 // capped/floored coupon
433 Real capped = computeUnderlyingNpv(false, 0.03, Null<Real>(), false);
434 Real floored = computeUnderlyingNpv(false, Null<Real>(), 0.01, false);
435 Real collared = computeUnderlyingNpv(false, 0.03, 0.01, false);
436
437 // the embedded option
438 Real cap = computeUnderlyingNpv(false, 0.03, Null<Real>(), true);
439 Real floor = computeUnderlyingNpv(false, Null<Real>(), 0.01, true);
440 Real collar = computeUnderlyingNpv(false, 0.03, 0.01, true);
441
442 BOOST_CHECK_CLOSE(capped + cap, plain, tol);
443 BOOST_CHECK_CLOSE(floored - floor, plain, tol);
444 BOOST_CHECK_CLOSE(collared - collar, plain, tol);
445
446 // underlying is payer
447
448 // no cap/floor
449 Real plain2 = computeUnderlyingNpv(true, Null<Real>(), Null<Real>(), false);
450
451 // capped/floored coupon
452 Real capped2 = computeUnderlyingNpv(true, 0.03, Null<Real>(), false);
453 Real floored2 = computeUnderlyingNpv(true, Null<Real>(), 0.01, false);
454 Real collared2 = computeUnderlyingNpv(true, 0.03, 0.01, false);
455
456 // the embedded option
457 Real cap2 = computeUnderlyingNpv(true, 0.03, Null<Real>(), true);
458 Real floor2 = computeUnderlyingNpv(true, Null<Real>(), 0.01, true);
459 Real collar2 = computeUnderlyingNpv(true, 0.03, 0.01, true);
460
461 BOOST_CHECK_CLOSE(capped2 + cap2, plain2, tol);
462 BOOST_CHECK_CLOSE(floored2 - floor2, plain2, tol);
463 BOOST_CHECK_CLOSE(collared2 - collar2, plain2, tol);
464
465 // check sign changes between underlying receiver and payer
466 BOOST_CHECK_CLOSE(plain, -plain2, tol);
467 BOOST_CHECK_CLOSE(capped, -capped2, tol);
468 BOOST_CHECK_CLOSE(floored, -floored2, tol);
469 BOOST_CHECK_CLOSE(collared, -collared2, tol);
470 BOOST_CHECK_CLOSE(cap, -cap2, tol);
471 BOOST_CHECK_CLOSE(floor, -floor2, tol);
472 BOOST_CHECK_CLOSE(collar, -collar2, tol);
473}