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

#include <qle/instruments/subperiodsswap.hpp>

+ Collaboration diagram for MakeSubPeriodsSwap:

Public Member Functions

 MakeSubPeriodsSwap (const Period &swapTenor, const QuantLib::ext::shared_ptr< IborIndex > &index, Rate fixedRate, const Period &floatPayTenor, const Period &forwardStart=0 *Days)
 
 operator SubPeriodsSwap () const
 
 operator QuantLib::ext::shared_ptr< SubPeriodsSwap > () const
 
MakeSubPeriodsSwapwithEffectiveDate (const Date &)
 
MakeSubPeriodsSwapwithNominal (Real n)
 
MakeSubPeriodsSwapwithIsPayer (bool p)
 
MakeSubPeriodsSwapwithSettlementDays (Natural settlementDays)
 
MakeSubPeriodsSwapwithFixedLegTenor (const Period &t)
 
MakeSubPeriodsSwapwithFixedLegCalendar (const Calendar &cal)
 
MakeSubPeriodsSwapwithFixedLegConvention (BusinessDayConvention bdc)
 
MakeSubPeriodsSwapwithFixedLegRule (DateGeneration::Rule r)
 
MakeSubPeriodsSwapwithFixedLegDayCount (const DayCounter &dc)
 
MakeSubPeriodsSwapwithSubCouponsType (const QuantExt::SubPeriodsCoupon1::Type &st)
 
MakeSubPeriodsSwapwithDiscountingTermStructure (const Handle< YieldTermStructure > &discountCurve)
 
MakeSubPeriodsSwapwithPricingEngine (const QuantLib::ext::shared_ptr< PricingEngine > &engine)
 

Private Attributes

Period swapTenor_
 
QuantLib::ext::shared_ptr< IborIndex > index_
 
Rate fixedRate_
 
Period floatPayTenor_
 
Period forwardStart_
 
Date effectiveDate_
 
Real nominal_
 
bool isPayer_
 
Natural settlementDays_
 
Period fixedTenor_
 
Calendar fixedCalendar_
 
BusinessDayConvention fixedConvention_
 
DateGeneration::Rule fixedRule_
 
DayCounter fixedDayCount_
 
DayCounter floatDayCounter_
 
QuantExt::SubPeriodsCoupon1::Type subCouponsType_
 
QuantLib::ext::shared_ptr< PricingEngine > engine_
 

Detailed Description

Definition at line 119 of file subperiodsswap.hpp.

Constructor & Destructor Documentation

◆ MakeSubPeriodsSwap()

MakeSubPeriodsSwap ( const Period &  swapTenor,
const QuantLib::ext::shared_ptr< IborIndex > &  index,
Rate  fixedRate,
const Period &  floatPayTenor,
const Period &  forwardStart = 0 * Days 
)

Definition at line 103 of file subperiodsswap.cpp.

105 : swapTenor_(swapTenor), index_(index), fixedRate_(fixedRate), floatPayTenor_(floatPayTenor), forwardStart_(forwardStart),
106 nominal_(1.0), isPayer_(true), settlementDays_(index->fixingDays()), fixedCalendar_(index->fixingCalendar()),
107 fixedConvention_(ModifiedFollowing), fixedRule_(DateGeneration::Backward), floatDayCounter_(index->dayCounter()),
BusinessDayConvention fixedConvention_
QuantExt::SubPeriodsCoupon1::Type subCouponsType_
QuantLib::ext::shared_ptr< IborIndex > index_
DateGeneration::Rule fixedRule_

Member Function Documentation

◆ operator SubPeriodsSwap()

operator SubPeriodsSwap ( ) const

Definition at line 110 of file subperiodsswap.cpp.

110 {
111 QuantLib::ext::shared_ptr<SubPeriodsSwap> swap = *this;
112 return *swap;
113}

◆ operator QuantLib::ext::shared_ptr< SubPeriodsSwap >()

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

Definition at line 115 of file subperiodsswap.cpp.

