26#ifndef quantlib_piecewise_zero_spreaded_term_structure_hpp
27#define quantlib_piecewise_zero_spreaded_term_structure_hpp
48 template <
class Interpolator>
53 const std::vector<Date>& dates,
57 const Interpolator& factory = Interpolator());
98 const std::vector<Date>& dates,
103 : originalCurve_(
std::move(h)), spreads_(
std::move(spreads)), dates_(dates),
104 times_(dates.size()), spreadValues_(dates.size()), comp_(comp), freq_(freq),
105 dc_(
std::move(dc)), factory_(factory) {
108 "spread and date vector have different sizes");
118 return originalCurve_->dayCounter();
123 return originalCurve_->calendar();
128 return originalCurve_->settlementDays();
134 return originalCurve_->referenceDate();
139 return std::min(originalCurve_->maxDate(), dates_.back());
146 InterestRate zeroRate = originalCurve_->zeroRate(
t, comp_, freq_,
true);
157 if (
t <= times_.front()) {
158 return spreads_.front()->value();
159 }
else if (
t >= times_.back()) {
160 return spreads_.back()->value();
162 return interpolator_(
t,
true);
168 if (!originalCurve_.empty()) {
169 updateInterpolation();
183 for (
Size i = 0; i < dates_.size(); i++) {
184 times_[i] = timeFromReference(dates_[i]);
185 spreadValues_[i] = spreads_[i]->value();
187 interpolator_ = factory_.interpolate(times_.begin(),
189 spreadValues_.begin());
Shared handle to an observable.
Concrete interest rate class.
const DayCounter & dayCounter() const
Compounding compounding() const
Frequency frequency() const
InterestRate equivalentRate(Compounding comp, Frequency freq, Time t) const
equivalent interest rate for a compounding period t.
Yield curve with an added vector of spreads on the zero-yield rate.
Calendar calendar() const override
the calendar used for reference and/or option date calculation
std::vector< Date > dates_
Rate zeroYieldImpl(Time) const override
returns the spreaded zero yield rate
const Date & referenceDate() const override
the date at which discount = 1.0 and/or variance = 0.0
std::vector< Time > times_
Handle< YieldTermStructure > originalCurve_
Natural settlementDays() const override
the settlementDays used for reference date calculation
Real calcSpread(Time t) const
DayCounter dayCounter() const override
the day counter used for date/time conversion
Date maxDate() const override
the latest date for which the curve can return values
std::vector< Spread > spreadValues_
void updateInterpolation()
std::vector< Handle< Quote > > spreads_
Interpolation interpolator_
base class for 1-D interpolations.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Zero-yield term structure.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Frequency
Frequency of events.
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
unsigned QL_INTEGER Natural
positive integer
Real Spread
spreads on interest rates
std::size_t Size
size of a container
InterpolatedPiecewiseZeroSpreadedTermStructure< Linear > PiecewiseZeroSpreadedTermStructure
Piecewise zero-spreaded yield curve based on linear interpolation of zero rates.
linear interpolation between discrete points
Compounding
Interest rate coumpounding rule.
purely virtual base class for market observables
Zero-yield based term structure.