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

#include <qle/instruments/makeoiscapfloor.hpp>

+ Collaboration diagram for MakeOISCapFloor:

Public Member Functions

 MakeOISCapFloor (CapFloor::Type type, const Period &tenor, const ext::shared_ptr< OvernightIndex > &index, const Period &rateComputationPeriod, Rate strike, const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve=Handle< YieldTermStructure >())
 
 operator Leg () const
 
MakeOISCapFloorwithNominal (Real n)
 
MakeOISCapFloorwithEffectiveDate (const Date &effectiveDate)
 
MakeOISCapFloorwithSettlementDays (Natural settlementDays)
 
MakeOISCapFloorwithCalendar (const Calendar &cal)
 
MakeOISCapFloorwithConvention (BusinessDayConvention bdc)
 
MakeOISCapFloorwithRule (DateGeneration::Rule r)
 
MakeOISCapFloorwithDayCount (const DayCounter &dc)
 
MakeOISCapFloorwithTelescopicValueDates (bool telescopicValueDates)
 
MakeOISCapFloorwithCouponPricer (const ext::shared_ptr< CappedFlooredOvernightIndexedCouponPricer > &pricer)
 
MakeOISCapFloorwithDiscountCurve ()
 

Private Attributes

CapFloor::Type type_
 
Period tenor_
 
QuantLib::ext::shared_ptr< OvernightIndex > index_
 
Period rateComputationPeriod_
 
Rate strike_
 
Real nominal_
 
Date effectiveDate_
 
Natural settlementDays_
 
Calendar calendar_
 
BusinessDayConvention convention_
 
DateGeneration::Rule rule_
 
DayCounter dayCounter_
 
bool telescopicValueDates_
 
ext::shared_ptr< CappedFlooredOvernightIndexedCouponPricerpricer_
 
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
 

Detailed Description

Definition at line 31 of file makeoiscapfloor.hpp.

Constructor & Destructor Documentation

◆ MakeOISCapFloor()

MakeOISCapFloor ( CapFloor::Type  type,
const Period &  tenor,
const ext::shared_ptr< OvernightIndex > &  index,
const Period &  rateComputationPeriod,
Rate  strike,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  discountCurve = Handle<YieldTermStructure>() 
)

Definition at line 25 of file makeoiscapfloor.cpp.

28 : type_(type), tenor_(tenor), index_(index), rateComputationPeriod_(rateComputationPeriod), strike_(strike),
29 nominal_(1.0), settlementDays_(2), calendar_(index->fixingCalendar()), convention_(ModifiedFollowing),
30 rule_(DateGeneration::Backward), dayCounter_(index->dayCounter()), telescopicValueDates_(false),
31 discountCurve_(discountCurve) {}
QuantLib::ext::shared_ptr< OvernightIndex > index_
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
BusinessDayConvention convention_
DateGeneration::Rule rule_

Member Function Documentation

◆ operator Leg()

operator Leg ( ) const

Definition at line 33 of file makeoiscapfloor.cpp.

33 {
34 Calendar calendar = index_->fixingCalendar();
35
36 Date startDate;
37 if (effectiveDate_ != Date()) {
38 startDate = effectiveDate_;
39 } else {
40 Date refDate = Settings::instance().evaluationDate();
41 startDate = calendar.advance(calendar.adjust(refDate), settlementDays_ * Days);
42 }
43
44 Date endDate = calendar.adjust(startDate + tenor_, ModifiedFollowing);
45
46 Schedule schedule(startDate, endDate, rateComputationPeriod_, calendar, ModifiedFollowing, ModifiedFollowing,
47 DateGeneration::Backward, false);
48
49 // determine atm strike if required
50 Real effectiveStrike = strike_;
51 if (effectiveStrike == Null<Real>()) {
52 Leg leg = OvernightLeg(schedule, index_)
53 .withNotionals(nominal_)
54 .withPaymentDayCounter(dayCounter_)
55 .withPaymentAdjustment(convention_)
56 .withTelescopicValueDates(telescopicValueDates_);
57 effectiveStrike =
58 CashFlows::atmRate(leg, discountCurve_.empty() ? **index_->forwardingTermStructure() : **discountCurve_,
59 false, index_->forwardingTermStructure()->referenceDate());
60 }
61
62 Real cap = Null<Real>(), floor = Null<Real>();
63 if (type_ == CapFloor::Cap)
64 cap = effectiveStrike;
65 else if (type_ == CapFloor::Floor)
66 floor = effectiveStrike;
67 else {
68 QL_FAIL("MakeOISCapFloor: expected type Cap or Floor");
69 }
70
71 Leg leg = OvernightLeg(schedule, index_)
72 .withNotionals(nominal_)
73 .withPaymentDayCounter(dayCounter_)
74 .withPaymentAdjustment(convention_)
75 .withCaps(cap)
76 .withFloors(floor)
77 .withNakedOption(true)
78 .withTelescopicValueDates(telescopicValueDates_);
79
80 if (pricer_) {
81 for (auto &c : leg) {
82 auto f = QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(c);
83 if (f) {
84 f->setPricer(pricer_);
85 }
86 }
87 }
88
89 return leg;
90}
ext::shared_ptr< CappedFlooredOvernightIndexedCouponPricer > pricer_
+ Here is the call graph for this function:

◆ withNominal()

MakeOISCapFloor & withNominal ( Real  n)

Definition at line 92 of file makeoiscapfloor.cpp.

92 {
93 nominal_ = n;
94 return *this;
95}

◆ withEffectiveDate()

MakeOISCapFloor & withEffectiveDate ( const Date &  effectiveDate)

Definition at line 97 of file makeoiscapfloor.cpp.

97 {
98 effectiveDate_ = effectiveDate;
99 return *this;
100}
+ Here is the caller graph for this function:

◆ withSettlementDays()

MakeOISCapFloor & withSettlementDays ( Natural  settlementDays)

Definition at line 102 of file makeoiscapfloor.cpp.

102 {
103 settlementDays_ = settlementDays;
104 return *this;
105}
+ Here is the caller graph for this function:

◆ withCalendar()

MakeOISCapFloor & withCalendar ( const Calendar &  cal)

Definition at line 107 of file makeoiscapfloor.cpp.

107 {
108 calendar_ = cal;
109 return *this;
110}

◆ withConvention()

MakeOISCapFloor & withConvention ( BusinessDayConvention  bdc)

Definition at line 112 of file makeoiscapfloor.cpp.

112 {
113 convention_ = bdc;
114 return *this;
115}

◆ withRule()

MakeOISCapFloor & withRule ( DateGeneration::Rule  r)

Definition at line 117 of file makeoiscapfloor.cpp.

117 {
118 rule_ = r;
119 return *this;
120}

◆ withDayCount()

MakeOISCapFloor & withDayCount ( const DayCounter &  dc)

Definition at line 122 of file makeoiscapfloor.cpp.

122 {
123 dayCounter_ = dc;
124 return *this;
125}

◆ withTelescopicValueDates()

MakeOISCapFloor & withTelescopicValueDates ( bool  telescopicValueDates)

Definition at line 127 of file makeoiscapfloor.cpp.

127 {
129 return *this;
130}
+ Here is the caller graph for this function:

◆ withCouponPricer()

MakeOISCapFloor & withCouponPricer ( const ext::shared_ptr< CappedFlooredOvernightIndexedCouponPricer > &  pricer)

Definition at line 133 of file makeoiscapfloor.cpp.

133 {
134 pricer_ = pricer;
135 return *this;
136}
+ Here is the caller graph for this function:

◆ withDiscountCurve()

MakeOISCapFloor & withDiscountCurve ( )

Member Data Documentation

◆ type_

CapFloor::Type type_
private

Definition at line 53 of file makeoiscapfloor.hpp.

◆ tenor_

Period tenor_
private

Definition at line 54 of file makeoiscapfloor.hpp.

◆ index_

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

Definition at line 55 of file makeoiscapfloor.hpp.

◆ rateComputationPeriod_

Period rateComputationPeriod_
private

Definition at line 56 of file makeoiscapfloor.hpp.

◆ strike_

Rate strike_
private

Definition at line 57 of file makeoiscapfloor.hpp.

◆ nominal_

Real nominal_
private

Definition at line 59 of file makeoiscapfloor.hpp.

◆ effectiveDate_

Date effectiveDate_
private

Definition at line 60 of file makeoiscapfloor.hpp.

◆ settlementDays_

Natural settlementDays_
private

Definition at line 61 of file makeoiscapfloor.hpp.

◆ calendar_

Calendar calendar_
private

Definition at line 62 of file makeoiscapfloor.hpp.

◆ convention_

BusinessDayConvention convention_
private

Definition at line 63 of file makeoiscapfloor.hpp.

◆ rule_

DateGeneration::Rule rule_
private

Definition at line 64 of file makeoiscapfloor.hpp.

◆ dayCounter_

DayCounter dayCounter_
private

Definition at line 65 of file makeoiscapfloor.hpp.

◆ telescopicValueDates_

bool telescopicValueDates_
private

Definition at line 66 of file makeoiscapfloor.hpp.

◆ pricer_

ext::shared_ptr<CappedFlooredOvernightIndexedCouponPricer> pricer_
private

Definition at line 68 of file makeoiscapfloor.hpp.

◆ discountCurve_

QuantLib::Handle<QuantLib::YieldTermStructure> discountCurve_
private

Definition at line 69 of file makeoiscapfloor.hpp.