115 {
116
117 Date startDate;
118
119 // start dates and end dates
120 if (effectiveDate_ != Date())
121 startDate = effectiveDate_;
122 else {
123 Date refDate = Settings::instance().evaluationDate();
124 // if the evaluation date is not a business day
125 // then move to the next business day
126 refDate = index_->fixingCalendar().adjust(refDate);
127 Date spotDate = index_->fixingCalendar().advance(refDate, settlementDays_ * Days);
128 startDate = spotDate + forwardStart_;
129 if (forwardStart_.length() < 0)
130 startDate = index_->fixingCalendar().adjust(startDate, Preceding);
131 else
132 startDate = index_->fixingCalendar().adjust(startDate, Following);
133 }
134
135 // Copied from MakeVanillaSwap - Is there a better way?
136 const Currency& curr = index_->currency();
137 Period fixedTenor;
138 if (fixedTenor_ != Period())
139 fixedTenor = fixedTenor_;
140 else {
141 if ((curr == EURCurrency()) ||
142 (curr == USDCurrency()) ||
143 (curr == CHFCurrency()) ||
144 (curr == SEKCurrency()) ||
145 (curr == GBPCurrency() && swapTenor_ <= 1 * Years))
146 fixedTenor = Period(1, Years);
147 else if ((curr == GBPCurrency() && swapTenor_ > 1 * Years) ||
148 (curr == JPYCurrency()) ||
149 (curr == AUDCurrency() && swapTenor_ >= 4 * Years))
150 fixedTenor = Period(6, Months);
151 else if ((curr == HKDCurrency() ||
152 (curr == AUDCurrency() && swapTenor_ < 4 * Years)))
153 fixedTenor = Period(3, Months);
154 else
155 QL_FAIL("unknown fixed leg default tenor for " << curr);
156 }
157
158 // Copied from MakeVanillaSwap - Is there a better way?
159 DayCounter fixedDayCount;
160 if (fixedDayCount_ != DayCounter())
161 fixedDayCount = fixedDayCount_;
162 else {
163 if (curr == USDCurrency())
164 fixedDayCount = Actual360();
165 else if (curr == EURCurrency() || curr == CHFCurrency() ||
166 curr == SEKCurrency())
167 fixedDayCount = Thirty360(Thirty360::BondBasis);
168 else if (curr == GBPCurrency() || curr == JPYCurrency() ||
169 curr == AUDCurrency() || curr == HKDCurrency() ||
170 curr == THBCurrency())
171 fixedDayCount = Actual365Fixed();
172 else
173 QL_FAIL("unknown fixed leg day counter for " << curr);
174 }
175
176 QuantLib::ext::shared_ptr<SubPeriodsSwap> swap(new SubPeriodsSwap(startDate, nominal_, swapTenor_, isPayer_,
177 fixedTenor, fixedRate_, fixedCalendar_, fixedDayCount, fixedConvention_, floatPayTenor_, index_,
179
180 if (engine_ != 0)
181 swap->setPricingEngine(engine_);
182
183 return swap;
184}
QuantLib::ext::shared_ptr< PricingEngine > engine_

◆ withEffectiveDate()

MakeSubPeriodsSwap & withEffectiveDate ( const Date &  effectiveDate)

Definition at line 186 of file subperiodsswap.cpp.

186 {
187 effectiveDate_ = effectiveDate;
188 return *this;
189}

◆ withNominal()

MakeSubPeriodsSwap & withNominal ( Real  n)

Definition at line 191 of file subperiodsswap.cpp.

191 {
192 nominal_ = n;
193 return *this;
194}

◆ withIsPayer()

MakeSubPeriodsSwap & withIsPayer ( bool  p)

Definition at line 196 of file subperiodsswap.cpp.

196 {
197 isPayer_ = p;
198 return *this;
199}

◆ withSettlementDays()

MakeSubPeriodsSwap & withSettlementDays ( Natural  settlementDays)

Definition at line 201 of file subperiodsswap.cpp.

201 {
202 settlementDays_ = settlementDays;
203 effectiveDate_ = Date();
204 return *this;
205}

◆ withFixedLegTenor()

MakeSubPeriodsSwap & withFixedLegTenor ( const Period &  t)

Definition at line 207 of file subperiodsswap.cpp.

207 {
208 fixedTenor_ = t;
209 return *this;
210}

◆ withFixedLegCalendar()

MakeSubPeriodsSwap & withFixedLegCalendar ( const Calendar &  cal)

Definition at line 212 of file subperiodsswap.cpp.

212 {
213 fixedCalendar_ = cal;
214 return *this;
215}

◆ withFixedLegConvention()

MakeSubPeriodsSwap & withFixedLegConvention ( BusinessDayConvention  bdc)

Definition at line 217 of file subperiodsswap.cpp.

217 {
218 fixedConvention_ = bdc;
219 return *this;
220}

◆ withFixedLegRule()

MakeSubPeriodsSwap & withFixedLegRule ( DateGeneration::Rule  r)

Definition at line 222 of file subperiodsswap.cpp.

222 {
223 fixedRule_ = r;
224 return *this;
225}

◆ withFixedLegDayCount()

MakeSubPeriodsSwap & withFixedLegDayCount ( const DayCounter &  dc)

Definition at line 227 of file subperiodsswap.cpp.

227 {
228 fixedDayCount_ = dc;
229 return *this;
230}

◆ withSubCouponsType()

MakeSubPeriodsSwap & withSubCouponsType ( const QuantExt::SubPeriodsCoupon1::Type st)

Definition at line 232 of file subperiodsswap.cpp.

232 {
233 subCouponsType_ = st;
234 return *this;
235}

◆ withDiscountingTermStructure()

MakeSubPeriodsSwap & withDiscountingTermStructure ( const Handle< YieldTermStructure > &  discountCurve)

Definition at line 237 of file subperiodsswap.cpp.

237 {
238 bool includeSettlementDateFlows = false;
239 engine_ = QuantLib::ext::shared_ptr<PricingEngine>(new DiscountingSwapEngine(d, includeSettlementDateFlows));
240 return *this;
241}

◆ withPricingEngine()

MakeSubPeriodsSwap & withPricingEngine ( const QuantLib::ext::shared_ptr< PricingEngine > &  engine)

Definition at line 243 of file subperiodsswap.cpp.

243 {
244 engine_ = engine;
245 return *this;
246}

Member Data Documentation

◆ swapTenor_

Period swapTenor_
private

Definition at line 144 of file subperiodsswap.hpp.

◆ index_

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

Definition at line 145 of file subperiodsswap.hpp.

◆ fixedRate_

Rate fixedRate_
private

Definition at line 146 of file subperiodsswap.hpp.

◆ floatPayTenor_

Period floatPayTenor_
private

Definition at line 147 of file subperiodsswap.hpp.

◆ forwardStart_

Period forwardStart_
private

Definition at line 148 of file subperiodsswap.hpp.

◆ effectiveDate_

Date effectiveDate_
private

Definition at line 150 of file subperiodsswap.hpp.

◆ nominal_

Real nominal_
private

Definition at line 151 of file subperiodsswap.hpp.

◆ isPayer_

bool isPayer_
private

Definition at line 152 of file subperiodsswap.hpp.

◆ settlementDays_

Natural settlementDays_
private

Definition at line 153 of file subperiodsswap.hpp.

◆ fixedTenor_

Period fixedTenor_
private

Definition at line 155 of file subperiodsswap.hpp.

◆ fixedCalendar_

Calendar fixedCalendar_
private

Definition at line 156 of file subperiodsswap.hpp.

◆ fixedConvention_

BusinessDayConvention fixedConvention_
private

Definition at line 157 of file subperiodsswap.hpp.

◆ fixedRule_

DateGeneration::Rule fixedRule_
private

Definition at line 158 of file subperiodsswap.hpp.

◆ fixedDayCount_

DayCounter fixedDayCount_
private

Definition at line 159 of file subperiodsswap.hpp.

◆ floatDayCounter_

DayCounter floatDayCounter_
private

Definition at line 159 of file subperiodsswap.hpp.

◆ subCouponsType_

QuantExt::SubPeriodsCoupon1::Type subCouponsType_
private

Definition at line 161 of file subperiodsswap.hpp.

◆ engine_

QuantLib::ext::shared_ptr<PricingEngine> engine_
private

Definition at line 163 of file subperiodsswap.hpp.