24#include <ql/termstructures/yieldtermstructure.hpp>
26#include <boost/accumulators/accumulators.hpp>
27#include <boost/accumulators/statistics/mean.hpp>
28#include <boost/accumulators/statistics/stats.hpp>
32using namespace boost::accumulators;
47 registerWith(originalCurve);
50 const std::vector<Real>& bondYields,
51 const std::vector<Real>& bondDurations
54 registerWith(originalCurve);
56 QL_REQUIRE(bondYields.size() == bondDurations.size(),
57 "BondYieldShiftedCurveTermStructure: inconsistent lengths of yield and duration vectors ("
58 << bondYields.size() <<
" vs. " << bondDurations.size() <<
")");
60 QL_REQUIRE(bondYields.size() > 0,
"at least one bondYield for shifting of the reference curve required.");
62 accumulator_set<Real, stats<tag::mean>> spreadMean, durationMean;
64 for (Size i = 0; i < bondYields.size(); ++i) {
66 Real thisCrvRate = -std::log(
originalCurve_->discount(
static_cast<Real
>(bondDurations[i])))/bondDurations[i];
67 Real thisSpread =
static_cast<Real
>(bondYields[i]) - thisCrvRate;
69 spreadMean(thisSpread);
70 durationMean(bondDurations[i]);
Calendar calendar() const override
BondYieldShiftedCurveTermStructure(const QuantLib::Handle< YieldTermStructure > &originalCurve, const std::vector< Real > &bondYields, const std::vector< Real > &bondDurations)
const Date & referenceDate() const override
BondYieldShiftedCurveTermStructure(const QuantLib::Handle< YieldTermStructure > &originalCurve, const Real &bondSpread, const Real &duration)
Handle< YieldTermStructure > originalCurve_
Natural settlementDays() const override
DayCounter dayCounter() const override
DiscountFactor discountImpl(Time) const override
Date maxDate() const override