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

Rate helper for bootstrapping using Sub Periods Swaps. More...

#include <qle/termstructures/subperiodsswaphelper.hpp>

+ Inheritance diagram for SubPeriodsSwapHelper:
+ Collaboration diagram for SubPeriodsSwapHelper:

Public Member Functions

 SubPeriodsSwapHelper (Handle< Quote > spread, const Period &swapTenor, const Period &fixedTenor, const Calendar &fixedCalendar, const DayCounter &fixedDayCount, BusinessDayConvention fixedConvention, const Period &floatPayTenor, const QuantLib::ext::shared_ptr< IborIndex > &iborIndex, const DayCounter &floatDayCount, const Handle< YieldTermStructure > &discountingCurve=Handle< YieldTermStructure >(), QuantExt::SubPeriodsCoupon1::Type type=QuantExt::SubPeriodsCoupon1::Compounding)
 
RateHelper interface
Real impliedQuote () const override
 
void setTermStructure (YieldTermStructure *) override
 
SubPeriodsSwapHelper inspectors
QuantLib::ext::shared_ptr< SubPeriodsSwapswap () const
 

Visitability

QuantLib::ext::shared_ptr< SubPeriodsSwapswap_
 
QuantLib::ext::shared_ptr< IborIndex > iborIndex_
 
Period swapTenor_
 
Period fixedTenor_
 
Calendar fixedCalendar_
 
DayCounter fixedDayCount_
 
BusinessDayConvention fixedConvention_
 
Period floatPayTenor_
 
DayCounter floatDayCount_
 
QuantExt::SubPeriodsCoupon1::Type type_
 
RelinkableHandle< YieldTermStructure > termStructureHandle_
 
Handle< YieldTermStructure > discountHandle_
 
RelinkableHandle< YieldTermStructure > discountRelinkableHandle_
 
void accept (AcyclicVisitor &) override
 
void initializeDates () override
 

Detailed Description

Rate helper for bootstrapping using Sub Periods Swaps.

Definition at line 37 of file subperiodsswaphelper.hpp.

Constructor & Destructor Documentation

◆ SubPeriodsSwapHelper()

SubPeriodsSwapHelper ( Handle< Quote >  spread,
const Period &  swapTenor,
const Period &  fixedTenor,
const Calendar &  fixedCalendar,
const DayCounter &  fixedDayCount,
BusinessDayConvention  fixedConvention,
const Period &  floatPayTenor,
const QuantLib::ext::shared_ptr< IborIndex > &  iborIndex,
const DayCounter &  floatDayCount,
const Handle< YieldTermStructure > &  discountingCurve = Handle<YieldTermStructure>(),
QuantExt::SubPeriodsCoupon1::Type  type = QuantExt::SubPeriodsCoupon1::Compounding 
)

Definition at line 26 of file subperiodsswaphelper.cpp.

33 : RelativeDateRateHelper(spread), iborIndex_(iborIndex), swapTenor_(swapTenor), fixedTenor_(fixedTenor),
34 fixedCalendar_(fixedCalendar), fixedDayCount_(fixedDayCount), fixedConvention_(fixedConvention),
35 floatPayTenor_(floatPayTenor), floatDayCount_(floatDayCount), type_(type), discountHandle_(discountingCurve) {
36
38 iborIndex_->unregisterWith(termStructureHandle_);
39
40 registerWith(iborIndex_);
41 registerWith(spread);
42 registerWith(discountHandle_);
43
45}
BusinessDayConvention fixedConvention_
RelinkableHandle< YieldTermStructure > termStructureHandle_
Handle< YieldTermStructure > discountHandle_
QuantExt::SubPeriodsCoupon1::Type type_
QuantLib::ext::shared_ptr< IborIndex > iborIndex_
RelativeDateBootstrapHelper< YieldTermStructure > RelativeDateRateHelper
+ Here is the call graph for this function:

Member Function Documentation

◆ impliedQuote()

Real impliedQuote ( ) const
override

Definition at line 101 of file subperiodsswaphelper.cpp.

101 {
102 QL_REQUIRE(termStructure_ != 0, "Termstructure not set");
103 swap_->deepUpdate();
104 return swap_->fairRate();
105}
QuantLib::ext::shared_ptr< SubPeriodsSwap > swap_

◆ setTermStructure()

void setTermStructure ( YieldTermStructure *  t)
override

Definition at line 86 of file subperiodsswaphelper.cpp.

86 {
87
88 bool observer = false;
89
90 QuantLib::ext::shared_ptr<YieldTermStructure> temp(t, null_deleter());
91 termStructureHandle_.linkTo(temp, observer);
92
93 if (discountHandle_.empty())
94 discountRelinkableHandle_.linkTo(temp, observer);
95 else
97
98 RelativeDateRateHelper::setTermStructure(t);
99}
RelinkableHandle< YieldTermStructure > discountRelinkableHandle_

