27#ifndef quantlib_interpolated_hazard_rate_curve_hpp
28#define quantlib_interpolated_hazard_rate_curve_hpp
38 template <
class Interpolator>
44 const std::vector<Date>&
dates,
50 const Interpolator& interpolator = {});
52 const std::vector<Date>&
dates,
56 const Interpolator& interpolator);
58 const std::vector<Date>&
dates,
61 const Interpolator& interpolator);
68 const std::vector<Time>&
times()
const;
69 const std::vector<Date>&
dates()
const;
70 const std::vector<Real>&
data()
const;
72 std::vector<std::pair<Date, Real> >
nodes()
const;
79 const Interpolator& interpolator = {});
85 const Interpolator& interpolator = {});
92 const Interpolator& interpolator = {});
108 return dates_.back();
112 inline const std::vector<Time>&
118 inline const std::vector<Date>&
124 inline const std::vector<Real>&
130 inline const std::vector<Rate>&
136 inline std::vector<std::pair<Date, Real> >
138 std::vector<std::pair<Date, Real> >
results(dates_.size());
139 for (
Size i=0; i<dates_.size(); ++i)
140 results[i] = std::make_pair(dates_[i], this->data_[i]);
150 if (t <= this->times_.back())
151 return this->interpolation_(
t,
true);
154 return this->data_.back();
164 if (t <= this->times_.back()) {
165 integral = this->interpolation_.primitive(
t,
true);
168 integral = this->interpolation_.primitive(this->times_.back(),
true)
169 + this->data_.back()*(
t - this->times_.back());
171 return std::exp(-integral);
176 const DayCounter& dayCounter,
177 const std::vector<Handle<Quote> >& jumps,
178 const std::vector<Date>& jumpDates,
179 const T& interpolator)
180 : HazardRateStructure(dayCounter, jumps, jumpDates),
181 InterpolatedCurve<
T>(interpolator) {}
185 const Date& referenceDate,
186 const DayCounter& dayCounter,
187 const std::vector<Handle<Quote> >& jumps,
188 const std::vector<Date>& jumpDates,
189 const T& interpolator)
190 : HazardRateStructure(referenceDate, Calendar(), dayCounter, jumps, jumpDates),
191 InterpolatedCurve<
T>(interpolator) {}
196 const Calendar& calendar,
197 const DayCounter& dayCounter,
198 const std::vector<Handle<Quote> >& jumps,
199 const std::vector<Date>& jumpDates,
200 const T& interpolator)
201 : HazardRateStructure(settlementDays, calendar, dayCounter, jumps, jumpDates),
202 InterpolatedCurve<
T>(interpolator) {}
206 const std::vector<Date>& dates,
207 const std::vector<Rate>& hazardRates,
208 const DayCounter& dayCounter,
209 const Calendar& calendar,
210 const std::vector<Handle<Quote> >& jumps,
211 const std::vector<Date>& jumpDates,
212 const T& interpolator)
213 : HazardRateStructure(dates.at(0), calendar, dayCounter, jumps, jumpDates),
214 InterpolatedCurve<
T>(
std::vector<
Time>(), hazardRates, interpolator),
222 const std::vector<Date>& dates,
223 const std::vector<Rate>& hazardRates,
224 const DayCounter& dayCounter,
225 const Calendar& calendar,
226 const T& interpolator)
227 : HazardRateStructure(dates.at(0), calendar, dayCounter),
228 InterpolatedCurve<
T>(
std::vector<
Time>(), hazardRates, interpolator),
236 const std::vector<Date>& dates,
237 const std::vector<Rate>& hazardRates,
238 const DayCounter& dayCounter,
239 const T& interpolator)
240 : HazardRateStructure(dates.at(0), Calendar(), dayCounter),
241 InterpolatedCurve<
T>(
std::vector<
Time>(), hazardRates, interpolator),
252 QL_REQUIRE(dates_.size() >= T::requiredPoints,
253 "not enough input dates given");
254 QL_REQUIRE(this->data_.size() == dates_.size(),
255 "dates/data count mismatch");
257 for (
Size i=0; i<dates_.size(); ++i) {
258 QL_REQUIRE(this->data_[i] >= 0.0,
"negative hazard rate");
261 this->setupTimes(dates_, dates_[0], dayCounter());
262 this->setupInterpolation();
263 this->interpolation_.update();
const std::vector< Date > & jumpDates() const
Shared handle to an observable.
Hazard-rate term structure.
Helper class to build interpolated term structures.
DefaultProbabilityTermStructure based on interpolation of hazard rates.
InterpolatedHazardRateCurve(const DayCounter &, const std::vector< Handle< Quote > > &jumps={}, const std::vector< Date > &jumpDates={}, const Interpolator &interpolator={})
Real hazardRateImpl(Time) const override
hazard rate calculation
InterpolatedHazardRateCurve(const Date &referenceDate, const DayCounter &, const std::vector< Handle< Quote > > &jumps={}, const std::vector< Date > &jumpDates={}, const Interpolator &interpolator={})
std::vector< Date > dates_
const std::vector< Date > & dates() const
const std::vector< Real > & data() const
InterpolatedHazardRateCurve(const std::vector< Date > &dates, const std::vector< Rate > &hazardRates, const DayCounter &dayCounter, const Interpolator &interpolator)
std::vector< std::pair< Date, Real > > nodes() const
const std::vector< Time > & times() const
Probability survivalProbabilityImpl(Time) const override
InterpolatedHazardRateCurve(const std::vector< Date > &dates, const std::vector< Rate > &hazardRates, const DayCounter &dayCounter, const Calendar &cal=Calendar(), const std::vector< Handle< Quote > > &jumps={}, const std::vector< Date > &jumpDates={}, const Interpolator &interpolator={})
Date maxDate() const override
the latest date for which the curve can return values
const std::vector< Rate > & hazardRates() const
InterpolatedHazardRateCurve(Natural settlementDays, const Calendar &, const DayCounter &, const std::vector< Handle< Quote > > &jumps={}, const std::vector< Date > &jumpDates={}, const Interpolator &interpolator={})
InterpolatedHazardRateCurve(const std::vector< Date > &dates, const std::vector< Rate > &hazardRates, const DayCounter &dayCounter, const Calendar &calendar, const Interpolator &interpolator)
virtual Natural settlementDays() const
the settlementDays used for reference date calculation
virtual const Date & referenceDate() const
the date at which discount = 1.0 and/or variance = 0.0
virtual Calendar calendar() const
the calendar used for reference and/or option date calculation
virtual DayCounter dayCounter() const
the day counter used for date/time conversion
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Real Time
continuous quantity with 1-year units
unsigned QL_INTEGER Natural
positive integer
Real Probability
probability
std::size_t Size
size of a container
hazard-rate term structure
Helper class to build interpolated term structures.