56 const std::map<Seniority, Real>& recoveryRates )
60 "NoSeniority is not a valid realized seniority.");
81 "NoSeniority is not valid for recovery rate request.");
82 auto itmatch = recoveryRates_.find(sen);
83 if(itmatch != recoveryRates_.end()) {
84 return itmatch->second;
95 const Date& settleDate,
96 const std::map<Seniority, Real>& recoveryRates)
102 "Settlement date should be after default date.");
103 QL_REQUIRE(recoveryRates.find(bondsSen) != recoveryRates.end(),
104 "Settled events must contain the seniority of the default");
113 const Date& settleDate,
115 : bondsCurrency_(
std::move(curr)), defaultDate_(creditEventDate), eventType_(atomicEvType),
116 bondsSeniority_(bondsSen), defSettlement_(settleDate, bondsSen, recoveryRate) {
119 "Settlement date should be after default date.");
132 for(
Size i=0; i<contractKey.
size(); i++) {
149 const ext::shared_ptr<DefaultType>& contractEvType)
const {
150 ext::shared_ptr<FailureToPay> eveType =
151 ext::dynamic_pointer_cast<FailureToPay>(contractEvType);
153 if(!eveType)
return false;
154 if(defaultedAmount_ < eveType->amountRequired())
return false;
156 return this->
hasOccurred(today - eveType->gracePeriod(),
true);
164 Real defaultedAmount,
166 const Date& settleDate,
167 const std::map<Seniority, Real>&
176 defaultedAmount_(defaultedAmount) { }
181 Real defaultedAmount,
183 const Date& settleDate,
192 defaultedAmount_(defaultedAmount) { }
200 const Date& settleDate,
201 const std::map<Seniority, Real>&
212 "Bankruptcy event should have settled for all seniorities.");
220 const Date& settleDate,
degenerate base class for the Acyclic Visitor pattern
BankruptcyEvent(const Date &creditEventDate, const Currency &curr, Seniority bondsSen, const Date &settleDate, const std::map< Seniority, Real > &recoveryRates)
DefaultSettlement(const Date &date, const std::map< Seniority, Real > &recoveryRates)
void accept(AcyclicVisitor &) override
Real recoveryRate(Seniority sen) const
std::map< Seniority, Real > recoveryRates_
Realized recovery rates.
Date date() const override
returns the date at which the event occurs
Credit event on a bond of a certain seniority(ies)/currency.
virtual Real recoveryRate(Seniority seniority) const
virtual bool matchesEventType(const ext::shared_ptr< DefaultType > &contractEvType) const
const Currency & currency() const
returns the currency of the bond this event refers to.
void accept(AcyclicVisitor &) override
DefaultEvent(const Date &creditEventDate, const DefaultType &atomicEvType, Currency curr, Seniority bondsSen, const Date &settleDate=Null< Date >(), const std::map< Seniority, Real > &recoveryRates=rate_map())
virtual bool matchesDefaultKey(const DefaultProbKey &contractKey) const
Seniority bondsSeniority_
Date date() const override
returns the date at which the event occurs
DefaultSettlement defSettlement_
const DefaultType & defaultType() const
Seniority eventSeniority() const
returns the seniority of the bond that triggered the event.
Seniority seniority() const
const Currency & currency() const
const std::vector< ext::shared_ptr< DefaultType > > & eventTypes() const
Atomic credit-event type.
virtual void accept(AcyclicVisitor &)
virtual bool hasOccurred(const Date &refDate=Date(), ext::optional< bool > includeRefDate=ext::nullopt) const
returns true if an event has already occurred before a date
bool matchesEventType(const ext::shared_ptr< DefaultType > &contractEvType) const override
FailureToPayEvent(const Date &creditEventDate, const Currency &curr, Seniority bondsSen, Real defaultedAmount, const Date &settleDate, const std::map< Seniority, Real > &recoveryRates)
Failure to Pay atomic event type.
template class providing a null value for a given type.
DateProxy & evaluationDate()
the date at which pricing is to be performed.
static Settings & instance()
access to the unique instance
Visitor for a specific class
virtual void visit(T &)=0
Classes for default-event description.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
std::size_t Size
size of a container
bool operator==(const Currency &c1, const Currency &c2)
std::map< Seniority, Real > makeIsdaConvMap()
Helper function for conventional recoveries. Returns the ISDA.
Seniority
Seniority of a bond.
ext::shared_ptr< BlackVolTermStructure > v
global repository for run-time library settings
Atomic (single contractual event) default events.
degenerate base class for the Acyclic Visitor pattern