QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
defaultprobabilityhelpers.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008, 2009 Jose Aparicio
5 Copyright (C) 2008 Chris Kenyon
6 Copyright (C) 2008 Roland Lichters
7 Copyright (C) 2008 StatPro Italia srl
8 Copyright (C) 2023 Andrea Pellegatta
9
10 This file is part of QuantLib, a free-software/open-source library
11 for financial quantitative analysts and developers - http://quantlib.org/
12
13 QuantLib is free software: you can redistribute it and/or modify it
14 under the terms of the QuantLib license. You should have received a
15 copy of the license along with this program; if not, please email
16 <quantlib-dev@lists.sf.net>. The license is also available online at
17 <http://quantlib.org/license.shtml>.
18
19 This program is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21 FOR A PARTICULAR PURPOSE. See the license for more details.
22*/
23
28#ifndef quantlib_default_probability_helpers_hpp
29#define quantlib_default_probability_helpers_hpp
30
31#include <ql/termstructures/defaulttermstructure.hpp>
32#include <ql/termstructures/bootstraphelper.hpp>
33#include <ql/time/schedule.hpp>
34#include <ql/instruments/creditdefaultswap.hpp>
35
36namespace QuantLib {
37
38 class YieldTermStructure;
39 class CreditDefaultSwap;
40
42 typedef BootstrapHelper<DefaultProbabilityTermStructure>
46
49 public:
81 const Period& tenor,
82 Integer settlementDays,
83 Calendar calendar,
84 Frequency frequency,
85 BusinessDayConvention paymentConvention,
87 DayCounter dayCounter,
88 Real recoveryRate,
89 const Handle<YieldTermStructure>& discountCurve,
90 bool settlesAccrual = true,
91 bool paysAtDefaultTime = true,
92 const Date& startDate = Date(),
93 DayCounter lastPeriodDayCounter = DayCounter(),
94 bool rebatesAccrual = true,
96
99 const Period& tenor,
100 Integer settlementDays,
101 Calendar calendar,
102 Frequency frequency,
103 BusinessDayConvention paymentConvention,
105 DayCounter dayCounter,
106 Real recoveryRate,
107 const Handle<YieldTermStructure>& discountCurve,
108 bool settlesAccrual = true,
109 bool paysAtDefaultTime = true,
110 const Date& startDate = Date(),
111 DayCounter lastPeriodDayCounter = DayCounter(),
112 bool rebatesAccrual = true,
115 // NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
116 ext::shared_ptr<CreditDefaultSwap> swap() const {
117 return swap_;
118 }
119 void update() override;
120
121 protected:
122 void initializeDates() override;
123 virtual void resetEngine() = 0;
138
140 ext::shared_ptr<CreditDefaultSwap> swap_;
145 };
146
148 class SpreadCdsHelper : public CdsHelper {
149 public:
150 SpreadCdsHelper(const Handle<Quote>& runningSpread,
151 const Period& tenor,
152 Integer settlementDays,
153 const Calendar& calendar,
154 Frequency frequency,
155 BusinessDayConvention paymentConvention,
157 const DayCounter& dayCounter,
158 Real recoveryRate,
159 const Handle<YieldTermStructure>& discountCurve,
160 bool settlesAccrual = true,
161 bool paysAtDefaultTime = true,
162 const Date& startDate = Date(),
163 const DayCounter& lastPeriodDayCounter = DayCounter(),
164 bool rebatesAccrual = true,
166
168 Rate runningSpread,
169 const Period& tenor,
170 Integer settlementDays, // ISDA: 1
171 const Calendar& calendar,
172 Frequency frequency, // ISDA: Quarterly
173 BusinessDayConvention paymentConvention, // ISDA:Following
174 DateGeneration::Rule rule, // ISDA: CDS
175 const DayCounter& dayCounter, // ISDA: Actual/360
176 Real recoveryRate,
177 const Handle<YieldTermStructure>& discountCurve,
178 bool settlesAccrual = true,
179 bool paysAtDefaultTime = true,
180 const Date& startDate = Date(),
181 const DayCounter& lastPeriodDayCounter = DayCounter(), // ISDA: Actual/360(inc)
182 bool rebatesAccrual = true, // ISDA: true
184 Real impliedQuote() const override;
185
186 private:
187 void resetEngine() override;
188 };
189
192 public:
194 UpfrontCdsHelper(const Handle<Quote>& upfront,
195 Rate runningSpread,
196 const Period& tenor,
197 Integer settlementDays,
198 const Calendar& calendar,
199 Frequency frequency,
200 BusinessDayConvention paymentConvention,
202 const DayCounter& dayCounter,
203 Real recoveryRate,
204 const Handle<YieldTermStructure>& discountCurve,
205 Natural upfrontSettlementDays = 3,
206 bool settlesAccrual = true,
207 bool paysAtDefaultTime = true,
208 const Date& startDate = Date(),
209 const DayCounter& lastPeriodDayCounter = DayCounter(),
210 bool rebatesAccrual = true,
212
214 UpfrontCdsHelper(Rate upfront,
215 Rate runningSpread,
216 const Period& tenor,
217 Integer settlementDays,
218 const Calendar& calendar,
219 Frequency frequency,
220 BusinessDayConvention paymentConvention,
222 const DayCounter& dayCounter,
223 Real recoveryRate,
224 const Handle<YieldTermStructure>& discountCurve,
225 Natural upfrontSettlementDays = 3,
226 bool settlesAccrual = true,
227 bool paysAtDefaultTime = true,
228 const Date& startDate = Date(),
229 const DayCounter& lastPeriodDayCounter = DayCounter(),
230 bool rebatesAccrual = true,
232 Real impliedQuote() const override;
233
234 private:
236 void initializeDates() override;
237 void resetEngine() override;
241 };
242
243}
244
245
246#endif
const Handle< Quote > & quote() const
calendar class
Definition: calendar.hpp:61
Base class for CDS helpers.
Handle< YieldTermStructure > discountCurve_
RelinkableHandle< DefaultProbabilityTermStructure > probability_
void setTermStructure(DefaultProbabilityTermStructure *) override
ext::shared_ptr< CreditDefaultSwap > swap() const
CreditDefaultSwap::PricingModel model_
BusinessDayConvention paymentConvention_
virtual void resetEngine()=0
ext::shared_ptr< CreditDefaultSwap > swap_
Date protectionStart_
protection effective date.
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Default probability term structure.
Shared handle to an observable.
Definition: handle.hpp:41
Bootstrap helper with date schedule relative to global evaluation date.
Relinkable handle to an observable.
Definition: handle.hpp:112
Payment schedule.
Definition: schedule.hpp:40
Spread-quoted CDS hazard rate bootstrap helper.
Upfront-quoted CDS hazard rate bootstrap helper.
Frequency
Frequency of events.
Definition: frequency.hpp:37
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
QL_INTEGER Integer
integer number
Definition: types.hpp:35
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
BootstrapHelper< DefaultProbabilityTermStructure > DefaultProbabilityHelper
alias for default-probability bootstrap helpers
RelativeDateBootstrapHelper< DefaultProbabilityTermStructure > RelativeDateDefaultProbabilityHelper