Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
BondYieldShiftedCurveTermStructure Class Reference

#include <qle/termstructures/bondyieldshiftedcurvetermstructure.hpp>

+ Inheritance diagram for BondYieldShiftedCurveTermStructure:
+ Collaboration diagram for BondYieldShiftedCurveTermStructure:

Public Member Functions

 BondYieldShiftedCurveTermStructure (const QuantLib::Handle< YieldTermStructure > &originalCurve, const Real &bondSpread, const Real &duration)
 
 BondYieldShiftedCurveTermStructure (const QuantLib::Handle< YieldTermStructure > &originalCurve, const std::vector< Real > &bondYields, const std::vector< Real > &bondDurations)
 

BondYieldShiftedCurveTermStructure interface

Handle< YieldTermStructure > originalCurve_
 
Real bondSpread_
 
Real duration_
 
DayCounter dayCounter () const override
 
Calendar calendar () const override
 
Natural settlementDays () const override
 
const Date & referenceDate () const override
 
Date maxDate () const override
 
Real bondSpread () const
 
Real duration () const
 
DiscountFactor discountImpl (Time) const override
 

Detailed Description

The given date will be the implied reference date.

Note
This term structure will be linked to the original curve and the bond spread, i.e., any changes in the latter will be reflected in this structure as well.

Definition at line 40 of file bondyieldshiftedcurvetermstructure.hpp.

Constructor & Destructor Documentation

◆ BondYieldShiftedCurveTermStructure() [1/2]

BondYieldShiftedCurveTermStructure ( const QuantLib::Handle< YieldTermStructure > &  originalCurve,
const Real &  bondSpread,
const Real &  duration 
)

◆ BondYieldShiftedCurveTermStructure() [2/2]

BondYieldShiftedCurveTermStructure ( const QuantLib::Handle< YieldTermStructure > &  originalCurve,
const std::vector< Real > &  bondYields,
const std::vector< Real > &  bondDurations 
)

Definition at line 49 of file bondyieldshiftedcurvetermstructure.hpp.

53 : YieldTermStructure(originalCurve->dayCounter()), originalCurve_(originalCurve) {
54 registerWith(originalCurve);
55
56 QL_REQUIRE(bondYields.size() == bondDurations.size(),
57 "BondYieldShiftedCurveTermStructure: inconsistent lengths of yield and duration vectors ("
58 << bondYields.size() << " vs. " << bondDurations.size() << ")");
59
60 QL_REQUIRE(bondYields.size() > 0, "at least one bondYield for shifting of the reference curve required.");
61
62 accumulator_set<Real, stats<tag::mean>> spreadMean, durationMean;
63
64 for (Size i = 0; i < bondYields.size(); ++i) {
65 //estimate spread at duration
66 Real thisCrvRate = -std::log(originalCurve_->discount(static_cast<Real>(bondDurations[i])))/bondDurations[i];
67 Real thisSpread = static_cast<Real>(bondYields[i]) - thisCrvRate;
68
69 spreadMean(thisSpread);
70 durationMean(bondDurations[i]);
71 }
72
73 bondSpread_ = mean(spreadMean);
74 duration_ = mean(durationMean);
75 }

Member Function Documentation

◆ dayCounter()

DayCounter dayCounter ( ) const
override

Definition at line 98 of file bondyieldshiftedcurvetermstructure.hpp.

98{ return originalCurve_->dayCounter(); }

◆ calendar()

Calendar calendar ( ) const
override

Definition at line 100 of file bondyieldshiftedcurvetermstructure.hpp.

100{ return originalCurve_->calendar(); }

◆ settlementDays()

Natural settlementDays ( ) const
override

Definition at line 102 of file bondyieldshiftedcurvetermstructure.hpp.

102{ return originalCurve_->settlementDays(); }

◆ referenceDate()

const Date & referenceDate ( ) const
override

Definition at line 110 of file bondyieldshiftedcurvetermstructure.hpp.

110 {
111 return originalCurve_->referenceDate();
112}

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 104 of file bondyieldshiftedcurvetermstructure.hpp.

104{ return originalCurve_->maxDate(); }

◆ bondSpread()

Real bondSpread ( ) const

Definition at line 106 of file bondyieldshiftedcurvetermstructure.hpp.

106{ return bondSpread_; }

◆ duration()

Real duration ( ) const

Definition at line 108 of file bondyieldshiftedcurvetermstructure.hpp.

108{ return duration_; }

◆ discountImpl()

DiscountFactor discountImpl ( Time  t) const
overrideprotected

Definition at line 114 of file bondyieldshiftedcurvetermstructure.hpp.

114 {
115
116 if ((duration_ != Null<Real>()) && (bondSpread_ != Null<Real>())) {
117
118 Real df = originalCurve_->discount(t) * std::exp(-t * bondSpread_);
119
120 return df;
121
122 } else {
123 return originalCurve_->discount(t);
124 }
125
126 }

Member Data Documentation

◆ originalCurve_

Handle<YieldTermStructure> originalCurve_
private

Definition at line 91 of file bondyieldshiftedcurvetermstructure.hpp.

◆ bondSpread_

Real bondSpread_
private

Definition at line 92 of file bondyieldshiftedcurvetermstructure.hpp.

◆ duration_

Real duration_
private

Definition at line 93 of file bondyieldshiftedcurvetermstructure.hpp.