18#include <ql/time/schedule.hpp>
27 BusinessDayConvention bdc,
const std::vector<Period>& tenors,
28 const std::vector<Real>& detachmentPoints,
29 const DayCounter& dc,
const Date& startDate,
30 boost::optional<DateGeneration::Rule> rule)
31 :
CorrelationTermStructure(refDate, cal, dc), bdc_(bdc), startDate_(startDate), rule_(rule), tenors_(tenors), detachmentPoints_(detachmentPoints) {
38 BusinessDayConvention bdc,
const std::vector<Period>& tenors,
39 const std::vector<double>& detachmentPoints,
40 const DayCounter& dc,
const Date& startDate,
41 boost::optional<DateGeneration::Rule> rule)
43 detachmentPoints_(detachmentPoints) {
49 Period prevTenor(0, Days);
50 for (
size_t i = 0; i <
tenors_.size(); ++i) {
51 QL_REQUIRE(
tenors_[i] > prevTenor,
"Tenors need to be sorted and larger than 0 * Days");
55 double prevDetachmentPoint = 0.0;
58 "Detachmentpoints need to be sorted and between (0, 1].");
60 "Detachmentpoints need to be sorted and between (0, 1].");
65 const Date& refDate = referenceDate();
67 Calendar cldr = calendar();
69 for (Size i = 0; i <
tenors_.size(); i++) {
73 if (*
rule_ == DateGeneration::CDS2015 || *
rule_ == DateGeneration::CDS ||
74 *
rule_ == DateGeneration::OldCDS) {
82 times_.push_back(timeFromReference(d));
84 QL_REQUIRE(!
dates_.empty(),
"no dates left after removing expired dates");
89 bool extrapolationNeeded =
91 QL_REQUIRE(extrapolate || allowsExtrapolation() || !extrapolationNeeded,
92 "No extrapolation allowed, require t = "
93 << t <<
" to be between (" <<
minTime() <<
", " <<
maxTime() <<
") and detachmentPoint = " << strike
abstract base correlation structure and an 2d-interpolated base correlation structure
void initializeDatesAndTimes() const
std::vector< Period > tenors_
virtual double maxDetachmentPoint() const
std::vector< Date > dates_
virtual void checkRange(Time t, Real strike, bool extrapolate) const override
Extra time range check for minimum time, then calls TermStructure::checkRange.
boost::optional< DateGeneration::Rule > rule_
virtual Time maxTime() const override
std::vector< double > detachmentPoints_
BusinessDayConvention bdc_
BaseCorrelationTermStructure()
virtual double minDetachmentPoint() const
virtual Time minTime() const override
The minimum time for which the curve can return values.
std::vector< double > times_
Correlation term structure.