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

#include <qle/cashflows/blackaveragebmacouponpricer.hpp>

+ Inheritance diagram for BlackAverageBMACouponPricer:
+ Collaboration diagram for BlackAverageBMACouponPricer:

Public Member Functions

void initialize (const FloatingRateCoupon &coupon) override
 
Real swapletPrice () const override
 
Rate swapletRate () const override
 
Real capletPrice (Rate effectiveCap) const override
 
Rate capletRate (Rate effectiveCap) const override
 
Real floorletPrice (Rate effectiveFloor) const override
 
Rate floorletRate (Rate effectiveFloor) const override
 
 CapFlooredAverageBMACouponPricer (const Handle< OptionletVolatilityStructure > &v, const bool effectiveVolatilityInput=false)
 
- Public Member Functions inherited from CapFlooredAverageBMACouponPricer
 CapFlooredAverageBMACouponPricer (const Handle< OptionletVolatilityStructure > &v, const bool effectiveVolatilityInput=false)
 
Handle< OptionletVolatilityStructure > capletVolatility () const
 
bool effectiveVolatilityInput () const
 
Real effectiveCapletVolatility () const
 
Real effectiveFloorletVolatility () const
 

Private Member Functions

Real optionletRate (Option::Type optionType, Real effStrike) const
 

Private Attributes

Real gearing_
 
ext::shared_ptr< BMAIndex > index_
 
Real swapletRate_
 
Real forwardRate_
 
const CappedFlooredAverageBMACouponcoupon_
 

Additional Inherited Members

- Protected Attributes inherited from CapFlooredAverageBMACouponPricer
Handle< OptionletVolatilityStructure > capletVol_
 
bool effectiveVolatilityInput_
 
Real effectiveCapletVolatility_
 
Real effectiveFloorletVolatility_
 

Detailed Description

Definition at line 32 of file blackaveragebmacouponpricer.hpp.

Member Function Documentation

◆ initialize()

void initialize ( const FloatingRateCoupon coupon)
override

Definition at line 26 of file blackaveragebmacouponpricer.cpp.

26 {
27 coupon_ = dynamic_cast<const CappedFlooredAverageBMACoupon*>(&coupon);
28 QL_REQUIRE(coupon_, "BlackAverageBMACouponPricer: CappedFlooredAverageBMACoupon required");
29 gearing_ = coupon.gearing();
30 index_ = ext::dynamic_pointer_cast<BMAIndex>(coupon.index());
31 if (!index_) {
32 // check if the coupon was right
33 const CappedFlooredAverageBMACoupon* c = dynamic_cast<const CappedFlooredAverageBMACoupon*>(&coupon);
34 QL_REQUIRE(c, "BlackAverageBMACouponPricer: CappedFlooredAverageBMACoupon required");
35 // coupon was right, index is not
36 QL_FAIL("BlackAverageBMACouponPricer: CappedFlooredAverageBMACoupon required");
37 }
38 swapletRate_ = coupon_->underlying()->rate();
39 forwardRate_ = (swapletRate_ - coupon_->underlying()->spread()) / coupon_->underlying()->gearing();
41}
const CappedFlooredAverageBMACoupon * coupon_
ext::shared_ptr< AverageBMACoupon > underlying() const
+ Here is the call graph for this function:

◆ swapletPrice()

Real swapletPrice ( ) const
override

Definition at line 105 of file blackaveragebmacouponpricer.cpp.

105 {
106 QL_FAIL("BlackAverageBMACouponPricer::swapletPrice() not provided");
107}

◆ swapletRate()

Rate swapletRate ( ) const
override

Definition at line 95 of file blackaveragebmacouponpricer.cpp.

95{ return swapletRate_; }

◆ capletPrice()

Real capletPrice ( Rate  effectiveCap) const
override

Definition at line 108 of file blackaveragebmacouponpricer.cpp.

108 {
109 QL_FAIL("BlackAverageBMACouponPricer::capletPrice() not provided");
110}

◆ capletRate()

Rate capletRate ( Rate  effectiveCap) const
override

Definition at line 97 of file blackaveragebmacouponpricer.cpp.

97 {
98 return optionletRate(Option::Call, effectiveCap);
99}
Real optionletRate(Option::Type optionType, Real effStrike) const
+ Here is the call graph for this function:

◆ floorletPrice()

Real floorletPrice ( Rate  effectiveFloor) const
override

Definition at line 111 of file blackaveragebmacouponpricer.cpp.

111 {
112 QL_FAIL("BlackAverageBMACouponPricer::floorletPrice() not provided");
113}

