26#ifndef quantlib_zero_curve_simple_hpp
27#define quantlib_zero_curve_simple_hpp
40template <
class Interpolator>
48 const Interpolator &interpolator = {});
51 const Interpolator &interpolator);
60 const std::vector<Time> &
times()
const;
61 const std::vector<Date> &
dates()
const;
62 const std::vector<Real> &
data()
const;
63 const std::vector<Rate> &
zeroRates()
const;
64 std::vector<std::pair<Date, Real> >
nodes()
const;
68 const Interpolator &interpolator = {});
72 const Interpolator &interpolator = {});
76 const Interpolator &interpolator = {});
106 std::vector<std::pair<Date, Real> >
results(dates_.size());
107 for (
Size i = 0; i < dates_.size(); ++i)
108 results[i] = std::make_pair(dates_[i], this->data_[i]);
118 if (t <= this->times_.back()) {
119 R = this->interpolation_(
t,
true);
123 Time tMax = this->times_.back();
124 Rate zMax = this->data_.back();
125 Rate instFwdMax = zMax + tMax * this->interpolation_.derivative(tMax);
126 R = (zMax * tMax + instFwdMax * (
t - tMax)) /
t;
134 : YieldTermStructure(dayCounter), InterpolatedCurve<
T>(interpolator) {}
138 const std::vector<Handle<Quote> > &jumps,
139 const std::vector<Date> &jumpDates,
const T &interpolator)
140 : YieldTermStructure(referenceDate, Calendar(), dayCounter, jumps, jumpDates), InterpolatedCurve<
T>(interpolator) {}
144 const DayCounter &dayCounter,
145 const std::vector<Handle<Quote> > &jumps,
146 const std::vector<Date> &jumpDates,
const T &interpolator)
147 : YieldTermStructure(settlementDays, calendar, dayCounter, jumps, jumpDates), InterpolatedCurve<
T>(interpolator) {}
151 const std::vector<Rate> &yields,
152 const DayCounter &dayCounter,
const Calendar &calendar,
153 const std::vector<Handle<Quote> > &jumps,
154 const std::vector<Date> &jumpDates,
const T &interpolator)
155 : YieldTermStructure(dates.at(0), calendar, dayCounter, jumps, jumpDates),
156 InterpolatedCurve<
T>(
std::vector<
Time>(), yields, interpolator), dates_(dates) {
162 const std::vector<Rate> &yields,
163 const DayCounter &dayCounter,
const Calendar &calendar,
164 const T &interpolator)
165 : YieldTermStructure(dates.at(0), calendar, dayCounter), InterpolatedCurve<
T>(
std::vector<
Time>(), yields,
173 const std::vector<Rate> &yields,
174 const DayCounter &dayCounter,
const T &interpolator)
175 : YieldTermStructure(dates.at(0), Calendar(), dayCounter), InterpolatedCurve<
T>(
std::vector<
Time>(), yields,
184 QL_REQUIRE(dates_.size() >= T::requiredPoints,
185 "not enough input dates given");
186 QL_REQUIRE(this->data_.size() == dates_.size(),
187 "dates/data count mismatch");
189 this->setupTimes(dates_, dates_[0], dayCounter());
190 this->setupInterpolation();
191 this->interpolation_.update();
Shared handle to an observable.
Helper class to build interpolated term structures.
YieldTermStructure based on interpolation of zero rates.
DiscountFactor discountImpl(Time t) const override
discount factor calculation
std::vector< Date > dates_
const std::vector< Date > & dates() const
InterpolatedSimpleZeroCurve(Natural settlementDays, const Calendar &, const DayCounter &, const std::vector< Handle< Quote > > &jumps={}, const std::vector< Date > &jumpDates={}, const Interpolator &interpolator={})
const std::vector< Rate > & zeroRates() const
const std::vector< Real > & data() const
std::vector< std::pair< Date, Real > > nodes() const
InterpolatedSimpleZeroCurve(const std::vector< Date > &dates, const std::vector< Rate > &yields, const DayCounter &dayCounter, const Calendar &calendar, const Interpolator &interpolator)
const std::vector< Time > & times() const
Date maxDate() const override
the latest date for which the curve can return values
InterpolatedSimpleZeroCurve(const DayCounter &, const Interpolator &interpolator={})
InterpolatedSimpleZeroCurve(const Date &referenceDate, const DayCounter &, const std::vector< Handle< Quote > > &jumps={}, const std::vector< Date > &jumpDates={}, const Interpolator &interpolator={})
InterpolatedSimpleZeroCurve(const std::vector< Date > &dates, const std::vector< Rate > &yields, const DayCounter &dayCounter, const Calendar &calendar=Calendar(), const std::vector< Handle< Quote > > &jumps={}, const std::vector< Date > &jumpDates={}, const Interpolator &interpolator={})
InterpolatedSimpleZeroCurve(const std::vector< Date > &dates, const std::vector< Rate > &yields, const DayCounter &dayCounter, 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
Interest-rate term structure.
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
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
unsigned QL_INTEGER Natural
positive integer
std::size_t Size
size of a container
Helper class to build interpolated term structures.
linear interpolation between discrete points
Interest-rate term structure.