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

#include <qle/instruments/fixedbmaswap.hpp>

+ Collaboration diagram for MakeFixedBMASwap:

Public Member Functions

 MakeFixedBMASwap (const Period &swapTenor, const QuantLib::ext::shared_ptr< BMAIndex > &bmaIndex, Rate fixedRate=Null< Rate >(), const Period &forwardStart=0 *Days)
 
 operator FixedBMASwap () const
 
 operator QuantLib::ext::shared_ptr< FixedBMASwap > () const
 
MakeFixedBMASwapreceiveFixed (bool flag=true)
 
MakeFixedBMASwapwithType (FixedBMASwap::Type type)
 
MakeFixedBMASwapwithNominal (Real n)
 
MakeFixedBMASwapwithBMALegTenor (const Period &tenor)
 
MakeFixedBMASwapwithSettlementDays (Natural settlementDays)
 
MakeFixedBMASwapwithEffectiveDate (const Date &)
 
MakeFixedBMASwapwithTerminationDate (const Date &)
 
MakeFixedBMASwapwithFixedLegTenor (const Period &t)
 
MakeFixedBMASwapwithFixedLegCalendar (const Calendar &cal)
 
MakeFixedBMASwapwithFixedLegConvention (BusinessDayConvention bdc)
 
MakeFixedBMASwapwithFixedLegTerminationDateConvention (BusinessDayConvention bdc)
 
MakeFixedBMASwapwithFixedLegRule (DateGeneration::Rule r)
 
MakeFixedBMASwapwithFixedLegEndOfMonth (bool flag=true)
 
MakeFixedBMASwapwithFixedLegFirstDate (const Date &d)
 
MakeFixedBMASwapwithFixedLegNextToLastDate (const Date &d)
 
MakeFixedBMASwapwithFixedLegDayCount (const DayCounter &dc)
 
MakeFixedBMASwapwithDiscountingTermStructure (const Handle< YieldTermStructure > &discountCurve)
 
MakeFixedBMASwapwithPricingEngine (const QuantLib::ext::shared_ptr< PricingEngine > &engine)
 

Private Attributes

Period swapTenor_
 
QuantLib::ext::shared_ptr< BMAIndex > bmaIndex_
 
Rate fixedRate_
 
Period fixedTenor_
 
Period forwardStart_
 
Natural settlementDays_
 
Date effectiveDate_
 
Date terminationDate_
 
Calendar fixedCalendar_
 
Calendar bmaCalendar_
 
FixedBMASwap::Type type_
 
Real nominal_
 
Period bmaLegTenor_
 
BusinessDayConvention fixedConvention_
 
BusinessDayConvention fixedTerminationDateConvention_
 
BusinessDayConvention bmaConvention_
 
BusinessDayConvention bmaTerminationDateConvention_
 
DateGeneration::Rule fixedRule_
 
DateGeneration::Rule bmaRule_
 
bool fixedEndOfMonth_
 
bool bmaEndOfMonth_
 
Date fixedFirstDate_
 
Date fixedNextToLastDate_
 
Date bmaFirstDate_
 
Date bmaNextToLastDate_
 
DayCounter fixedDayCount_
 
DayCounter bmaDayCount_
 
QuantLib::ext::shared_ptr< PricingEngine > engine_
 

Detailed Description

Definition at line 86 of file fixedbmaswap.hpp.

Constructor & Destructor Documentation

◆ MakeFixedBMASwap()

MakeFixedBMASwap ( const Period &  swapTenor,
const QuantLib::ext::shared_ptr< BMAIndex > &  bmaIndex,
Rate  fixedRate = Null<Rate>(),
const Period &  forwardStart = 0 * Days 
)

Definition at line 135 of file fixedbmaswap.cpp.

