Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
InterpolatedHazardRateCurve< Interpolator > Class Template Reference

DefaultProbabilityTermStructure based on interpolation of hazard rates. More...

#include <qle/termstructures/interpolatedhazardratecurve.hpp>

+ Inheritance diagram for InterpolatedHazardRateCurve< Interpolator >:
+ Collaboration diagram for InterpolatedHazardRateCurve< Interpolator >:

Public Member Functions

 InterpolatedHazardRateCurve (const std::vector< Date > &dates, const std::vector< Rate > &hazardRates, const DayCounter &dayCounter, const Calendar &cal=Calendar(), const std::vector< Handle< Quote > > &jumps=std::vector< Handle< Quote > >(), const std::vector< Date > &jumpDates=std::vector< Date >(), const Interpolator &interpolator=Interpolator(), const bool allowNegativeRates=false)
 
 InterpolatedHazardRateCurve (const std::vector< Date > &dates, const std::vector< Rate > &hazardRates, const DayCounter &dayCounter, const Calendar &calendar, const Interpolator &interpolator, const bool allowNegativeRates=false)
 
 InterpolatedHazardRateCurve (const std::vector< Date > &dates, const std::vector< Rate > &hazardRates, const DayCounter &dayCounter, const Interpolator &interpolator, const bool allowNegativeRates=false)
 
TermStructure interface
Date maxDate () const override
 

DefaultProbabilityTermStructure implementation

std::vector< Date > dates_
 
bool allowNegativeRates_
 
Real hazardRateImpl (Time) const override
 
Probability survivalProbabilityImpl (Time) const override
 
void initialize ()
 

other inspectors

const std::vector< Time > & times () const
 
const std::vector< Date > & dates () const
 
const std::vector< Real > & data () const
 
const std::vector< Rate > & hazardRates () const
 
std::vector< std::pair< Date, Real > > nodes () const
 
 InterpolatedHazardRateCurve (const DayCounter &, const std::vector< Handle< Quote > > &jumps=std::vector< Handle< Quote > >(), const std::vector< Date > &jumpDates=std::vector< Date >(), const Interpolator &interpolator=Interpolator(), const bool allowNegativeRates=false)
 
 InterpolatedHazardRateCurve (const Date &referenceDate, const DayCounter &, const std::vector< Handle< Quote > > &jumps=std::vector< Handle< Quote > >(), const std::vector< Date > &jumpDates=std::vector< Date >(), const Interpolator &interpolator=Interpolator(), const bool allowNegativeRates=false)
 
 InterpolatedHazardRateCurve (Natural settlementDays, const Calendar &, const DayCounter &, const std::vector< Handle< Quote > > &jumps=std::vector< Handle< Quote > >(), const std::vector< Date > &jumpDates=std::vector< Date >(), const Interpolator &interpolator=Interpolator(), const bool allowNegativeRates=false)
 

Detailed Description

template<class Interpolator>
class QuantExt::InterpolatedHazardRateCurve< Interpolator >

DefaultProbabilityTermStructure based on interpolation of hazard rates.

This is an exact copy of the QuantLib class, but with the option to disabled the check for non negative input hazard rates

Definition at line 60 of file interpolatedhazardratecurve.hpp.

Constructor & Destructor Documentation

◆ InterpolatedHazardRateCurve() [1/6]

InterpolatedHazardRateCurve ( const std::vector< Date > &  dates,
const std::vector< Rate > &  hazardRates,
const DayCounter &  dayCounter,
const Calendar &  cal = Calendar(),
const std::vector< Handle< Quote > > &  jumps = std::vector< Handle< Quote > >(),
const std::vector< Date > &  jumpDates = std::vector< Date >(),
const Interpolator &  interpolator = Interpolator(),
const bool  allowNegativeRates = false 
)

◆ InterpolatedHazardRateCurve() [2/6]

InterpolatedHazardRateCurve ( const std::vector< Date > &  dates,
const std::vector< Rate > &  hazardRates,
const DayCounter &  dayCounter,
const Calendar &  calendar,
const Interpolator &  interpolator,
const bool  allowNegativeRates = false 
)

◆ InterpolatedHazardRateCurve() [3/6]

InterpolatedHazardRateCurve ( const std::vector< Date > &  dates,
const std::vector< Rate > &  hazardRates,
const DayCounter &  dayCounter,
const Interpolator &  interpolator,
const bool  allowNegativeRates = false 
)

