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

Pricer for sub-period coupons. More...

#include <qle/cashflows/subperiodscouponpricer.hpp>

+ Inheritance diagram for SubPeriodsCouponPricer1:
+ Collaboration diagram for SubPeriodsCouponPricer1:

Public Member Functions

 SubPeriodsCouponPricer1 ()
 
void initialize (const FloatingRateCoupon &coupon) override
 
Rate swapletRate () const override
 
Real swapletPrice () const override
 
Real capletPrice (Rate) const override
 
Rate capletRate (Rate) const override
 
Real floorletPrice (Rate) const override
 
Rate floorletRate (Rate) const override
 

Protected Attributes

Real gearing_
 
Spread spread_
 
Time accrualPeriod_
 
QuantLib::ext::shared_ptr< InterestRateIndexindex_
 
SubPeriodsCoupon1::Type type_
 
bool includeSpread_
 
const SubPeriodsCoupon1coupon_
 

Detailed Description

Pricer for sub-period coupons.

Definition at line 38 of file subperiodscouponpricer.hpp.

Constructor & Destructor Documentation

◆ SubPeriodsCouponPricer1()

Definition at line 40 of file subperiodscouponpricer.hpp.

40{}

Member Function Documentation

◆ initialize()

void initialize ( const FloatingRateCoupon coupon)
override

Definition at line 23 of file subperiodscouponpricer.cpp.

23 {
24
25 coupon_ = dynamic_cast<const SubPeriodsCoupon1*>(&coupon);
26 QL_REQUIRE(coupon_, "SubPeriodsCoupon required");
27
28 index_ = QuantLib::ext::dynamic_pointer_cast<InterestRateIndex>(coupon_->index());
29 QL_REQUIRE(index_, "InterestRateIndex required");
30
31 gearing_ = coupon_->gearing();
33 accrualPeriod_ = coupon_->accrualPeriod();
34 type_ = coupon_->type();
36}
bool includeSpread() const
whether to include/exclude spread in compounding/averaging
Type type() const
whether sub-period fixings are averaged or compounded
Spread spread() const
Need to be able to change spread to solve for fair spread.
QuantLib::ext::shared_ptr< InterestRateIndex > index_
+ Here is the call graph for this function:

◆ swapletRate()

Rate swapletRate ( ) const
override

Definition at line 38 of file subperiodscouponpricer.cpp.

38 {
39
40 std::vector<Time> accrualFractions = coupon_->accrualFractions();
41 Size numPeriods = accrualFractions.size();
42 Spread incSpread = includeSpread_ ? spread_ : 0.0;
43 Spread excSpread = includeSpread_ ? 0.0 : spread_;
44 Real accumulatedRate;
45 Rate rate;
46
47 std::vector<Rate> fixings = coupon_->indexFixings();
49 accumulatedRate = 0.0;
50 for (Size i = 0; i < numPeriods; ++i) {
51 accumulatedRate += (fixings[i] + incSpread) * accrualFractions[i];
52 }
53 rate = gearing_ * accumulatedRate / accrualPeriod_ + excSpread;
55 accumulatedRate = 1.0;
56 for (Size i = 0; i < numPeriods; ++i) {
57 accumulatedRate *= (1.0 + (fixings[i] + incSpread) * accrualFractions[i]);
58 }
59 rate = gearing_ * (accumulatedRate - 1.0) / accrualPeriod_ + excSpread;
60 } else {
61 QL_FAIL("Invalid sub-period coupon type");
62 }
63
64 return rate;
65}
const std::vector< Time > & accrualFractions() const
accrual periods for the sub-periods
const std::vector< Rate > & indexFixings() const
fixings for the sub-periods
+ Here is the call graph for this function:

◆ swapletPrice()

Real swapletPrice ( ) const
override

Definition at line 45 of file subperiodscouponpricer.hpp.

45{ QL_FAIL("swapletPrice not available"); }

◆ capletPrice()

Real capletPrice ( Rate  ) const
override

Definition at line 46 of file subperiodscouponpricer.hpp.

46{ QL_FAIL("capletPrice not available"); }

◆ capletRate()

Rate capletRate ( Rate  ) const
override

Definition at line 47 of file subperiodscouponpricer.hpp.

47{ QL_FAIL("capletRate not available"); }

◆ floorletPrice()

Real floorletPrice ( Rate  ) const
override

Definition at line 48 of file subperiodscouponpricer.hpp.

48{ QL_FAIL("floorletPrice not available"); }

◆ floorletRate()

Rate floorletRate ( Rate  ) const
override

Definition at line 49 of file subperiodscouponpricer.hpp.

49{ QL_FAIL("floorletRate not available"); }

Member Data Documentation

◆ gearing_

Real gearing_
protected

Definition at line 52 of file subperiodscouponpricer.hpp.

◆ spread_

Spread spread_
protected

Definition at line 53 of file subperiodscouponpricer.hpp.

◆ accrualPeriod_

Time accrualPeriod_
protected

Definition at line 54 of file subperiodscouponpricer.hpp.

◆ index_

QuantLib::ext::shared_ptr<InterestRateIndex> index_
protected

Definition at line 55 of file subperiodscouponpricer.hpp.

◆ type_

SubPeriodsCoupon1::Type type_
protected

Definition at line 56 of file subperiodscouponpricer.hpp.

◆ includeSpread_

bool includeSpread_
protected

Definition at line 57 of file subperiodscouponpricer.hpp.

◆ coupon_

const SubPeriodsCoupon1* coupon_
protected

Definition at line 59 of file subperiodscouponpricer.hpp.