Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
List of all members
SubPeriodsSwap Class Reference

Single currency sub periods swap. More...

#include <qle/instruments/subperiodsswap.hpp>

+ Inheritance diagram for SubPeriodsSwap:
+ Collaboration diagram for SubPeriodsSwap:

Public Member Functions

Constructors
 SubPeriodsSwap (const Date &effectiveDate, Real nominal, const Period &swapTenor, bool isPayer, const Period &fixedTenor, Rate fixedRate, const Calendar &fixedCalendar, const DayCounter &fixedDayCount, BusinessDayConvention fixedConvention, const Period &floatPayTenor, const QuantLib::ext::shared_ptr< IborIndex > &iborIndex, const DayCounter &floatingDayCount, DateGeneration::Rule rule=DateGeneration::Backward, QuantExt::SubPeriodsCoupon1::Type type=QuantExt::SubPeriodsCoupon1::Compounding)
 Constructor with conventions deduced from the index. More...
 
Inspectors
Real nominal () const
 
bool isPayer () const
 
const Schedule & fixedSchedule () const
 
Rate fixedRate () const
 
const Leg & fixedLeg () const
 
const Schedule & floatSchedule () const
 
const QuantLib::ext::shared_ptr< IborIndex > & floatIndex () const
 
QuantExt::SubPeriodsCoupon1::Type type () const
 
const Period & floatPayTenor () const
 
const Leg & floatLeg () const
 

Results

Real nominal_
 
bool isPayer_
 
Schedule fixedSchedule_
 
Rate fixedRate_
 
DayCounter fixedDayCount_
 
Schedule floatSchedule_
 
QuantLib::ext::shared_ptr< IborIndex > floatIndex_
 
DayCounter floatDayCount_
 
Period floatPayTenor_
 
QuantExt::SubPeriodsCoupon1::Type type_
 
Real fairRate () const
 
Real fixedLegBPS () const
 
Real fixedLegNPV () const
 
Real floatLegBPS () const
 
Real floatLegNPV () const
 

Detailed Description

Single currency sub periods swap.

Definition at line 38 of file subperiodsswap.hpp.

Constructor & Destructor Documentation

◆ SubPeriodsSwap()

SubPeriodsSwap ( const Date &  effectiveDate,
Real  nominal,
const Period &  swapTenor,
bool  isPayer,
const Period &  fixedTenor,
Rate  fixedRate,
const Calendar &  fixedCalendar,
const DayCounter &  fixedDayCount,
BusinessDayConvention  fixedConvention,
const Period &  floatPayTenor,
const QuantLib::ext::shared_ptr< IborIndex > &  iborIndex,
const DayCounter &  floatingDayCount,
DateGeneration::Rule  rule = DateGeneration::Backward,
QuantExt::SubPeriodsCoupon1::Type  type = QuantExt::SubPeriodsCoupon1::Compounding 
)

Constructor with conventions deduced from the index.

Definition at line 36 of file subperiodsswap.cpp.

44 floatIndex_(iborIndex), floatDayCount_(floatingDayCount), floatPayTenor_(floatPayTenor), type_(type) {
45
46 Date terminationDate = effectiveDate + swapTenor;
47
48 // Fixed leg
49 fixedSchedule_ = MakeSchedule()
50 .from(effectiveDate)
51 .to(terminationDate)
52 .withTenor(fixedTenor)
53 .withCalendar(fixedCalendar)
54 .withConvention(fixedConvention)
55 .withTerminationDateConvention(fixedConvention)
56 .withRule(rule);
57
58 legs_[0] = FixedRateLeg(fixedSchedule_)
59 .withNotionals(nominal_)
60 .withCouponRates(fixedRate_, fixedDayCount_)
61 .withPaymentAdjustment(fixedConvention);
62
63 // Sub Periods Leg, schedule is the PAY schedule
64 BusinessDayConvention floatPmtConvention = iborIndex->businessDayConvention();
65 Calendar floatPmtCalendar = iborIndex->fixingCalendar();
66 floatSchedule_ = MakeSchedule()
67 .from(effectiveDate)
68 .to(terminationDate)
69 .withTenor(floatPayTenor)
70 .withCalendar(floatPmtCalendar)
71 .withConvention(floatPmtConvention)
72 .withTerminationDateConvention(floatPmtConvention)
73 .withRule(rule);
74
75 legs_[1] = SubPeriodsLeg1(floatSchedule_, floatIndex_)
76 .withNotional(nominal_)
77 .withPaymentAdjustment(floatPmtConvention)
78 .withPaymentDayCounter(floatDayCount_)
79 .withPaymentCalendar(floatPmtCalendar)
80 .includeSpread(false)
81 .withType(type_);
82
83 // legs_[0] is fixed
84 payer_[0] = isPayer_ ? -1.0 : +1.0;
85 payer_[1] = isPayer_ ? +1.0 : -1.0;
86
87 // Register this instrument with its coupons
88 Leg::const_iterator it;
89 for (it = legs_[0].begin(); it != legs_[0].end(); ++it)
90 registerWith(*it);
91 for (it = legs_[1].begin(); it != legs_[1].end(); ++it)
92 registerWith(*it);
93}
QuantLib::ext::shared_ptr< IborIndex > floatIndex_
const Period & floatPayTenor() const
QuantExt::SubPeriodsCoupon1::Type type() const
QuantExt::SubPeriodsCoupon1::Type type_
+ Here is the call graph for this function:

Member Function Documentation

◆ nominal()

Real nominal ( ) const

Definition at line 91 of file subperiodsswap.hpp.

91{ return nominal_; }

◆ isPayer()

bool isPayer ( ) const

Definition at line 93 of file subperiodsswap.hpp.

93{ return isPayer_; }

◆ fixedSchedule()

const Schedule & fixedSchedule ( ) const

Definition at line 95 of file subperiodsswap.hpp.

95{ return fixedSchedule_; }

◆ fixedRate()

Rate fixedRate ( ) const

Definition at line 97 of file subperiodsswap.hpp.

97{ return fixedRate_; }

◆ fixedLeg()

const Leg & fixedLeg ( ) const

Definition at line 99 of file subperiodsswap.hpp.

99{ return legs_[0]; }

◆ floatSchedule()

const Schedule & floatSchedule ( ) const

Definition at line 105 of file subperiodsswap.hpp.

105{ return floatSchedule_; }

◆ floatIndex()

const QuantLib::ext::shared_ptr< IborIndex > & floatIndex ( ) const

Definition at line 107 of file subperiodsswap.hpp.

107{ return floatIndex_; }

◆ type()

Definition at line 109 of file subperiodsswap.hpp.

109{ return type_; }

◆ floatPayTenor()

const Period & floatPayTenor ( ) const

Definition at line 111 of file subperiodsswap.hpp.

111{ return floatPayTenor_; }
+ Here is the caller graph for this function:

◆ floatLeg()

const Leg & floatLeg ( ) const

Definition at line 113 of file subperiodsswap.hpp.

113{ return legs_[1]; }

◆ fairRate()

Real fairRate ( ) const

Definition at line 95 of file subperiodsswap.cpp.

95 {
96 static const Spread basisPoint = 1.0e-4;
97 calculate();
98 QL_REQUIRE(legBPS_[0] != Null<Real>(), "result not available");
99 return fixedRate_ - NPV_ / (legBPS_[0] / basisPoint);
100}

◆ fixedLegBPS()

Rate fixedLegBPS ( ) const

Definition at line 101 of file subperiodsswap.hpp.

101{ return legBPS(0); }

◆ fixedLegNPV()

Rate fixedLegNPV ( ) const

Definition at line 103 of file subperiodsswap.hpp.

103{ return legNPV(0); }

◆ floatLegBPS()

Rate floatLegBPS ( ) const

Definition at line 115 of file subperiodsswap.hpp.

115{ return legBPS(1); }

◆ floatLegNPV()

Rate floatLegNPV ( ) const

Definition at line 117 of file subperiodsswap.hpp.

117{ return legNPV(1); }

Member Data Documentation

◆ nominal_

Real nominal_
private

Definition at line 76 of file subperiodsswap.hpp.

◆ isPayer_

bool isPayer_
private

Definition at line 77 of file subperiodsswap.hpp.

◆ fixedSchedule_

Schedule fixedSchedule_
private

Definition at line 79 of file subperiodsswap.hpp.

◆ fixedRate_

Rate fixedRate_
private

Definition at line 80 of file subperiodsswap.hpp.

◆ fixedDayCount_

DayCounter fixedDayCount_
private

Definition at line 81 of file subperiodsswap.hpp.

◆ floatSchedule_

Schedule floatSchedule_
private

Definition at line 83 of file subperiodsswap.hpp.

◆ floatIndex_

QuantLib::ext::shared_ptr<IborIndex> floatIndex_
private

Definition at line 84 of file subperiodsswap.hpp.

◆ floatDayCount_

DayCounter floatDayCount_
private

Definition at line 85 of file subperiodsswap.hpp.

◆ floatPayTenor_

Period floatPayTenor_
private

Definition at line 86 of file subperiodsswap.hpp.

◆ type_

Definition at line 87 of file subperiodsswap.hpp.