/src/quantlib/ql/cashflows/digitalcmscoupon.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2007 Cristina Duminuco |
5 | | Copyright (C) 2007 Giorgio Facchinetti |
6 | | Copyright (C) 2007 StatPro Italia srl |
7 | | |
8 | | This file is part of QuantLib, a free-software/open-source library |
9 | | for financial quantitative analysts and developers - http://quantlib.org/ |
10 | | |
11 | | QuantLib is free software: you can redistribute it and/or modify it |
12 | | under the terms of the QuantLib license. You should have received a |
13 | | copy of the license along with this program; if not, please email |
14 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
15 | | <https://www.quantlib.org/license.shtml>. |
16 | | |
17 | | This program is distributed in the hope that it will be useful, but WITHOUT |
18 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
19 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
20 | | */ |
21 | | |
22 | | #include <ql/cashflows/cashflowvectors.hpp> |
23 | | #include <ql/cashflows/digitalcmscoupon.hpp> |
24 | | #include <utility> |
25 | | |
26 | | namespace QuantLib { |
27 | | |
28 | | DigitalCmsCoupon::DigitalCmsCoupon( |
29 | | const ext::shared_ptr<CmsCoupon>& underlying, |
30 | | Rate callStrike, |
31 | | Position::Type callPosition, |
32 | | bool isCallATMIncluded, |
33 | | Rate callDigitalPayoff, |
34 | | Rate putStrike, |
35 | | Position::Type putPosition, |
36 | | bool isPutATMIncluded, |
37 | | Rate putDigitalPayoff, |
38 | | const ext::shared_ptr<DigitalReplication>& replication, |
39 | | bool nakedOption) |
40 | 0 | : DigitalCoupon(underlying, callStrike, callPosition, isCallATMIncluded, |
41 | 0 | callDigitalPayoff, putStrike, putPosition, |
42 | 0 | isPutATMIncluded, putDigitalPayoff, replication, nakedOption) {} Unexecuted instantiation: QuantLib::DigitalCmsCoupon::DigitalCmsCoupon(boost::shared_ptr<QuantLib::CmsCoupon> const&, double, QuantLib::Position::Type, bool, double, double, QuantLib::Position::Type, bool, double, boost::shared_ptr<QuantLib::DigitalReplication> const&, bool) Unexecuted instantiation: QuantLib::DigitalCmsCoupon::DigitalCmsCoupon(boost::shared_ptr<QuantLib::CmsCoupon> const&, double, QuantLib::Position::Type, bool, double, double, QuantLib::Position::Type, bool, double, boost::shared_ptr<QuantLib::DigitalReplication> const&, bool) |
43 | | |
44 | 0 | void DigitalCmsCoupon::accept(AcyclicVisitor& v) { |
45 | 0 | typedef DigitalCoupon super; |
46 | 0 | auto* v1 = dynamic_cast<Visitor<DigitalCmsCoupon>*>(&v); |
47 | 0 | if (v1 != nullptr) |
48 | 0 | v1->visit(*this); |
49 | 0 | else |
50 | 0 | super::accept(v); |
51 | 0 | } |
52 | | |
53 | | |
54 | | DigitalCmsLeg::DigitalCmsLeg(Schedule schedule, ext::shared_ptr<SwapIndex> index) |
55 | 0 | : schedule_(std::move(schedule)), index_(std::move(index)) {} |
56 | | |
57 | 0 | DigitalCmsLeg& DigitalCmsLeg::withNotionals(Real notional) { |
58 | 0 | notionals_ = std::vector<Real>(1,notional); |
59 | 0 | return *this; |
60 | 0 | } |
61 | | |
62 | | DigitalCmsLeg& DigitalCmsLeg::withNotionals( |
63 | 0 | const std::vector<Real>& notionals) { |
64 | 0 | notionals_ = notionals; |
65 | 0 | return *this; |
66 | 0 | } |
67 | | |
68 | | DigitalCmsLeg& DigitalCmsLeg::withPaymentDayCounter( |
69 | 0 | const DayCounter& dayCounter) { |
70 | 0 | paymentDayCounter_ = dayCounter; |
71 | 0 | return *this; |
72 | 0 | } |
73 | | |
74 | | DigitalCmsLeg& DigitalCmsLeg::withPaymentAdjustment( |
75 | 0 | BusinessDayConvention convention) { |
76 | 0 | paymentAdjustment_ = convention; |
77 | 0 | return *this; |
78 | 0 | } |
79 | | |
80 | 0 | DigitalCmsLeg& DigitalCmsLeg::withFixingDays(Natural fixingDays) { |
81 | 0 | fixingDays_ = std::vector<Natural>(1,fixingDays); |
82 | 0 | return *this; |
83 | 0 | } |
84 | | |
85 | | DigitalCmsLeg& DigitalCmsLeg::withFixingDays( |
86 | 0 | const std::vector<Natural>& fixingDays) { |
87 | 0 | fixingDays_ = fixingDays; |
88 | 0 | return *this; |
89 | 0 | } |
90 | | |
91 | 0 | DigitalCmsLeg& DigitalCmsLeg::withGearings(Real gearing) { |
92 | 0 | gearings_ = std::vector<Real>(1,gearing); |
93 | 0 | return *this; |
94 | 0 | } |
95 | | |
96 | | DigitalCmsLeg& DigitalCmsLeg::withGearings( |
97 | 0 | const std::vector<Real>& gearings) { |
98 | 0 | gearings_ = gearings; |
99 | 0 | return *this; |
100 | 0 | } |
101 | | |
102 | 0 | DigitalCmsLeg& DigitalCmsLeg::withSpreads(Spread spread) { |
103 | 0 | spreads_ = std::vector<Spread>(1,spread); |
104 | 0 | return *this; |
105 | 0 | } |
106 | | |
107 | | DigitalCmsLeg& DigitalCmsLeg::withSpreads( |
108 | 0 | const std::vector<Spread>& spreads) { |
109 | 0 | spreads_ = spreads; |
110 | 0 | return *this; |
111 | 0 | } |
112 | | |
113 | 0 | DigitalCmsLeg& DigitalCmsLeg::inArrears(bool flag) { |
114 | 0 | inArrears_ = flag; |
115 | 0 | return *this; |
116 | 0 | } |
117 | | |
118 | 0 | DigitalCmsLeg& DigitalCmsLeg::withCallStrikes(Rate strike) { |
119 | 0 | callStrikes_ = std::vector<Rate>(1,strike); |
120 | 0 | return *this; |
121 | 0 | } |
122 | | |
123 | | DigitalCmsLeg& DigitalCmsLeg::withCallStrikes( |
124 | 0 | const std::vector<Rate>& strikes) { |
125 | 0 | callStrikes_ = strikes; |
126 | 0 | return *this; |
127 | 0 | } |
128 | | |
129 | 0 | DigitalCmsLeg& DigitalCmsLeg::withLongCallOption(Position::Type type) { |
130 | 0 | longCallOption_ = type; |
131 | 0 | return *this; |
132 | 0 | } |
133 | | |
134 | 0 | DigitalCmsLeg& DigitalCmsLeg::withCallATM(bool flag) { |
135 | 0 | callATM_ = flag; |
136 | 0 | return *this; |
137 | 0 | } |
138 | | |
139 | 0 | DigitalCmsLeg& DigitalCmsLeg::withCallPayoffs(Rate payoff) { |
140 | 0 | callPayoffs_ = std::vector<Rate>(1,payoff); |
141 | 0 | return *this; |
142 | 0 | } |
143 | | |
144 | | DigitalCmsLeg& DigitalCmsLeg::withCallPayoffs( |
145 | 0 | const std::vector<Rate>& payoffs) { |
146 | 0 | callPayoffs_ = payoffs; |
147 | 0 | return *this; |
148 | 0 | } |
149 | | |
150 | 0 | DigitalCmsLeg& DigitalCmsLeg::withPutStrikes(Rate strike) { |
151 | 0 | putStrikes_ = std::vector<Rate>(1,strike); |
152 | 0 | return *this; |
153 | 0 | } |
154 | | |
155 | | DigitalCmsLeg& DigitalCmsLeg::withPutStrikes( |
156 | 0 | const std::vector<Rate>& strikes) { |
157 | 0 | putStrikes_ = strikes; |
158 | 0 | return *this; |
159 | 0 | } |
160 | | |
161 | 0 | DigitalCmsLeg& DigitalCmsLeg::withLongPutOption(Position::Type type) { |
162 | 0 | longPutOption_ = type; |
163 | 0 | return *this; |
164 | 0 | } |
165 | | |
166 | 0 | DigitalCmsLeg& DigitalCmsLeg::withPutATM(bool flag) { |
167 | 0 | putATM_ = flag; |
168 | 0 | return *this; |
169 | 0 | } |
170 | | |
171 | 0 | DigitalCmsLeg& DigitalCmsLeg::withPutPayoffs(Rate payoff) { |
172 | 0 | putPayoffs_ = std::vector<Rate>(1,payoff); |
173 | 0 | return *this; |
174 | 0 | } |
175 | | |
176 | | DigitalCmsLeg& DigitalCmsLeg::withPutPayoffs( |
177 | 0 | const std::vector<Rate>& payoffs) { |
178 | 0 | putPayoffs_ = payoffs; |
179 | 0 | return *this; |
180 | 0 | } |
181 | | |
182 | | DigitalCmsLeg& DigitalCmsLeg::withReplication( |
183 | 0 | const ext::shared_ptr<DigitalReplication>& replication) { |
184 | 0 | replication_ = replication; |
185 | 0 | return *this; |
186 | 0 | } |
187 | | |
188 | 0 | DigitalCmsLeg& DigitalCmsLeg::withNakedOption(bool nakedOption) { |
189 | 0 | nakedOption_ = nakedOption; |
190 | 0 | return *this; |
191 | 0 | } |
192 | | |
193 | 0 | DigitalCmsLeg::operator Leg() const { |
194 | 0 | return FloatingDigitalLeg<SwapIndex, CmsCoupon, DigitalCmsCoupon>( |
195 | 0 | schedule_, notionals_, index_, paymentDayCounter_, |
196 | 0 | paymentAdjustment_, fixingDays_, |
197 | 0 | gearings_, spreads_, inArrears_, |
198 | 0 | callStrikes_, longCallOption_, |
199 | 0 | callATM_, callPayoffs_, |
200 | 0 | putStrikes_, longPutOption_, |
201 | 0 | putATM_, putPayoffs_, |
202 | 0 | replication_, nakedOption_); |
203 | 0 | } |
204 | | |
205 | | } |