◆ InterpolatedHazardRateCurve() [4/6]

InterpolatedHazardRateCurve ( const DayCounter &  ,
const std::vector< Handle< Quote > > &  jumps = std::vector< Handle< Quote > >(),
const std::vector< Date > &  jumpDates = std::vector< Date >(),
const Interpolator &  interpolator = Interpolator(),
const bool  allowNegativeRates = false 
)
protected

◆ InterpolatedHazardRateCurve() [5/6]

InterpolatedHazardRateCurve ( const Date &  referenceDate,
const DayCounter &  ,
const std::vector< Handle< Quote > > &  jumps = std::vector< Handle< Quote > >(),
const std::vector< Date > &  jumpDates = std::vector< Date >(),
const Interpolator &  interpolator = Interpolator(),
const bool  allowNegativeRates = false 
)
protected

◆ InterpolatedHazardRateCurve() [6/6]

InterpolatedHazardRateCurve ( Natural  settlementDays,
const Calendar &  ,
const DayCounter &  ,
const std::vector< Handle< Quote > > &  jumps = std::vector< Handle< Quote > >(),
const std::vector< Date > &  jumpDates = std::vector< Date >(),
const Interpolator &  interpolator = Interpolator(),
const bool  allowNegativeRates = false 
)
protected

Member Function Documentation

◆ maxDate()

Date maxDate
override

Definition at line 136 of file interpolatedhazardratecurve.hpp.

136 {
137 return dates_.back();
138 }

◆ times()

const std::vector< Time > & times

Definition at line 142 of file interpolatedhazardratecurve.hpp.

142 {
143 return this->times_;
144 }

◆ dates()

const std::vector< Date > & dates

Definition at line 148 of file interpolatedhazardratecurve.hpp.

148 {
149 return dates_;
150 }

◆ data()

const std::vector< Real > & data

Definition at line 154 of file interpolatedhazardratecurve.hpp.

154 {
155 return this->data_;
156 }

◆ hazardRates()

const std::vector< Rate > & hazardRates

Definition at line 160 of file interpolatedhazardratecurve.hpp.

160 {
161 return this->data_;
162 }

◆ nodes()

std::vector< std::pair< Date, Real > > nodes

Definition at line 166 of file interpolatedhazardratecurve.hpp.

166 {
167 std::vector<std::pair<Date, Real> > results(dates_.size());
168 for (Size i=0; i<dates_.size(); ++i)
169 results[i] = std::make_pair(dates_[i], this->data_[i]);
170 return results;
171 }

◆ hazardRateImpl()

Real hazardRateImpl ( Time  ) const
overrideprotected

◆ survivalProbabilityImpl()

Probability survivalProbabilityImpl ( Time  ) const
overrideprotected

◆ initialize()

void initialize
private

Definition at line 285 of file interpolatedhazardratecurve.hpp.

286 {
287 QL_REQUIRE(dates_.size() >= T::requiredPoints,
288 "not enough input dates given");
289 QL_REQUIRE(this->data_.size() == dates_.size(),
290 "dates/data count mismatch");
291
292 this->times_.resize(dates_.size());
293 this->times_[0] = 0.0;
294 for (Size i=1; i<dates_.size(); ++i) {
295 QL_REQUIRE(dates_[i] > dates_[i-1],
296 "invalid date (" << dates_[i] << ", vs "
297 << dates_[i-1] << ")");
298 this->times_[i] = dayCounter().yearFraction(dates_[0], dates_[i]);
299 QL_REQUIRE(!close(this->times_[i], this->times_[i-1]),
300 "two dates correspond to the same time "
301 "under this curve's day count convention");
302 QL_REQUIRE(allowNegativeRates_ || this->data_[i] >= 0.0, "negative hazard rate");
303 }
304
305 this->interpolation_ =
306 this->interpolator_.interpolate(this->times_.begin(),
307 this->times_.end(),
308 this->data_.begin());
309 this->interpolation_.update();
310 }

Member Data Documentation

◆ dates_

std::vector<Date> dates_
mutableprotected

Definition at line 126 of file interpolatedhazardratecurve.hpp.

◆ allowNegativeRates_

bool allowNegativeRates_
private

Definition at line 129 of file interpolatedhazardratecurve.hpp.