Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
subperiodscoupon.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file subperiodscoupon.hpp
20 \brief Coupon with a number of sub-periods
21
22 \ingroup cashflows
23*/
24
25#ifndef quantext_sub_periods_coupon_hpp
26#define quantext_sub_periods_coupon_hpp
27
28#include <ql/cashflows/floatingratecoupon.hpp>
29#include <ql/time/schedule.hpp>
30
31namespace QuantExt {
32using namespace QuantLib;
33//! Sub-periods pricer
34class SubPeriodsCouponPricer1;
35
36//! Sub-periods coupon
37/*! The coupon period tenor is a multiple of the tenor associated with
38* the index. The index tenor divides the coupon period into sub-periods.
39* The index fixing for each sub-period is compounded or averaged over
40* the full coupon period.
41
42 \ingroup cashflows
43 \todo merge into QuantLib
44
45*/
47public:
49 SubPeriodsCoupon1(const Date& paymentDate, Real nominal, const Date& startDate, const Date& endDate,
50 const QuantLib::ext::shared_ptr<InterestRateIndex>& index, Type type, BusinessDayConvention convention,
51 Spread spread = 0.0, const DayCounter& dayCounter = DayCounter(), bool includeSpread = false,
52 Real gearing = 1.0);
53 //! \name Inspectors
54 //@{
55 //! fixing dates for the sub-periods
56 const std::vector<Date>& fixingDates() const { return fixingDates_; }
57 //! accrual periods for the sub-periods
58 const std::vector<Time>& accrualFractions() const { return accrualFractions_; }
59 //! fixings for the sub-periods
60 const std::vector<Rate>& indexFixings() const;
61 //! value dates for the sub-periods
62 const std::vector<Date>& valueDates() const { return valueDates_; }
63 //! whether sub-period fixings are averaged or compounded
64 Type type() const { return type_; }
65 //! whether to include/exclude spread in compounding/averaging
66 bool includeSpread() const { return includeSpread_; }
67 //! Need to be able to change spread to solve for fair spread
68 Spread spread() const { return spread_; }
69 Spread& spread() { return spread_; }
70 //@}
71 //! \name FloatingRateCoupon interface
72 //@{
73 //! the date when the coupon is fully determined
74 Date fixingDate() const override { return fixingDates_.back(); }
75 //@}
76 //! \name Visitability
77 //@{
78 void accept(AcyclicVisitor&) override;
79 //@}
80private:
83 std::vector<Date> valueDates_, fixingDates_;
84 mutable std::vector<Rate> fixings_;
86 std::vector<Time> accrualFractions_;
87};
88
89//! helper class building a sequence of sub-period coupons
90/*! \ingroup cashflows
91 \todo merge into QuantLib
92 */
94public:
95 SubPeriodsLeg1(const Schedule& schedule, const QuantLib::ext::shared_ptr<InterestRateIndex>& index);
96 SubPeriodsLeg1& withNotional(Real notional);
97 SubPeriodsLeg1& withNotionals(const std::vector<Real>& notionals);
98 SubPeriodsLeg1& withPaymentDayCounter(const DayCounter& dayCounter);
99 SubPeriodsLeg1& withPaymentAdjustment(BusinessDayConvention convention);
100 SubPeriodsLeg1& withGearing(Real gearing);
101 SubPeriodsLeg1& withGearings(const std::vector<Real>& gearings);
102 SubPeriodsLeg1& withSpread(Spread spread);
103 SubPeriodsLeg1& withSpreads(const std::vector<Spread>& spreads);
104 SubPeriodsLeg1& withPaymentCalendar(const Calendar& calendar);
107 operator Leg() const;
108
109private:
110 Schedule schedule_;
111 QuantLib::ext::shared_ptr<InterestRateIndex> index_;
112 std::vector<Real> notionals_;
114 BusinessDayConvention paymentAdjustment_;
115 std::vector<Real> gearings_;
116 std::vector<Spread> spreads_;
120};
121} // namespace QuantExt
122
123#endif
bool includeSpread() const
whether to include/exclude spread in compounding/averaging
std::vector< Date > fixingDates_
const std::vector< Date > & valueDates() const
value dates for the sub-periods
std::vector< Time > accrualFractions_
void accept(AcyclicVisitor &) override
std::vector< Rate > fixings_
const std::vector< Time > & accrualFractions() const
accrual periods for the sub-periods
std::vector< Date > valueDates_
const std::vector< Rate > & indexFixings() const
fixings for the sub-periods
const std::vector< Date > & fixingDates() const
fixing dates for the sub-periods
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.
Date fixingDate() const override
the date when the coupon is fully determined
helper class building a sequence of sub-period coupons
BusinessDayConvention paymentAdjustment_
SubPeriodsLeg1 & withPaymentDayCounter(const DayCounter &dayCounter)
SubPeriodsLeg1 & withGearing(Real gearing)
SubPeriodsLeg1 & withType(SubPeriodsCoupon1::Type type)
QuantLib::ext::shared_ptr< InterestRateIndex > index_
SubPeriodsLeg1 & withSpreads(const std::vector< Spread > &spreads)
std::vector< Real > notionals_
std::vector< Spread > spreads_
SubPeriodsLeg1 & withSpread(Spread spread)
SubPeriodsCoupon1::Type type_
SubPeriodsLeg1 & includeSpread(bool includeSpread)
SubPeriodsLeg1 & withGearings(const std::vector< Real > &gearings)
SubPeriodsLeg1 & withPaymentCalendar(const Calendar &calendar)
SubPeriodsLeg1 & withNotional(Real notional)
SubPeriodsLeg1 & withNotionals(const std::vector< Real > &notionals)
SubPeriodsLeg1 & withPaymentAdjustment(BusinessDayConvention convention)
std::vector< Real > gearings_
SimpleQuote & spread_