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

Sub-periods coupon. More...

#include <qle/cashflows/subperiodscoupon.hpp>

+ Inheritance diagram for SubPeriodsCoupon1:
+ Collaboration diagram for SubPeriodsCoupon1:

Public Types

enum  Type { Averaging , Compounding }
 

Public Member Functions

 SubPeriodsCoupon1 (const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, const QuantLib::ext::shared_ptr< InterestRateIndex > &index, Type type, BusinessDayConvention convention, Spread spread=0.0, const DayCounter &dayCounter=DayCounter(), bool includeSpread=false, Real gearing=1.0)
 
Inspectors
const std::vector< Date > & fixingDates () const
 fixing dates for the sub-periods More...
 
const std::vector< Time > & accrualFractions () const
 accrual periods for the sub-periods More...
 
const std::vector< Rate > & indexFixings () const
 fixings for the sub-periods More...
 
const std::vector< Date > & valueDates () const
 value dates for the sub-periods More...
 
Type type () const
 whether sub-period fixings are averaged or compounded More...
 
bool includeSpread () const
 whether to include/exclude spread in compounding/averaging More...
 
Spread spread () const
 Need to be able to change spread to solve for fair spread. More...
 
Spread & spread ()
 
FloatingRateCoupon interface
Date fixingDate () const override
 the date when the coupon is fully determined More...
 

Visitability

Type type_
 
bool includeSpread_
 
std::vector< Date > valueDates_
 
std::vector< Date > fixingDates_
 
std::vector< Rate > fixings_
 
Size numPeriods_
 
std::vector< Time > accrualFractions_
 
void accept (AcyclicVisitor &) override
 

Detailed Description

Sub-periods coupon.

The coupon period tenor is a multiple of the tenor associated with the index. The index tenor divides the coupon period into sub-periods. The index fixing for each sub-period is compounded or averaged over the full coupon period.

\ingroup cashflows
\todo merge into QuantLib

Definition at line 46 of file subperiodscoupon.hpp.

Member Enumeration Documentation

◆ Type

enum Type
Enumerator
Averaging 
Compounding 

Definition at line 48 of file subperiodscoupon.hpp.

Constructor & Destructor Documentation

◆ SubPeriodsCoupon1()

SubPeriodsCoupon1 ( const Date &  paymentDate,
Real  nominal,
const Date &  startDate,
const Date &  endDate,
const QuantLib::ext::shared_ptr< InterestRateIndex > &  index,
Type  type,
BusinessDayConvention  convention,
Spread  spread = 0.0,
const DayCounter &  dayCounter = DayCounter(),
bool  includeSpread = false,
Real  gearing = 1.0 
)

Definition at line 31 of file subperiodscoupon.cpp.

35 : FloatingRateCoupon(paymentDate, nominal, startDate, endDate, index->fixingDays(), index, gearing, spread, Date(),
36 Date(), dayCounter, false),
38
39 // Populate the value dates.
40 Schedule sch = MakeSchedule()
41 .from(startDate)
42 .to(endDate)
43 .withTenor(index->tenor())
44 .withCalendar(index->fixingCalendar())
45 .withConvention(convention)
46 .withTerminationDateConvention(convention)
47 .backwards();
48 valueDates_ = sch.dates();
49 QL_ENSURE(valueDates_.size() >= 2, "Degenerate schedule.");
50
51 // Populate the fixing dates.
52 numPeriods_ = valueDates_.size() - 1;
53 if (index->fixingDays() == 0) {
54 fixingDates_ = std::vector<Date>(valueDates_.begin(), valueDates_.end() - 1);
55 } else {
57 for (Size i = 0; i < numPeriods_; ++i)
58 fixingDates_[i] = index->fixingDate(valueDates_[i]);
59 }
60
61 // Populate the accrual periods.
63 for (Size i = 0; i < numPeriods_; ++i) {
64 accrualFractions_[i] = dayCounter.yearFraction(valueDates_[i], valueDates_[i + 1]);
65 }
66}
bool includeSpread() const
whether to include/exclude spread in compounding/averaging
std::vector< Date > fixingDates_
std::vector< Time > accrualFractions_
std::vector< Date > valueDates_
Type type() const
whether sub-period fixings are averaged or compounded
Spread spread() const
Need to be able to change spread to solve for fair spread.

