26#ifndef quantlib_forward_curve_hpp
27#define quantlib_forward_curve_hpp
39 template <
class Interpolator>
45 const std::vector<Date>&
dates,
51 const Interpolator& interpolator = {});
53 const std::vector<Date>&
dates,
57 const Interpolator& interpolator);
59 const std::vector<Date>&
dates,
62 const Interpolator& interpolator);
69 const std::vector<Time>&
times()
const;
70 const std::vector<Date>&
dates()
const;
71 const std::vector<Real>&
data()
const;
72 const std::vector<Rate>&
forwards()
const;
73 std::vector<std::pair<Date, Real> >
nodes()
const;
79 const Interpolator& interpolator = {});
85 const Interpolator& interpolator = {});
92 const Interpolator& interpolator = {});
114 if (this->maxDate_ !=
Date())
115 return this->maxDate_;
116 return dates_.back();
120 inline const std::vector<Time>&
126 inline const std::vector<Date>&
132 inline const std::vector<Real>&
138 inline const std::vector<Rate>&
144 inline std::vector<std::pair<Date, Real> >
146 std::vector<std::pair<Date, Real> >
results(dates_.size());
147 for (
Size i=0; i<dates_.size(); ++i)
148 results[i] = std::make_pair(dates_[i], this->data_[i]);
158 if (t <= this->times_.back())
159 return this->interpolation_(
t,
true);
162 return this->data_.back();
168 return forwardImpl(0.0);
171 if (t <= this->times_.back()) {
172 integral = this->interpolation_.primitive(
t,
true);
175 integral = this->interpolation_.primitive(this->times_.back(),
true)
176 + this->data_.back()*(
t - this->times_.back());
183 const DayCounter& dayCounter,
184 const T& interpolator)
185 : ForwardRateStructure(dayCounter), InterpolatedCurve<
T>(interpolator) {}
189 const Date& referenceDate,
190 const DayCounter& dayCounter,
191 const std::vector<Handle<Quote> >& jumps,
192 const std::vector<Date>& jumpDates,
193 const T& interpolator)
194 : ForwardRateStructure(referenceDate, Calendar(), dayCounter, jumps, jumpDates),
195 InterpolatedCurve<
T>(interpolator) {}
200 const Calendar& calendar,
201 const DayCounter& dayCounter,
202 const std::vector<Handle<Quote> >& jumps,
203 const std::vector<Date>& jumpDates,
204 const T& interpolator)
205 : ForwardRateStructure(settlementDays, calendar, dayCounter, jumps, jumpDates),
206 InterpolatedCurve<
T>(interpolator) {}
210 const std::vector<Date>& dates,
211 const std::vector<Rate>& forwards,
212 const DayCounter& dayCounter,
213 const Calendar& calendar,
214 const std::vector<Handle<Quote> >& jumps,
215 const std::vector<Date>& jumpDates,
216 const T& interpolator)
217 : ForwardRateStructure(dates.at(0), calendar, dayCounter, jumps, jumpDates),
218 InterpolatedCurve<
T>(
std::vector<
Time>(), forwards, interpolator),
226 const std::vector<Date>& dates,
227 const std::vector<Rate>& forwards,
228 const DayCounter& dayCounter,
229 const Calendar& calendar,
230 const T& interpolator)
231 : ForwardRateStructure(dates.at(0), calendar, dayCounter),
232 InterpolatedCurve<
T>(
std::vector<
Time>(), forwards, interpolator),
240 const std::vector<Date>& dates,
241 const std::vector<Rate>& forwards,
242 const DayCounter& dayCounter,
243 const T& interpolator)
244 : ForwardRateStructure(dates.at(0), Calendar(), dayCounter),
245 InterpolatedCurve<
T>(
std::vector<
Time>(), forwards, interpolator),
256 QL_REQUIRE(dates_.size() >= T::requiredPoints,
257 "not enough input dates given");
258 QL_REQUIRE(this->data_.size() == dates_.size(),
259 "dates/data count mismatch");
261 this->setupTimes(dates_, dates_[0], dayCounter());
262 this->setupInterpolation();
263 this->interpolation_.update();
backward-flat interpolation between discrete points
Forward-rate term structure
Shared handle to an observable.
Helper class to build interpolated term structures.
YieldTermStructure based on interpolation of forward rates.
Rate zeroYieldImpl(Time t) const override
Rate forwardImpl(Time t) const override
instantaneous forward-rate calculation
InterpolatedForwardCurve(const std::vector< Date > &dates, const std::vector< Rate > &forwards, const DayCounter &dayCounter, const Calendar &cal=Calendar(), const std::vector< Handle< Quote > > &jumps={}, const std::vector< Date > &jumpDates={}, const Interpolator &interpolator={})
std::vector< Date > dates_
const std::vector< Rate > & forwards() const
const std::vector< Date > & dates() const
const std::vector< Real > & data() const
std::vector< std::pair< Date, Real > > nodes() const
InterpolatedForwardCurve(const std::vector< Date > &dates, const std::vector< Rate > &forwards, const DayCounter &dayCounter, const Interpolator &interpolator)
const std::vector< Time > & times() const
InterpolatedForwardCurve(const Date &referenceDate, const DayCounter &, 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
InterpolatedForwardCurve(const DayCounter &, const Interpolator &interpolator={})
InterpolatedForwardCurve(Natural settlementDays, const Calendar &, const DayCounter &, const std::vector< Handle< Quote > > &jumps={}, const std::vector< Date > &jumpDates={}, const Interpolator &interpolator={})
InterpolatedForwardCurve(const std::vector< Date > &dates, const std::vector< Rate > &forwards, 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
const std::vector< Date > & jumpDates() const
floating-point comparisons
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Forward-based yield term structure.
Real Time
continuous quantity with 1-year units
unsigned QL_INTEGER Natural
positive integer
std::size_t Size
size of a container
InterpolatedForwardCurve< BackwardFlat > ForwardCurve
Term structure based on flat interpolation of forward rates.
Helper class to build interpolated term structures.