◆ floorletRate()

Rate floorletRate ( Rate  effectiveFloor) const
override

Definition at line 101 of file blackaveragebmacouponpricer.cpp.

101 {
102 return optionletRate(Option::Put, effectiveFloor);
103}
+ Here is the call graph for this function:

◆ optionletRate()

Real optionletRate ( Option::Type  optionType,
Real  effStrike 
) const
private

Definition at line 43 of file blackaveragebmacouponpricer.cpp.

43 {
44 Date lastRelevantFixingDate = coupon_->underlying()->fixingDate();
45 if (lastRelevantFixingDate <= Settings::instance().evaluationDate()) {
46 // the amount is determined
47 Real a, b;
48 if (optionType == Option::Call) {
49 a = forwardRate_;
50 b = effStrike;
51 } else {
52 a = effStrike;
53 b = forwardRate_;
54 }
55 return gearing_ * std::max(a - b, 0.0);
56 } else {
57 // not yet determined, use Black model
58 QL_REQUIRE(!capletVolatility().empty(), "BlackAverageBMACouponPricer: missing optionlet volatility");
59 std::vector<Date> fixingDates = coupon_->underlying()->fixingDates();
60 QL_REQUIRE(!fixingDates.empty(),
61 "BlackAverageBMACouponPricer: internal error, got empty fixingDates, contact dev.");
62 fixingDates.erase(std::next(fixingDates.end(), -1)); // there is one additional date returned!
63 QL_REQUIRE(!fixingDates.empty(), "BlackAverageBMACouponPricer: empty fixing dates");
64 bool shiftedLn = capletVolatility()->volatilityType() == ShiftedLognormal;
65 Real shift = capletVolatility()->displacement();
66 Real stdDev;
67 Real effectiveTime = capletVolatility()->timeFromReference(fixingDates.back());
69 // vol input is effective, i.e. we use a plain black model
70 stdDev = capletVolatility()->volatility(fixingDates.back(), effStrike) * std::sqrt(effectiveTime);
71 } else {
72 // vol input is not effective: we proceed similarly to average on coupon pricing:
73 // for the standard deviation see Lyashenko, Mercurio, Looking forward to backward looking rates,
74 // section 6.3. the idea is to dampen the average volatility sigma between the fixing start and fixing end
75 // date by a linear function going from (fixing start, 1) to (fixing end, 0)
76 Real fixingStartTime = capletVolatility()->timeFromReference(fixingDates.front());
77 Real fixingEndTime = capletVolatility()->timeFromReference(fixingDates.back());
78 Real sigma = capletVolatility()->volatility(
79 std::max(fixingDates.front(), capletVolatility()->referenceDate() + 1), effStrike);
80 Real T = std::max(fixingStartTime, 0.0);
81 if (!close_enough(fixingEndTime, T))
82 T += std::pow(fixingEndTime - T, 3.0) / std::pow(fixingEndTime - fixingStartTime, 2.0) / 3.0;
83 stdDev = sigma * std::sqrt(T);
84 }
85 if (optionType == Option::Type::Call)
86 effectiveCapletVolatility_ = stdDev / std::sqrt(effectiveTime);
87 else
88 effectiveFloorletVolatility_ = stdDev / std::sqrt(effectiveTime);
89 Real fixing = shiftedLn ? blackFormula(optionType, effStrike, forwardRate_, stdDev, 1.0, shift)
90 : bachelierBlackFormula(optionType, effStrike, forwardRate_, stdDev, 1.0);
91 return gearing_ * fixing;
92 }
93}
Handle< OptionletVolatilityStructure > capletVolatility() const
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CapFlooredAverageBMACouponPricer()

CapFlooredAverageBMACouponPricer ( const Handle< OptionletVolatilityStructure > &  v,
const bool  effectiveVolatilityInput = false 
)

Member Data Documentation

◆ gearing_

Real gearing_
private

Definition at line 46 of file blackaveragebmacouponpricer.hpp.

◆ index_

ext::shared_ptr<BMAIndex> index_
private

Definition at line 47 of file blackaveragebmacouponpricer.hpp.

◆ swapletRate_

Real swapletRate_
private

Definition at line 48 of file blackaveragebmacouponpricer.hpp.

◆ forwardRate_

Real forwardRate_
private

Definition at line 48 of file blackaveragebmacouponpricer.hpp.

◆ coupon_

const CappedFlooredAverageBMACoupon* coupon_
private

Definition at line 50 of file blackaveragebmacouponpricer.hpp.