◆ swap()

QuantLib::ext::shared_ptr< SubPeriodsSwap > swap ( ) const

Definition at line 53 of file subperiodsswaphelper.hpp.

53{ return swap_; }

◆ accept()

void accept ( AcyclicVisitor &  v)
override

Definition at line 107 of file subperiodsswaphelper.cpp.

107 {
108 Visitor<SubPeriodsSwapHelper>* v1 = dynamic_cast<Visitor<SubPeriodsSwapHelper>*>(&v);
109 if (v1 != 0)
110 v1->visit(*this);
111 else
112 RateHelper::accept(v);
113}

◆ initializeDates()

void initializeDates ( )
overrideprotected

Definition at line 47 of file subperiodsswaphelper.cpp.

47 {
48
49 // build swap
50 Date valuationDate = Settings::instance().evaluationDate();
51 Calendar spotCalendar = iborIndex_->fixingCalendar();
52 Natural spotDays = iborIndex_->fixingDays();
53 // move val date forward in case it is a holiday
54 valuationDate = spotCalendar.adjust(valuationDate);
55 Date effectiveDate = spotCalendar.advance(valuationDate, spotDays * Days);
56
57 swap_ = QuantLib::ext::shared_ptr<SubPeriodsSwap>(new SubPeriodsSwap(
58 effectiveDate, 1.0, swapTenor_, true, fixedTenor_, 0.0, fixedCalendar_, fixedDayCount_, fixedConvention_,
59 floatPayTenor_, iborIndex_, floatDayCount_, DateGeneration::Backward, type_));
60
61 QuantLib::ext::shared_ptr<PricingEngine> engine(new DiscountingSwapEngine(discountRelinkableHandle_));
62 swap_->setPricingEngine(engine);
63
64 // set earliest and latest
65 earliestDate_ = swap_->startDate();
66 latestDate_ = swap_->maturityDate();
67
68 QuantLib::ext::shared_ptr<FloatingRateCoupon> lastFloating =
69 QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(swap_->floatLeg().back());
70 if (IborCoupon::Settings::instance().usingAtParCoupons()) {
71 /* Subperiods coupons do not have a par approximation either... */
72 if (QuantLib::ext::dynamic_pointer_cast<QuantExt::SubPeriodsCoupon1>(lastFloating)) {
73 Date fixingValueDate = iborIndex_->valueDate(lastFloating->fixingDate());
74 Date endValueDate = iborIndex_->maturityDate(fixingValueDate);
75 latestDate_ = std::max(latestDate_, endValueDate);
76 }
77 } else {
78 /* May need to adjust latestDate_ if you are projecting libor based
79 on tenor length rather than from accrual date to accrual date. */
80 Date fixingValueDate = iborIndex_->valueDate(lastFloating->fixingDate());
81 Date endValueDate = iborIndex_->maturityDate(fixingValueDate);
82 latestDate_ = std::max(latestDate_, endValueDate);
83 }
84}
+ Here is the caller graph for this function:

Member Data Documentation

◆ swap_

QuantLib::ext::shared_ptr<SubPeriodsSwap> swap_
private

Definition at line 64 of file subperiodsswaphelper.hpp.

◆ iborIndex_

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

Definition at line 65 of file subperiodsswaphelper.hpp.

◆ swapTenor_

Period swapTenor_
private

Definition at line 66 of file subperiodsswaphelper.hpp.

◆ fixedTenor_

Period fixedTenor_
private

Definition at line 67 of file subperiodsswaphelper.hpp.

◆ fixedCalendar_

Calendar fixedCalendar_
private

Definition at line 68 of file subperiodsswaphelper.hpp.

◆ fixedDayCount_

DayCounter fixedDayCount_
private

Definition at line 69 of file subperiodsswaphelper.hpp.

◆ fixedConvention_

BusinessDayConvention fixedConvention_
private

Definition at line 70 of file subperiodsswaphelper.hpp.

◆ floatPayTenor_

Period floatPayTenor_
private

Definition at line 71 of file subperiodsswaphelper.hpp.

◆ floatDayCount_

DayCounter floatDayCount_
private

Definition at line 72 of file subperiodsswaphelper.hpp.

◆ type_

Definition at line 73 of file subperiodsswaphelper.hpp.

◆ termStructureHandle_

RelinkableHandle<YieldTermStructure> termStructureHandle_
private

Definition at line 75 of file subperiodsswaphelper.hpp.

◆ discountHandle_

Handle<YieldTermStructure> discountHandle_
private

Definition at line 76 of file subperiodsswaphelper.hpp.

◆ discountRelinkableHandle_

RelinkableHandle<YieldTermStructure> discountRelinkableHandle_
private

Definition at line 77 of file subperiodsswaphelper.hpp.