QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
defaulttype.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2009 StatPro Italia srl
5 Copyright (C) 2009 Jose Aparicio
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file defaulttype.hpp
22 \brief Classes for default-event description.
23*/
24
25
26#ifndef quantlib_default_type_hpp
27#define quantlib_default_type_hpp
28
29#include <ql/time/period.hpp>
30
31namespace QuantLib {
32
33 //! Seniority of a bond.
34 /*! They are also ISDA tier/seniorities used for CDS conventional
35 spreads.
36 */
37 enum Seniority {
38 SecDom = 0,
43 // Unassigned value, allows for default RR quote
45 // markit parlance
51 };
52
53
54 //! Atomic (single contractual event) default events.
55 /*! Default types defined as enum to allow easy aggregation of
56 types. Theres an event algebra logic by default provided by
57 DefaultType. If your new type requires more sofisticated test
58 you need to derive from it as in FailureToPay
59 */
61 enum Type {
62 // Includes one of the restructuring cases
69 // synonyms
73 // Other non-isda
74 Downgrade, // Non-ISDA, not in FpML
75 MergerEvent // Non-ISDA, not in FpML
76 };
77 };
78
79
80 // these could be merged with the ones above if not because
81 // restructuring types can not be combined together.
82
83 //! Restructuring type
85 enum Type {
91 // Markit notation:
96 };
97 };
98
99
100 //! Atomic credit-event type.
101 /*! This class encapsulates the ISDA default contractual types and
102 their combinations. Non-atomicity works only at the atomic
103 type level, obviating the specific event characteristics which
104 it is accounted for only in derived classes.
105 */
107 public:
108 explicit DefaultType(AtomicDefault::Type defType =
111
112 virtual ~DefaultType() = default;
113
115 return defTypes_;
116 }
118 bool isRestructuring() const {
120 }
121
122 // bool isAtomic() const { return defTypes_.size() == 1;}
123
124 /*! Returns true if one or a set of event types is within this
125 one and as such will be recognised as a trigger. Not the
126 same as equality.
127
128 Notice that these methods do not include any event logical
129 hierarchy. The match is in a strict sense. If event B is
130 contained in (implied by) event A this would not send a
131 match. This policies should be implemented at the
132 CreditEvent class, which is polymorphic.
133 */
135 return defTypes_ == defType;
136 }
137
139 return (restrType_ == resType) ||
141 }
142 protected:
143 //std::set<AtomicDefault::Type> defTypes_;
146 };
147
148
149 /*! Equality is the criteria for indexing the curves. This depends
150 only on the atomic types and not on idiosincracies of derived
151 type as mentioned in the functional documentation (specific
152 event characteristics are relevant to credit event matching
153 but not to the probability meaning). operator== is also used
154 to remove duplicates in some containers. This ensures we do
155 not have two equal events (despite having different
156 characteristics) in those containers. This makes sense, theres
157 no logic in having two FailureToPay in a contract even if they
158 have different characteristics.
159 */
160 bool operator==(const DefaultType& lhs, const DefaultType& rhs);
161
162
163
164 //! Failure to Pay atomic event type.
165 class FailureToPay : public DefaultType {
166 public:
167 // Only atomic construction.
168 // Amount contract by default is in dollars as per ISDA doc and not
169 // the contract curr. Theres an issue here...... FIX ME
170 explicit FailureToPay(const Period& grace,
171 Real amount = 1.e+6)
173 gracePeriod_(grace), amountRequired_(amount) {}
174
176 const Period& gracePeriod() const {return gracePeriod_;}
177 private:
178 // Grace period to consider the event. If payment occurs during
179 // the period the event should be removed from its container.
181 // Minimum default amount triggering the event
183 };
184
185}
186
187#endif
Atomic credit-event type.
virtual ~DefaultType()=default
Restructuring::Type restructuringType() const
Restructuring::Type restrType_
AtomicDefault::Type defTypes_
bool containsRestructuringType(Restructuring::Type resType) const
bool containsDefaultType(AtomicDefault::Type defType) const
bool isRestructuring() const
AtomicDefault::Type defaultType() const
Failure to Pay atomic event type.
const Period & gracePeriod() const
FailureToPay(const Period &grace, Real amount=1.e+6)
Real amountRequired() const
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
bool operator==(const Currency &c1, const Currency &c2)
Definition: currency.hpp:231
Seniority
Seniority of a bond.
Definition: defaulttype.hpp:37
period- and frequency-related classes and enumerations
Atomic (single contractual event) default events.
Definition: defaulttype.hpp:60
Restructuring type.
Definition: defaulttype.hpp:84