Skip to content

Commit 49108fc

Browse files
committed
Merge branch 'QPR-11180' into 'master'
Merge cds instrument, engine and helpers into ql Closes QPR-11180 See merge request qs/quantlib!32
2 parents dac0aa1 + 26fcccc commit 49108fc

12 files changed

Lines changed: 1051 additions & 167 deletions

Examples/CDS/CDS.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void example01() {
102102
new SimpleQuote(quoted_spreads[i]))),
103103
tenors[i], settlementDays, calendar, Quarterly, Following,
104104
DateGeneration::TwentiethIMM, Actual365Fixed(),
105-
recovery_rate, tsCurve)));
105+
recovery_rate, tsCurve, true, CreditDefaultSwap::ProtectionPaymentTime::atDefault)));
106106
}
107107

108108
// Bootstrap hazard rates
@@ -143,7 +143,8 @@ void example01() {
143143
.withTerminationDateConvention(Unadjusted)
144144
.withRule(DateGeneration::TwentiethIMM);
145145
CreditDefaultSwap cds_3m(Protection::Seller, nominal, quoted_spreads[0],
146-
cdsSchedule, Following, Actual365Fixed());
146+
cdsSchedule, Following, Actual365Fixed(),
147+
true, CreditDefaultSwap::ProtectionPaymentTime::atDefault);
147148

148149
cdsSchedule = MakeSchedule()
149150
.from(settlementDate)
@@ -153,7 +154,8 @@ void example01() {
153154
.withTerminationDateConvention(Unadjusted)
154155
.withRule(DateGeneration::TwentiethIMM);
155156
CreditDefaultSwap cds_6m(Protection::Seller, nominal, quoted_spreads[1],
156-
cdsSchedule, Following, Actual365Fixed());
157+
cdsSchedule, Following, Actual365Fixed(),
158+
true, CreditDefaultSwap::ProtectionPaymentTime::atDefault);
157159

158160
cdsSchedule = MakeSchedule()
159161
.from(settlementDate)
@@ -163,7 +165,8 @@ void example01() {
163165
.withTerminationDateConvention(Unadjusted)
164166
.withRule(DateGeneration::TwentiethIMM);
165167
CreditDefaultSwap cds_1y(Protection::Seller, nominal, quoted_spreads[2],
166-
cdsSchedule, Following, Actual365Fixed());
168+
cdsSchedule, Following, Actual365Fixed(),
169+
true, CreditDefaultSwap::ProtectionPaymentTime::atDefault);
167170

168171
cdsSchedule = MakeSchedule()
169172
.from(settlementDate)
@@ -173,7 +176,8 @@ void example01() {
173176
.withTerminationDateConvention(Unadjusted)
174177
.withRule(DateGeneration::TwentiethIMM);
175178
CreditDefaultSwap cds_2y(Protection::Seller, nominal, quoted_spreads[3],
176-
cdsSchedule, Following, Actual365Fixed());
179+
cdsSchedule, Following, Actual365Fixed(),
180+
true, CreditDefaultSwap::ProtectionPaymentTime::atDefault);
177181

178182
cds_3m.setPricingEngine(engine);
179183
cds_6m.setPricingEngine(engine);
@@ -350,7 +354,7 @@ std::copy(cdsSchedule.begin(), cdsSchedule.end(),
350354
ext::shared_ptr<CreditDefaultSwap> trade =
351355
ext::shared_ptr<CreditDefaultSwap>(
352356
new CreditDefaultSwap(Protection::Buyer, 100000000.0, 0.01, sched,
353-
Following, Actual360(), true, true,
357+
Following, Actual360(), true, CreditDefaultSwap::ProtectionPaymentTime::atDefault,
354358
Date(22,October,2014), ext::shared_ptr<Claim>(),
355359
Actual360(true), true));
356360

@@ -373,7 +377,7 @@ std::copy(cdsSchedule.begin(), cdsSchedule.end(),
373377

374378
ext::shared_ptr<CdsHelper> cds5y(new SpreadCdsHelper(
375379
0.00672658551, 4 * Years + 6 * Months, 1, WeekendsOnly(), Quarterly,
376-
Following, DateGeneration::CDS, Actual360(), 0.4, rateTs, true, true,
380+
Following, DateGeneration::CDS, Actual360(), 0.4, rateTs, true, CreditDefaultSwap::ProtectionPaymentTime::atDefault,
377381
Date(), Actual360(true), true, CreditDefaultSwap::ISDA));
378382

379383
isdaCdsHelper.push_back(cds5y);
@@ -559,27 +563,27 @@ void example03() {
559563
CreditDefaultSwap::PricingModel model = CreditDefaultSwap::ISDA;
560564
ext::shared_ptr<CdsHelper> cds6m(new SpreadCdsHelper(
561565
0.007927, 6 * Months, 1, WeekendsOnly(), Quarterly, Following,
562-
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, true, Date(),
566+
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, CreditDefaultSwap::ProtectionPaymentTime::atDefault, Date(),
563567
Actual360(true), true, model));
564568
ext::shared_ptr<CdsHelper> cds1y(new SpreadCdsHelper(
565569
0.007927, 1 * Years, 1, WeekendsOnly(), Quarterly, Following,
566-
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, true, Date(),
570+
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, CreditDefaultSwap::ProtectionPaymentTime::atDefault, Date(),
567571
Actual360(true), true, model));
568572
ext::shared_ptr<CdsHelper> cds3y(new SpreadCdsHelper(
569573
0.012239, 3 * Years, 1, WeekendsOnly(), Quarterly, Following,
570-
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, true, Date(),
574+
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, CreditDefaultSwap::ProtectionPaymentTime::atDefault, Date(),
571575
Actual360(true), true, model));
572576
ext::shared_ptr<CdsHelper> cds5y(new SpreadCdsHelper(
573577
0.016979, 5 * Years, 1, WeekendsOnly(), Quarterly, Following,
574-
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, true, Date(),
578+
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, CreditDefaultSwap::ProtectionPaymentTime::atDefault, Date(),
575579
Actual360(true), true, model));
576580
ext::shared_ptr<CdsHelper> cds7y(new SpreadCdsHelper(
577581
0.019271, 7 * Years, 1, WeekendsOnly(), Quarterly, Following,
578-
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, true, Date(),
582+
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, CreditDefaultSwap::ProtectionPaymentTime::atDefault, Date(),
579583
Actual360(true), true, model));
580584
ext::shared_ptr<CdsHelper> cds10y(new SpreadCdsHelper(
581585
0.020860, 10 * Years, 1, WeekendsOnly(), Quarterly, Following,
582-
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, true, Date(),
586+
DateGeneration::CDS, Actual360(), 0.4, isdaYts, true, CreditDefaultSwap::ProtectionPaymentTime::atDefault, Date(),
583587
Actual360(true), true, model));
584588

585589
std::vector<ext::shared_ptr<DefaultProbabilityHelper> > isdaCdsHelpers;

0 commit comments

Comments
 (0)