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

swap paying a fixed rate against BMA coupons More...

#include <qle/instruments/fixedbmaswap.hpp>

+ Inheritance diagram for FixedBMASwap:
+ Collaboration diagram for FixedBMASwap:

Classes

class  engine
 
class  results
 

Public Types

enum  Type { Receiver = -1 , Payer = 1 }
 

Public Member Functions

 FixedBMASwap (Type type, Real nominal, const Schedule &fixedSchedule, Rate fixedRate, const DayCounter &fixedDayCount, const Schedule &bmaSchedule, const QuantLib::ext::shared_ptr< BMAIndex > &bmaIndex, const DayCounter &bmaDayCount)
 
Inspectors
Real fixedRate () const
 
Real nominal () const
 
Type type () const
 "payer" or "receiver" refer to the BMA leg More...
 
const Leg & bmaLeg () const
 
const Leg & fixedLeg () const
 

Results

Type type_
 
Real nominal_
 
Rate fixedRate_
 
Rate fairRate_
 
Real fixedLegBPS () const
 
Real fixedLegNPV () const
 
Rate fairRate () const
 
Real bmaLegBPS () const
 
Real bmaLegNPV () const
 
void fetchResults (const PricingEngine::results *) const override
 

Detailed Description

swap paying a fixed rate against BMA coupons

Definition at line 35 of file fixedbmaswap.hpp.

Member Enumeration Documentation

◆ Type

enum Type
Enumerator
Receiver 
Payer 

Definition at line 39 of file fixedbmaswap.hpp.

Constructor & Destructor Documentation

◆ FixedBMASwap()

FixedBMASwap ( Type  type,
Real  nominal,
const Schedule &  fixedSchedule,
Rate  fixedRate,
const DayCounter &  fixedDayCount,
const Schedule &  bmaSchedule,
const QuantLib::ext::shared_ptr< BMAIndex > &  bmaIndex,
const DayCounter &  bmaDayCount 
)

Definition at line 35 of file fixedbmaswap.cpp.

42
43 legs_[0] = FixedRateLeg(fixedSchedule)
44 .withNotionals(nominal)
45 .withCouponRates(fixedRate, fixedDayCount)
46 .withPaymentAdjustment(fixedSchedule.businessDayConvention());
47
48 legs_[1] = AverageBMALeg(bmaSchedule, bmaIndex)
49 .withNotionals(nominal)
50 .withPaymentDayCounter(bmaDayCount)
51 .withPaymentAdjustment(bmaSchedule.businessDayConvention());
52
53 for (Size j = 0; j < 2; ++j) {
54 for (Leg::iterator i = legs_[j].begin(); i != legs_[j].end(); ++i)
55 registerWith(*i);
56 }
57
58 switch (type_) {
59 case Payer:
60 payer_[0] = +1.0;
61 payer_[1] = -1.0;
62 break;
63 case Receiver:
64 payer_[0] = -1.0;
65 payer_[1] = +1.0;
66 break;
67 default:
68 QL_FAIL("Unknown BMA-swap type");
69 }
70}
Type type() const
"payer" or "receiver" refer to the BMA leg
+ Here is the call graph for this function:

Member Function Documentation

◆ fixedRate()

Real fixedRate ( ) const

Definition at line 72 of file fixedbmaswap.cpp.

72{ return fixedRate_; }
+ Here is the caller graph for this function:

◆ nominal()

Real nominal ( ) const

Definition at line 74 of file fixedbmaswap.cpp.

74{ return nominal_; }
+ Here is the caller graph for this function:

◆ type()

FixedBMASwap::Type type ( ) const

"payer" or "receiver" refer to the BMA leg

Definition at line 76 of file fixedbmaswap.cpp.

76{ return type_; }

◆ bmaLeg()

const Leg & bmaLeg ( ) const

Definition at line 80 of file fixedbmaswap.cpp.

80{ return legs_[1]; }

◆ fixedLeg()

const Leg & fixedLeg ( ) const

Definition at line 78 of file fixedbmaswap.cpp.

78{ return legs_[0]; }

◆ fixedLegBPS()

Real fixedLegBPS ( ) const

Definition at line 82 of file fixedbmaswap.cpp.

82 {
83 calculate();
84 QL_REQUIRE(legBPS_[0] != Null<Real>(), "result not available");
85 return legBPS_[0];
86}

◆ fixedLegNPV()

Real fixedLegNPV ( ) const

Definition at line 88 of file fixedbmaswap.cpp.

88 {
89 calculate();
90 QL_REQUIRE(legNPV_[0] != Null<Real>(), "result not available");
91 return legNPV_[0];
92}

◆ fairRate()

Rate fairRate ( ) const

Definition at line 94 of file fixedbmaswap.cpp.

94 {
95 calculate();
96 QL_REQUIRE(fairRate_ != Null<Rate>(), "result not available");
97 return fairRate_;
98}
+ Here is the caller graph for this function:

◆ bmaLegBPS()

Real bmaLegBPS ( ) const

Definition at line 100 of file fixedbmaswap.cpp.

100 {
101 calculate();
102 QL_REQUIRE(legBPS_[1] != Null<Real>(), "result not available");
103 return legBPS_[1];
104}

◆ bmaLegNPV()

Real bmaLegNPV ( ) const

Definition at line 106 of file fixedbmaswap.cpp.

106 {
107 calculate();
108 QL_REQUIRE(legNPV_[1] != Null<Real>(), "result not available");
109 return legNPV_[1];
110}

◆ fetchResults()

void fetchResults ( const PricingEngine::results *  r) const
override

Definition at line 112 of file fixedbmaswap.cpp.

112 {
113 static const Spread basisPoint = 1.0e-4;
114
115 Swap::fetchResults(r);
116
117 const FixedBMASwap::results* results = dynamic_cast<const FixedBMASwap::results*>(r);
118 if (results) { // might be a swap engine, so no error is thrown
119 fairRate_ = results->fairRate;
120 } else {
121 fairRate_ = Null<Rate>();
122 }
123 if (fairRate_ == Null<Rate>()) {
124 // calculate it from other results
125 if (legBPS_[0] != Null<Real>())
126 fairRate_ = fixedRate_ - NPV_ / (legBPS_[0] / basisPoint);
127 }
128}

Member Data Documentation

◆ type_

Type type_
private

Definition at line 70 of file fixedbmaswap.hpp.

◆ nominal_

Real nominal_
private

Definition at line 71 of file fixedbmaswap.hpp.

◆ fixedRate_

Rate fixedRate_
private

Definition at line 72 of file fixedbmaswap.hpp.

◆ fairRate_

Rate fairRate_
mutableprivate

Definition at line 74 of file fixedbmaswap.hpp.