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

Average overnight index swap. More...

#include <qle/instruments/averageois.hpp>

+ Inheritance diagram for AverageOIS:
+ Collaboration diagram for AverageOIS:

Public Types

enum  Type { Receiver = -1 , Payer = 1 }
 Receiver (Payer) means receive (pay) fixed. More...
 

Public Member Functions

 AverageOIS (Type type, Real nominal, const Schedule &fixedSchedule, Rate fixedRate, const DayCounter &fixedDayCounter, BusinessDayConvention fixedPaymentAdjustment, const Calendar &fixedPaymentCalendar, const Schedule &onSchedule, const QuantLib::ext::shared_ptr< OvernightIndex > &overnightIndex, BusinessDayConvention onPaymentAdjustment, const Calendar &onPaymentCalendar, Natural rateCutoff=0, Spread onSpread=0.0, Real onGearing=1.0, const DayCounter &onDayCounter=DayCounter(), const QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > &onCouponPricer=QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer >(), const bool telescopicValueDates=false)
 Arithmetic average ON leg vs. fixed leg constructor. More...
 
 AverageOIS (Type type, std::vector< Real > nominals, const Schedule &fixedSchedule, std::vector< Rate > fixedRates, const DayCounter &fixedDayCounter, BusinessDayConvention fixedPaymentAdjustment, const Calendar &fixedPaymentCalendar, const Schedule &onSchedule, const QuantLib::ext::shared_ptr< OvernightIndex > &overnightIndex, BusinessDayConvention onPaymentAdjustment, const Calendar &onPaymentCalendar, Natural rateCutoff=0, std::vector< Spread > onSpreads=std::vector< Spread >(1, 0.0), std::vector< Real > onGearings=std::vector< Real >(1, 1.0), const DayCounter &onDayCounter=DayCounter(), const QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > &onCouponPricer=QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer >(), const bool telescopicValueDates=false)
 
Inspectors
Type type () const
 
Real nominal () const
 
const std::vector< Real > & nominals () const
 
Rate fixedRate () const
 
const std::vector< Rate > & fixedRates () const
 
const DayCounter & fixedDayCounter ()
 
const QuantLib::ext::shared_ptr< OvernightIndex > & overnightIndex ()
 
Natural rateCutoff ()
 
Spread onSpread () const
 
const std::vector< Spread > & onSpreads () const
 
Real onGearing () const
 
const std::vector< Real > & onGearings () const
 
const DayCounter & onDayCounter ()
 
const Leg & fixedLeg () const
 
const Leg & overnightLeg () const
 

Results

Type type_
 
std::vector< Real > nominals_
 
std::vector< Rate > fixedRates_
 
DayCounter fixedDayCounter_
 
BusinessDayConvention fixedPaymentAdjustment_
 
Calendar fixedPaymentCalendar_
 
QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
 
BusinessDayConvention onPaymentAdjustment_
 
Calendar onPaymentCalendar_
 
Natural rateCutoff_
 
std::vector< Spread > onSpreads_
 
std::vector< Real > onGearings_
 
DayCounter onDayCounter_
 
QuantLib::ext::shared_ptr< AverageONIndexedCouponPriceronCouponPricer_
 
bool telescopicValueDates_
 
Real fixedLegBPS () const
 
Real fixedLegNPV () const
 
Real fairRate () const
 
Real overnightLegBPS () const
 
Real overnightLegNPV () const
 
Spread fairSpread () const
 
void setONIndexedCouponPricer (const QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > &onCouponPricer)
 
void initialize (const Schedule &fixedLegSchedule, const Schedule &onLegSchedule)
 

Detailed Description

Average overnight index swap.

Swap with first leg fixed and the second leg being an arithmetic average overnight index.

    \ingroup instruments

Definition at line 46 of file averageois.hpp.

Member Enumeration Documentation

◆ Type

enum Type

Receiver (Payer) means receive (pay) fixed.

Enumerator
Receiver 
Payer 

Definition at line 49 of file averageois.hpp.

Constructor & Destructor Documentation

◆ AverageOIS() [1/2]

AverageOIS ( Type  type,
Real  nominal,
const Schedule &  fixedSchedule,
Rate  fixedRate,
const DayCounter &  fixedDayCounter,
BusinessDayConvention  fixedPaymentAdjustment,
const Calendar &  fixedPaymentCalendar,
const Schedule &  onSchedule,
const QuantLib::ext::shared_ptr< OvernightIndex > &  overnightIndex,
BusinessDayConvention  onPaymentAdjustment,
const Calendar &  onPaymentCalendar,
Natural  rateCutoff = 0,
Spread  onSpread = 0.0,
Real  onGearing = 1.0,
const DayCounter &  onDayCounter = DayCounter(),
const QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > &  onCouponPricer = QuantLib::ext::shared_ptr<AverageONIndexedCouponPricer>(),
const bool  telescopicValueDates = false 
)