Member Function Documentation

◆ fixingDates()

const std::vector< Date > & fixingDates ( ) const

fixing dates for the sub-periods

Definition at line 56 of file subperiodscoupon.hpp.

56{ return fixingDates_; }

◆ accrualFractions()

const std::vector< Time > & accrualFractions ( ) const

accrual periods for the sub-periods

Definition at line 58 of file subperiodscoupon.hpp.

58{ return accrualFractions_; }
+ Here is the caller graph for this function:

◆ indexFixings()

const std::vector< Rate > & indexFixings ( ) const

fixings for the sub-periods

Definition at line 68 of file subperiodscoupon.cpp.

68 {
69
70 fixings_.resize(numPeriods_);
71
72 for (Size i = 0; i < numPeriods_; ++i) {
73 fixings_[i] = index_->fixing(fixingDates_[i]);
74 }
75
76 return fixings_;
77}
std::vector< Rate > fixings_
+ Here is the caller graph for this function:

◆ valueDates()

const std::vector< Date > & valueDates ( ) const

value dates for the sub-periods

Definition at line 62 of file subperiodscoupon.hpp.

62{ return valueDates_; }

◆ type()

Type type ( ) const

whether sub-period fixings are averaged or compounded

Definition at line 64 of file subperiodscoupon.hpp.

64{ return type_; }
+ Here is the caller graph for this function:

◆ includeSpread()

bool includeSpread ( ) const

whether to include/exclude spread in compounding/averaging

Definition at line 66 of file subperiodscoupon.hpp.

66{ return includeSpread_; }
+ Here is the caller graph for this function:

◆ spread() [1/2]

Spread spread ( ) const

Need to be able to change spread to solve for fair spread.

Definition at line 68 of file subperiodscoupon.hpp.

68{ return spread_; }
SimpleQuote & spread_
+ Here is the caller graph for this function:

◆ spread() [2/2]

Spread & spread ( )

Definition at line 69 of file subperiodscoupon.hpp.

69{ return spread_; }

◆ fixingDate()

Date fixingDate ( ) const
override

the date when the coupon is fully determined

Definition at line 74 of file subperiodscoupon.hpp.

74{ return fixingDates_.back(); }

◆ accept()

void accept ( AcyclicVisitor &  v)
override

Definition at line 79 of file subperiodscoupon.cpp.

79 {
80 Visitor<SubPeriodsCoupon1>* v1 = dynamic_cast<Visitor<SubPeriodsCoupon1>*>(&v);
81 if (v1 != 0) {
82 v1->visit(*this);
83 } else {
84 FloatingRateCoupon::accept(v);
85 }
86}

Member Data Documentation

◆ type_

Type type_
private

Definition at line 81 of file subperiodscoupon.hpp.

◆ includeSpread_

bool includeSpread_
private

Definition at line 82 of file subperiodscoupon.hpp.

◆ valueDates_

std::vector<Date> valueDates_
private

Definition at line 83 of file subperiodscoupon.hpp.

◆ fixingDates_

std::vector<Date> fixingDates_
private

Definition at line 83 of file subperiodscoupon.hpp.

◆ fixings_

std::vector<Rate> fixings_
mutableprivate

Definition at line 84 of file subperiodscoupon.hpp.

◆ numPeriods_

Size numPeriods_
private

Definition at line 85 of file subperiodscoupon.hpp.

◆ accrualFractions_

std::vector<Time> accrualFractions_
private

Definition at line 86 of file subperiodscoupon.hpp.