137 : swapTenor_(swapTenor), bmaIndex_(index), fixedRate_(fixedRate), forwardStart_(forwardStart),
138 settlementDays_(bmaIndex_->fixingDays()), fixedCalendar_(index->fixingCalendar()),
139 bmaCalendar_(index->fixingCalendar()), type_(FixedBMASwap::Payer), nominal_(1.0), bmaLegTenor_(3 * Months),
140 fixedConvention_(ModifiedFollowing), fixedTerminationDateConvention_(ModifiedFollowing),
141 bmaConvention_(ModifiedFollowing), bmaTerminationDateConvention_(ModifiedFollowing),
142 fixedRule_(DateGeneration::Backward), bmaRule_(DateGeneration::Backward), fixedEndOfMonth_(false),
143 bmaEndOfMonth_(false), fixedFirstDate_(Date()), fixedNextToLastDate_(Date()), bmaFirstDate_(Date()),
144 bmaNextToLastDate_(Date()), bmaDayCount_(index->dayCounter()) {}
FixedBMASwap::Type type_
BusinessDayConvention fixedConvention_
DateGeneration::Rule bmaRule_
BusinessDayConvention bmaTerminationDateConvention_
DateGeneration::Rule fixedRule_
BusinessDayConvention fixedTerminationDateConvention_
QuantLib::ext::shared_ptr< BMAIndex > bmaIndex_
BusinessDayConvention bmaConvention_

Member Function Documentation

◆ operator FixedBMASwap()

operator FixedBMASwap ( ) const

Definition at line 146 of file fixedbmaswap.cpp.

146 {
147 QuantLib::ext::shared_ptr<FixedBMASwap> swap = *this;
148 return *swap;
149}

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

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

Definition at line 151 of file fixedbmaswap.cpp.

