27 bool between(
const ext::shared_ptr<DefaultEvent>& e,
30 bool includeRefDate =
false) {
31 return !e->hasOccurred(start, includeRefDate) &&
32 e->hasOccurred(end, includeRefDate);
36 Issuer::Issuer(std::vector<std::pair<DefaultProbKey, Handle<DefaultProbabilityTermStructure> > >
39 : probabilities_(
std::move(probabilities)), events_(
std::move(events)) {}
41 Issuer::Issuer(
const std::vector<std::vector<ext::shared_ptr<DefaultType> > >& eventTypes,
42 const std::vector<Currency>& currencies,
43 const std::vector<Seniority>& seniorities,
46 : events_(
std::move(events)) {
47 QL_REQUIRE((eventTypes.size() == curves.size()) &&
48 (curves.size()== currencies.size()) &&
49 (currencies.size() == seniorities.size()),
50 "Incompatible size of Issuer parameters.");
52 for(
Size i=0; i <eventTypes.size(); i++) {
62 if (key == probabilitie.first)
63 return probabilitie.second;
64 QL_FAIL(
"Probability curve not available.");
67 ext::shared_ptr<DefaultEvent>
75 for (
const auto& event :
events_) {
76 if (event->matchesDefaultKey(contractKey) && between(event, start, end, includeRefDate))
79 return ext::shared_ptr<DefaultEvent>();
83 std::vector<ext::shared_ptr<DefaultEvent> >
90 std::vector<ext::shared_ptr<DefaultEvent> > defaults;
92 for (
const auto& event :
events_) {
93 if (event->matchesDefaultKey(contractKey) && between(event, start, end, includeRefDate))
94 defaults.push_back(event);
Shared handle to an observable.
ext::shared_ptr< DefaultEvent > defaultedBetween(const Date &start, const Date &end, const DefaultProbKey &key, bool includeRefDate=false) const
If a default event with the required seniority and.
DefaultEventSet events_
History of past events affecting this issuer. Notice it is possible.
const Handle< DefaultProbabilityTermStructure > & defaultProbability(const DefaultProbKey &key) const
std::vector< std::pair< DefaultProbKey, Handle< DefaultProbabilityTermStructure > > > probabilities_
probabilities of events for each bond collection
std::vector< ext::shared_ptr< DefaultEvent > > defaultsBetween(const Date &start, const Date &end, const DefaultProbKey &contractKey, bool includeRefDate) const
Issuer(std::vector< key_curve_pair > probabilities=std::vector< key_curve_pair >(), DefaultEventSet events=DefaultEventSet())
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
std::size_t Size
size of a container
Classes for credit-name handling.
std::set< ext::shared_ptr< DefaultEvent >, earlier_than< ext::shared_ptr< DefaultEvent > > > DefaultEventSet