Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
durationadjustedcmscoupon.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 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 durationadjustedcmscoupon.hpp
20 \brief cms coupon scaled by a duration number
21 \ingroup cashflows
22*/
23
24#pragma once
25
26#include <ql/cashflows/floatingratecoupon.hpp>
27#include <ql/indexes/swapindex.hpp>
28#include <ql/time/schedule.hpp>
29
30namespace QuantExt {
31
32using namespace QuantLib;
33
35public:
36 /* indexFixing(), rate(), etc. refer to the adjusted cms index fixing.
37 The adjustment factor is defined as 1.0 if the duration is 0, otherwise it is
38 sum_i 1 / (1+S)^i where the sum runs over i = 1, ... , duration */
39 DurationAdjustedCmsCoupon(const Date& paymentDate, Real nominal, const Date& startDate, const Date& endDate,
40 Natural fixingDays, const QuantLib::ext::shared_ptr<SwapIndex>& index, Size duration = 0,
41 Real gearing = 1.0, Spread spread = 0.0, const Date& refPeriodStart = Date(),
42 const Date& refPeriodEnd = Date(), const DayCounter& dayCounter = DayCounter(),
43 bool isInArrears = false, const Date& exCouponDate = Date());
44 const QuantLib::ext::shared_ptr<SwapIndex>& swapIndex() const { return swapIndex_; }
45 Size duration() const;
46 Real durationAdjustment() const;
47 Rate indexFixing() const override;
48 void accept(AcyclicVisitor&) override;
49
50private:
51 QuantLib::ext::shared_ptr<SwapIndex> swapIndex_;
53};
54
56public:
57 DurationAdjustedCmsLeg(const Schedule& schedule, const QuantLib::ext::shared_ptr<SwapIndex>& swapIndex,
58 const Size duration);
60 DurationAdjustedCmsLeg& withNotionals(const std::vector<Real>& notionals);
62 DurationAdjustedCmsLeg& withPaymentAdjustment(BusinessDayConvention);
65 DurationAdjustedCmsLeg& withFixingDays(Natural fixingDays);
66 DurationAdjustedCmsLeg& withFixingDays(const std::vector<Natural>& fixingDays);
68 DurationAdjustedCmsLeg& withGearings(const std::vector<Real>& gearings);
69 DurationAdjustedCmsLeg& withSpreads(Spread spread);
70 DurationAdjustedCmsLeg& withSpreads(const std::vector<Spread>& spreads);
72 DurationAdjustedCmsLeg& withCaps(const std::vector<Rate>& caps);
74 DurationAdjustedCmsLeg& withFloors(const std::vector<Rate>& floors);
75 DurationAdjustedCmsLeg& inArrears(bool flag = true);
77 DurationAdjustedCmsLeg& withExCouponPeriod(const Period&, const Calendar&, BusinessDayConvention,
78 bool endOfMonth = false);
80
81 operator Leg() const;
82
83private:
84 Schedule schedule_;
85 QuantLib::ext::shared_ptr<SwapIndex> swapIndex_;
86 std::vector<Real> notionals_;
88 Natural paymentLag_;
90 BusinessDayConvention paymentAdjustment_;
91 std::vector<Natural> fixingDays_;
92 std::vector<Real> gearings_;
93 std::vector<Spread> spreads_;
94 std::vector<Rate> caps_, floors_;
98 BusinessDayConvention exCouponAdjustment_;
101};
102
103} // namespace QuantExt
const QuantLib::ext::shared_ptr< SwapIndex > & swapIndex() const
void accept(AcyclicVisitor &) override
QuantLib::ext::shared_ptr< SwapIndex > swapIndex_
DurationAdjustedCmsLeg & withPaymentCalendar(const Calendar &)
DurationAdjustedCmsLeg & withPaymentAdjustment(BusinessDayConvention)
DurationAdjustedCmsLeg & withZeroPayments(bool flag=true)
DurationAdjustedCmsLeg & withSpreads(Spread spread)
DurationAdjustedCmsLeg & withFixingDays(Natural fixingDays)
QuantLib::ext::shared_ptr< SwapIndex > swapIndex_
DurationAdjustedCmsLeg & withDuration(Size duration)
DurationAdjustedCmsLeg & withPaymentLag(Natural lag)
DurationAdjustedCmsLeg & withFloors(Rate floor)
DurationAdjustedCmsLeg & withNotionals(Real notional)
DurationAdjustedCmsLeg & withGearings(Real gearing)
DurationAdjustedCmsLeg & withExCouponPeriod(const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth=false)
DurationAdjustedCmsLeg & withPaymentDayCounter(const DayCounter &)
DurationAdjustedCmsLeg & inArrears(bool flag=true)
DurationAdjustedCmsLeg & withCaps(Rate cap)