Arithmetic average ON leg vs. fixed leg constructor.

Definition at line 26 of file averageois.cpp.

34 : Swap(2), type_(type), nominals_(std::vector<Real>(1, nominal)), fixedRates_(std::vector<Rate>(1, fixedRate)),
35 fixedDayCounter_(fixedDCB), fixedPaymentAdjustment_(fixedLegPaymentAdjustment),
36 fixedPaymentCalendar_(fixedLegPaymentCalendar), overnightIndex_(overnightIndex),
37 onPaymentAdjustment_(onLegPaymentAdjustment), onPaymentCalendar_(onLegPaymentCalendar), rateCutoff_(rateCutoff),
38 onSpreads_(std::vector<Spread>(1, onLegSpread)), onGearings_(std::vector<Real>(1, onLegGearing)),
39 onDayCounter_(onLegDCB), onCouponPricer_(onLegCouponPricer), telescopicValueDates_(telescopicValueDates) {
40 initialize(fixedLegSchedule, onLegSchedule);
41}
Rate fixedRate() const
Definition: averageois.cpp:106
QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
Definition: averageois.hpp:123
DayCounter fixedDayCounter_
Definition: averageois.hpp:119
BusinessDayConvention fixedPaymentAdjustment_
Definition: averageois.hpp:120
const QuantLib::ext::shared_ptr< OvernightIndex > & overnightIndex()
Definition: averageois.hpp:87
BusinessDayConvention onPaymentAdjustment_
Definition: averageois.hpp:124
void initialize(const Schedule &fixedLegSchedule, const Schedule &onLegSchedule)
Definition: averageois.cpp:61
std::vector< Rate > fixedRates_
Definition: averageois.hpp:118
QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > onCouponPricer_
Definition: averageois.hpp:130
std::vector< Spread > onSpreads_
Definition: averageois.hpp:127
Calendar onPaymentCalendar_
Definition: averageois.hpp:125
Real nominal() const
Definition: averageois.cpp:101
Calendar fixedPaymentCalendar_
Definition: averageois.hpp:121
Type type() const
Definition: averageois.hpp:78
DayCounter onDayCounter_
Definition: averageois.hpp:129
std::vector< Real > onGearings_
Definition: averageois.hpp:128
std::vector< Real > nominals_
Definition: averageois.hpp:116
+ Here is the call graph for this function:

◆ AverageOIS() [2/2]

AverageOIS ( Type  type,
std::vector< Real >  nominals,
const Schedule &  fixedSchedule,
std::vector< Rate >  fixedRates,
const DayCounter &  fixedDayCounter,
BusinessDayConvention  fixedPaymentAdjustment,
const Calendar &  fixedPaymentCalendar,
const Schedule &  onSchedule,
const QuantLib::ext::shared_ptr< OvernightIndex > &  overnightIndex,
BusinessDayConvention  onPaymentAdjustment,
const Calendar &  onPaymentCalendar,
Natural  rateCutoff = 0,
std::vector< Spread >  onSpreads = std::vector<Spread>(1, 0.0),
std::vector< Real >  onGearings = std::vector<Real>(1, 1.0),
const DayCounter &  onDayCounter = DayCounter(),
const QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > &  onCouponPricer = QuantLib::ext::shared_ptr<AverageONIndexedCouponPricer>(),
const bool  telescopicValueDates = false 
)

Arithmetic average ON leg vs. fixed leg constructor, allowing for varying nominals, fixed rates, ON leg spreads and ON leg gearings.

Definition at line 43 of file averageois.cpp.

53 fixedPaymentAdjustment_(fixedLegPaymentAdjustment), fixedPaymentCalendar_(fixedLegPaymentCalendar),
54 overnightIndex_(overnightIndex), onPaymentAdjustment_(onLegPaymentAdjustment),
55 onPaymentCalendar_(onLegPaymentCalendar), rateCutoff_(rateCutoff), onSpreads_(onLegSpreads),
56 onGearings_(onLegGearings), onDayCounter_(onLegDCB), onCouponPricer_(onLegCouponPricer),
57 telescopicValueDates_(telescopicValueDates) {
58 initialize(fixedLegSchedule, onLegSchedule);
59}
const std::vector< Real > & nominals() const
Definition: averageois.hpp:81
const std::vector< Rate > & fixedRates() const
Definition: averageois.hpp:84
+ Here is the call graph for this function:

Member Function Documentation

◆ type()

Type type ( ) const

Definition at line 78 of file averageois.hpp.

78{ return type_; }

◆ nominal()

Real nominal ( ) const

Definition at line 101 of file averageois.cpp.

101 {
102 QL_REQUIRE(nominals_.size() == 1, "Swap has varying nominals");
103 return nominals_[0];
104}

◆ nominals()

const std::vector< Real > & nominals ( ) const

Definition at line 81 of file averageois.hpp.

81{ return nominals_; }

◆ fixedRate()

Rate fixedRate ( ) const

Definition at line 106 of file averageois.cpp.

106 {
107 QL_REQUIRE(fixedRates_.size() == 1, "Swap has varying fixed rates");
108 return fixedRates_[0];
109}

◆ fixedRates()

const std::vector< Rate > & fixedRates ( ) const

Definition at line 84 of file averageois.hpp.

84{ return fixedRates_; }

◆ fixedDayCounter()

const DayCounter & fixedDayCounter ( )

Definition at line 85 of file averageois.hpp.

85{ return fixedDayCounter_; }

◆ overnightIndex()

const QuantLib::ext::shared_ptr< OvernightIndex > & overnightIndex ( )

Definition at line 87 of file averageois.hpp.

87{ return overnightIndex_; }

◆ rateCutoff()

Natural rateCutoff ( )

Definition at line 88 of file averageois.hpp.

88{ return rateCutoff_; }

◆ onSpread()

Spread onSpread ( ) const

Definition at line 111 of file averageois.cpp.

111 {
112 QL_REQUIRE(onSpreads_.size() == 1, "Swap has varying ON spreads");
113 return onSpreads_[0];
114}

◆ onSpreads()

const std::vector< Spread > & onSpreads ( ) const

Definition at line 90 of file averageois.hpp.

90{ return onSpreads_; }

◆ onGearing()

Real onGearing ( ) const

Definition at line 116 of file averageois.cpp.

116 {
117 QL_REQUIRE(onGearings_.size() == 1, "Swap has varying ON gearings");
118 return onGearings_[0];
119}

◆ onGearings()

const std::vector< Real > & onGearings ( ) const

Definition at line 92 of file averageois.hpp.

92{ return onGearings_; }

◆ onDayCounter()

const DayCounter & onDayCounter ( )

Definition at line 93 of file averageois.hpp.

93{ return onDayCounter_; }

◆ fixedLeg()

const Leg & fixedLeg ( ) const

Definition at line 95 of file averageois.hpp.

95{ return legs_[0]; }

◆ overnightLeg()

const Leg & overnightLeg ( ) const

Definition at line 96 of file averageois.hpp.

96{ return legs_[1]; }

◆ fixedLegBPS()

Real fixedLegBPS ( ) const

Definition at line 121 of file averageois.cpp.

121 {
122 calculate();
123 QL_REQUIRE(legBPS_[0] != Null<Real>(), "fixedLegBPS not available");
124 return legBPS_[0];
125}
+ Here is the caller graph for this function:

◆ fixedLegNPV()

Real fixedLegNPV ( ) const

Definition at line 127 of file averageois.cpp.

127 {
128 calculate();
129 QL_REQUIRE(legNPV_[0] != Null<Real>(), "fixedLegNPV not available");
130 return legNPV_[0];
131}

◆ fairRate()

Real fairRate ( ) const

Definition at line 133 of file averageois.cpp.

133 {
134 static const Spread basisPoint = 1.0e-4;
135 calculate();
136 return -overnightLegNPV() / (fixedLegBPS() / basisPoint);
137}
Real fixedLegBPS() const
Definition: averageois.cpp:121
Real overnightLegNPV() const
Definition: averageois.cpp:145
+ Here is the call graph for this function:

◆ overnightLegBPS()

Real overnightLegBPS ( ) const

Definition at line 139 of file averageois.cpp.

139 {
140 calculate();
141 QL_REQUIRE(legBPS_[1] != Null<Real>(), "overnightLegBPS not available");
142 return legBPS_[1];
143}
+ Here is the caller graph for this function:

◆ overnightLegNPV()

Real overnightLegNPV ( ) const

Definition at line 145 of file averageois.cpp.

145 {
146 calculate();
147 QL_REQUIRE(legNPV_[1] != Null<Real>(), "overnightLegNPV not available");
148 return legNPV_[1];
149}
+ Here is the caller graph for this function:

◆ fairSpread()

Spread fairSpread ( ) const

Definition at line 151 of file averageois.cpp.

151 {
152 QL_REQUIRE(onSpreads_.size() == 1, "fairSpread not implemented for varying spreads.");
153 static const Spread basisPoint = 1.0e-4;
154 calculate();
155 return onSpreads_[0] - NPV_ / (overnightLegBPS() / basisPoint);
156}
Real overnightLegBPS() const
Definition: averageois.cpp:139
+ Here is the call graph for this function:

◆ setONIndexedCouponPricer()

void setONIndexedCouponPricer ( const QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > &  onCouponPricer)

Definition at line 158 of file averageois.cpp.

158 {
159 QuantExt::setCouponPricer(legs_[1], onCouponPricer);
160 update();
161}
void setCouponPricer(const Leg &leg, const QuantLib::ext::shared_ptr< FloatingRateCouponPricer > &pricer)
Set Coupon Pricer.
+ Here is the call graph for this function:

◆ initialize()

void initialize ( const Schedule &  fixedLegSchedule,
const Schedule &  onLegSchedule 
)
private

Definition at line 61 of file averageois.cpp.

61 {
62 // Fixed leg.
63 legs_[0] = FixedRateLeg(fixedLegSchedule)
64 .withNotionals(nominals_)
65 .withCouponRates(fixedRates_, fixedDayCounter_)
66 .withPaymentAdjustment(fixedPaymentAdjustment_)
67 .withPaymentCalendar(fixedPaymentCalendar_);
68
69 // Average ON leg.
70 AverageONLeg tempAverageONLeg = AverageONLeg(onLegSchedule, overnightIndex_)
71 .withNotionals(nominals_)
72 .withPaymentAdjustment(onPaymentAdjustment_)
73 .withPaymentCalendar(onPaymentCalendar_)
74 .withRateCutoff(rateCutoff_)
75 .withSpreads(onSpreads_)
76 .withGearings(onGearings_)
77 .withPaymentDayCounter(onDayCounter_)
78 .withTelescopicValueDates(telescopicValueDates_);
79
80 if (onCouponPricer_) {
81 tempAverageONLeg = tempAverageONLeg.withAverageONIndexedCouponPricer(onCouponPricer_);
82 }
83
84 legs_[1] = tempAverageONLeg;
85
86 // Set the fixed and ON leg to pay (receive) and receive (pay) resp.
87 switch (type_) {
88 case Payer:
89 payer_[0] = -1.0;
90 payer_[1] = +1.0;
91 break;
92 case Receiver:
93 payer_[0] = +1.0;
94 payer_[1] = -1.0;
95 break;
96 default:
97 QL_FAIL("Unknown average ON index swap type");
98 }
99}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ type_

Type type_
private

Definition at line 115 of file averageois.hpp.

◆ nominals_

std::vector<Real> nominals_
private

Definition at line 116 of file averageois.hpp.

◆ fixedRates_

std::vector<Rate> fixedRates_
private

Definition at line 118 of file averageois.hpp.

◆ fixedDayCounter_

DayCounter fixedDayCounter_
private

Definition at line 119 of file averageois.hpp.

◆ fixedPaymentAdjustment_

BusinessDayConvention fixedPaymentAdjustment_
private

Definition at line 120 of file averageois.hpp.

◆ fixedPaymentCalendar_

Calendar fixedPaymentCalendar_
private

Definition at line 121 of file averageois.hpp.

◆ overnightIndex_

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

Definition at line 123 of file averageois.hpp.

◆ onPaymentAdjustment_

BusinessDayConvention onPaymentAdjustment_
private

Definition at line 124 of file averageois.hpp.

◆ onPaymentCalendar_

Calendar onPaymentCalendar_
private

Definition at line 125 of file averageois.hpp.

◆ rateCutoff_

Natural rateCutoff_
private

Definition at line 126 of file averageois.hpp.

◆ onSpreads_

std::vector<Spread> onSpreads_
private

Definition at line 127 of file averageois.hpp.

◆ onGearings_

std::vector<Real> onGearings_
private

Definition at line 128 of file averageois.hpp.

◆ onDayCounter_

DayCounter onDayCounter_
private

Definition at line 129 of file averageois.hpp.

◆ onCouponPricer_

QuantLib::ext::shared_ptr<AverageONIndexedCouponPricer> onCouponPricer_
private

Definition at line 130 of file averageois.hpp.

◆ telescopicValueDates_

bool telescopicValueDates_
private

Definition at line 131 of file averageois.hpp.