151 {
152 Date startDate;
153
154 // start dates and end dates
155 if (effectiveDate_ != Date())
156 startDate = effectiveDate_;
157 else {
158 Date refDate = Settings::instance().evaluationDate();
159 // if the evaluation date is not a business day
160 // then move to the next business day
161 refDate = bmaCalendar_.adjust(refDate);
162 Date spotDate = bmaCalendar_.advance(refDate, settlementDays_ * Days);
163 startDate = spotDate + forwardStart_;
164 if (forwardStart_.length() < 0)
165 startDate = bmaCalendar_.adjust(startDate, Preceding);
166 else
167 startDate = bmaCalendar_.adjust(startDate, Following);
168 }
169
170 Date endDate = terminationDate_;
171 if (endDate == Date()) {
172 if (bmaEndOfMonth_)
173 endDate = bmaCalendar_.advance(startDate, swapTenor_, ModifiedFollowing, bmaEndOfMonth_);
174 else
175 endDate = startDate + swapTenor_;
176 }
177
178 const Currency& curr = bmaIndex_->currency();
179 QL_REQUIRE(curr == USDCurrency(), "Only USD is supported for fixed vs BMA swaps.");
180
181 // schedules
182
183 Period fixedTenor;
184 if (fixedTenor_ != Period())
185 fixedTenor = fixedTenor_;
186 else
187 // Default according to Bloomberg & OpenGamma
188 fixedTenor = 6 * Months;
189
190 Schedule fixedSchedule(startDate, endDate, fixedTenor, fixedCalendar_, fixedConvention_,
193
194 Schedule bmaSchedule(startDate, endDate, bmaLegTenor_, bmaCalendar_, bmaConvention_, bmaTerminationDateConvention_,
196
197 DayCounter fixedDayCount;
198 if (fixedDayCount_ != DayCounter())
199 fixedDayCount = fixedDayCount_;
200 else {
201 // Default according to Bloomberg & OpenGamma
202 fixedDayCount = Thirty360(Thirty360::USA);
203 }
204
205 Rate usedFixedRate = fixedRate_;
206 if (fixedRate_ == Null<Rate>()) {
207 FixedBMASwap temp(type_, nominal_, fixedSchedule,
208 0.0, // fixed rate
209 fixedDayCount, bmaSchedule, bmaIndex_, bmaDayCount_);
210 if (engine_ != 0)
211 temp.setPricingEngine(engine_);
212 else
213 QL_FAIL("Null fixed rate and no discounting curve provided to fixed vs BMA swap.");
214 usedFixedRate = temp.fairRate();
215 }
216
217 QuantLib::ext::shared_ptr<FixedBMASwap> swap(new FixedBMASwap(type_, nominal_, fixedSchedule, usedFixedRate, fixedDayCount,
218 bmaSchedule, bmaIndex_, bmaDayCount_));
219
220 if (engine_ != 0)
221 swap->setPricingEngine(engine_);
222
223 return swap;
224}
QuantLib::ext::shared_ptr< PricingEngine > engine_
+ Here is the call graph for this function:

◆ receiveFixed()

MakeFixedBMASwap & receiveFixed ( bool  flag = true)

Definition at line 226 of file fixedbmaswap.cpp.

226 {
228 return *this;
229}

◆ withType()

MakeFixedBMASwap & withType ( FixedBMASwap::Type  type)

Definition at line 231 of file fixedbmaswap.cpp.

231 {
232 type_ = type;
233 return *this;
234}

◆ withNominal()

MakeFixedBMASwap & withNominal ( Real  n)

Definition at line 236 of file fixedbmaswap.cpp.

236 {
237 nominal_ = n;
238 return *this;
239}

◆ withBMALegTenor()

MakeFixedBMASwap & withBMALegTenor ( const Period &  tenor)

Definition at line 241 of file fixedbmaswap.cpp.

241 {
242 QL_REQUIRE(tenor.units() == Months, "Average BMA Leg coupons should pay as a multiple of months.");
243 bmaLegTenor_ = tenor;
244 return *this;
245}

◆ withSettlementDays()

MakeFixedBMASwap & withSettlementDays ( Natural  settlementDays)

Definition at line 247 of file fixedbmaswap.cpp.

247 {
248 settlementDays_ = settlementDays;
249 effectiveDate_ = Date();
250 return *this;
251}

◆ withEffectiveDate()

MakeFixedBMASwap & withEffectiveDate ( const Date &  effectiveDate)

Definition at line 253 of file fixedbmaswap.cpp.

253 {
254 effectiveDate_ = effectiveDate;
255 return *this;
256}

◆ withTerminationDate()

MakeFixedBMASwap & withTerminationDate ( const Date &  terminationDate)

Definition at line 258 of file fixedbmaswap.cpp.

258 {
259 terminationDate_ = terminationDate;
260 swapTenor_ = Period();
261 return *this;
262}

◆ withFixedLegTenor()

MakeFixedBMASwap & withFixedLegTenor ( const Period &  t)

Definition at line 275 of file fixedbmaswap.cpp.

275 {
276 fixedTenor_ = t;
277 return *this;
278}

◆ withFixedLegCalendar()

MakeFixedBMASwap & withFixedLegCalendar ( const Calendar &  cal)

Definition at line 280 of file fixedbmaswap.cpp.

280 {
281 fixedCalendar_ = cal;
282 return *this;
283}

◆ withFixedLegConvention()

MakeFixedBMASwap & withFixedLegConvention ( BusinessDayConvention  bdc)

Definition at line 285 of file fixedbmaswap.cpp.

285 {
286 fixedConvention_ = bdc;
287 return *this;
288}

◆ withFixedLegTerminationDateConvention()

MakeFixedBMASwap & withFixedLegTerminationDateConvention ( BusinessDayConvention  bdc)

Definition at line 290 of file fixedbmaswap.cpp.

290 {
292 return *this;
293}

◆ withFixedLegRule()

MakeFixedBMASwap & withFixedLegRule ( DateGeneration::Rule  r)

Definition at line 295 of file fixedbmaswap.cpp.

295 {
296 fixedRule_ = r;
297 return *this;
298}

◆ withFixedLegEndOfMonth()

MakeFixedBMASwap & withFixedLegEndOfMonth ( bool  flag = true)

Definition at line 300 of file fixedbmaswap.cpp.

300 {
301 fixedEndOfMonth_ = flag;
302 return *this;
303}

◆ withFixedLegFirstDate()

MakeFixedBMASwap & withFixedLegFirstDate ( const Date &  d)

Definition at line 305 of file fixedbmaswap.cpp.

305 {
306 fixedFirstDate_ = d;
307 return *this;
308}

◆ withFixedLegNextToLastDate()

MakeFixedBMASwap & withFixedLegNextToLastDate ( const Date &  d)

Definition at line 310 of file fixedbmaswap.cpp.

310 {
312 return *this;
313}

◆ withFixedLegDayCount()

MakeFixedBMASwap & withFixedLegDayCount ( const DayCounter &  dc)

Definition at line 315 of file fixedbmaswap.cpp.

315 {
316 fixedDayCount_ = dc;
317 return *this;
318}

◆ withDiscountingTermStructure()

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

Definition at line 264 of file fixedbmaswap.cpp.

264 {
265 bool includeSettlementDateFlows = false;
266 engine_ = QuantLib::ext::shared_ptr<PricingEngine>(new DiscountingSwapEngine(d, includeSettlementDateFlows));
267 return *this;
268}

◆ withPricingEngine()

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

Definition at line 270 of file fixedbmaswap.cpp.

270 {
271 engine_ = engine;
272 return *this;
273}

Member Data Documentation

◆ swapTenor_

Period swapTenor_
private

Definition at line 120 of file fixedbmaswap.hpp.

◆ bmaIndex_

QuantLib::ext::shared_ptr<BMAIndex> bmaIndex_
private

Definition at line 121 of file fixedbmaswap.hpp.

◆ fixedRate_

Rate fixedRate_
private

Definition at line 122 of file fixedbmaswap.hpp.

◆ fixedTenor_

Period fixedTenor_
private

Definition at line 123 of file fixedbmaswap.hpp.

◆ forwardStart_

Period forwardStart_
private

Definition at line 124 of file fixedbmaswap.hpp.

◆ settlementDays_

Natural settlementDays_
private

Definition at line 126 of file fixedbmaswap.hpp.

◆ effectiveDate_

Date effectiveDate_
private

Definition at line 127 of file fixedbmaswap.hpp.

◆ terminationDate_

Date terminationDate_
private

Definition at line 127 of file fixedbmaswap.hpp.

◆ fixedCalendar_

Calendar fixedCalendar_
private

Definition at line 128 of file fixedbmaswap.hpp.

◆ bmaCalendar_

Calendar bmaCalendar_
private

Definition at line 128 of file fixedbmaswap.hpp.

◆ type_

FixedBMASwap::Type type_
private

Definition at line 130 of file fixedbmaswap.hpp.

◆ nominal_

Real nominal_
private

Definition at line 131 of file fixedbmaswap.hpp.

◆ bmaLegTenor_

Period bmaLegTenor_
private

Definition at line 132 of file fixedbmaswap.hpp.

◆ fixedConvention_

BusinessDayConvention fixedConvention_
private

Definition at line 133 of file fixedbmaswap.hpp.

◆ fixedTerminationDateConvention_

BusinessDayConvention fixedTerminationDateConvention_
private

Definition at line 133 of file fixedbmaswap.hpp.

◆ bmaConvention_

BusinessDayConvention bmaConvention_
private

Definition at line 134 of file fixedbmaswap.hpp.

◆ bmaTerminationDateConvention_

BusinessDayConvention bmaTerminationDateConvention_
private

Definition at line 134 of file fixedbmaswap.hpp.

◆ fixedRule_

DateGeneration::Rule fixedRule_
private

Definition at line 135 of file fixedbmaswap.hpp.

◆ bmaRule_

DateGeneration::Rule bmaRule_
private

Definition at line 135 of file fixedbmaswap.hpp.

◆ fixedEndOfMonth_

bool fixedEndOfMonth_
private

Definition at line 136 of file fixedbmaswap.hpp.

◆ bmaEndOfMonth_

bool bmaEndOfMonth_
private

Definition at line 136 of file fixedbmaswap.hpp.

◆ fixedFirstDate_

Date fixedFirstDate_
private

Definition at line 137 of file fixedbmaswap.hpp.

◆ fixedNextToLastDate_

Date fixedNextToLastDate_
private

Definition at line 137 of file fixedbmaswap.hpp.

◆ bmaFirstDate_

Date bmaFirstDate_
private

Definition at line 138 of file fixedbmaswap.hpp.

◆ bmaNextToLastDate_

Date bmaNextToLastDate_
private

Definition at line 138 of file fixedbmaswap.hpp.

◆ fixedDayCount_

DayCounter fixedDayCount_
private

Definition at line 139 of file fixedbmaswap.hpp.

◆ bmaDayCount_

DayCounter bmaDayCount_
private

Definition at line 139 of file fixedbmaswap.hpp.

◆ engine_

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

Definition at line 141 of file fixedbmaswap.hpp.