QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
digitalcmsspreadcoupon.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2015 Peter Caspers
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
22#include <utility>
23
24namespace QuantLib {
25
27 const ext::shared_ptr<CmsSpreadCoupon>& underlying,
28 Rate callStrike,
29 Position::Type callPosition,
30 bool isCallATMIncluded,
31 Rate callDigitalPayoff,
32 Rate putStrike,
33 Position::Type putPosition,
34 bool isPutATMIncluded,
35 Rate putDigitalPayoff,
36 const ext::shared_ptr<DigitalReplication>& replication,
37 bool nakedOption)
38 : DigitalCoupon(underlying, callStrike, callPosition, isCallATMIncluded,
39 callDigitalPayoff, putStrike, putPosition,
40 isPutATMIncluded, putDigitalPayoff, replication, nakedOption) {}
41
43 typedef DigitalCoupon super;
44 auto* v1 = dynamic_cast<Visitor<DigitalCmsSpreadCoupon>*>(&v);
45 if (v1 != nullptr)
46 v1->visit(*this);
47 else
48 super::accept(v);
49 }
50
51
53 ext::shared_ptr<SwapSpreadIndex> index)
54 : schedule_(std::move(schedule)), index_(std::move(index)) {}
55
57 notionals_ = std::vector<Real>(1,notional);
58 return *this;
59 }
60
62 const std::vector<Real>& notionals) {
63 notionals_ = notionals;
64 return *this;
65 }
66
68 const DayCounter& dayCounter) {
69 paymentDayCounter_ = dayCounter;
70 return *this;
71 }
72
74 BusinessDayConvention convention) {
75 paymentAdjustment_ = convention;
76 return *this;
77 }
78
80 fixingDays_ = std::vector<Natural>(1,fixingDays);
81 return *this;
82 }
83
85 const std::vector<Natural>& fixingDays) {
86 fixingDays_ = fixingDays;
87 return *this;
88 }
89
91 gearings_ = std::vector<Real>(1,gearing);
92 return *this;
93 }
94
96 const std::vector<Real>& gearings) {
97 gearings_ = gearings;
98 return *this;
99 }
100
102 spreads_ = std::vector<Spread>(1,spread);
103 return *this;
104 }
105
107 const std::vector<Spread>& spreads) {
108 spreads_ = spreads;
109 return *this;
110 }
111
113 inArrears_ = flag;
114 return *this;
115 }
116
118 callStrikes_ = std::vector<Rate>(1,strike);
119 return *this;
120 }
121
123 const std::vector<Rate>& strikes) {
124 callStrikes_ = strikes;
125 return *this;
126 }
127
129 longCallOption_ = type;
130 return *this;
131 }
132
134 callATM_ = flag;
135 return *this;
136 }
137
139 callPayoffs_ = std::vector<Rate>(1,payoff);
140 return *this;
141 }
142
144 const std::vector<Rate>& payoffs) {
145 callPayoffs_ = payoffs;
146 return *this;
147 }
148
150 putStrikes_ = std::vector<Rate>(1,strike);
151 return *this;
152 }
153
155 const std::vector<Rate>& strikes) {
156 putStrikes_ = strikes;
157 return *this;
158 }
159
161 longPutOption_ = type;
162 return *this;
163 }
164
166 putATM_ = flag;
167 return *this;
168 }
169
171 putPayoffs_ = std::vector<Rate>(1,payoff);
172 return *this;
173 }
174
176 const std::vector<Rate>& payoffs) {
177 putPayoffs_ = payoffs;
178 return *this;
179 }
180
182 const ext::shared_ptr<DigitalReplication>& replication) {
183 replication_ = replication;
184 return *this;
185 }
186
188 replication_ = ext::make_shared<DigitalReplication>();
189 return *this;
190 }
191
193 nakedOption_ = nakedOption;
194 return *this;
195 }
196
197 DigitalCmsSpreadLeg::operator Leg() const {
198 return FloatingDigitalLeg<SwapSpreadIndex, CmsSpreadCoupon, DigitalCmsSpreadCoupon>(
199 schedule_, notionals_, index_, paymentDayCounter_,
200 paymentAdjustment_, fixingDays_,
201 gearings_, spreads_, inArrears_,
202 callStrikes_, longCallOption_,
203 callATM_, callPayoffs_,
204 putStrikes_, longPutOption_,
205 putATM_, putPayoffs_,
206 replication_, nakedOption_);
207 }
208
209}
Cash flow vector builders.
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
day counter class
Definition: daycounter.hpp:44
void accept(AcyclicVisitor &) override
DigitalCmsSpreadCoupon(const ext::shared_ptr< CmsSpreadCoupon > &underlying, Rate callStrike=Null< Rate >(), Position::Type callPosition=Position::Long, bool isCallATMIncluded=false, Rate callDigitalPayoff=Null< Rate >(), Rate putStrike=Null< Rate >(), Position::Type putPosition=Position::Long, bool isPutATMIncluded=false, Rate putDigitalPayoff=Null< Rate >(), const ext::shared_ptr< DigitalReplication > &replication={}, bool nakedOption=false)
helper class building a sequence of digital ibor-rate coupons
DigitalCmsSpreadLeg & inArrears(bool flag=true)
DigitalCmsSpreadLeg & withPutATM(bool flag=true)
DigitalCmsSpreadLeg & withCallATM(bool flag=true)
BusinessDayConvention paymentAdjustment_
DigitalCmsSpreadLeg & withNakedOption(bool nakedOption=true)
DigitalCmsSpreadLeg & withCallStrikes(Rate strike)
DigitalCmsSpreadLeg & withPutPayoffs(Rate payoff)
DigitalCmsSpreadLeg & withPutStrikes(Rate strike)
DigitalCmsSpreadLeg & withGearings(Real gearing)
DigitalCmsSpreadLeg & withSpreads(Spread spread)
DigitalCmsSpreadLeg & withCallPayoffs(Rate payoff)
DigitalCmsSpreadLeg & withLongPutOption(Position::Type)
DigitalCmsSpreadLeg & withNotionals(Real notional)
DigitalCmsSpreadLeg & withFixingDays(Natural fixingDays)
DigitalCmsSpreadLeg & withLongCallOption(Position::Type)
DigitalCmsSpreadLeg & withPaymentAdjustment(BusinessDayConvention)
ext::shared_ptr< DigitalReplication > replication_
DigitalCmsSpreadLeg & withReplication()
DigitalCmsSpreadLeg & withPaymentDayCounter(const DayCounter &)
DigitalCmsSpreadLeg(Schedule schedule, ext::shared_ptr< SwapSpreadIndex > index)
Digital-payoff coupon.
Payment schedule.
Definition: schedule.hpp:40
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
Cms-spread-rate coupon with digital call/put option.
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Spread
spreads on interest rates
Definition: types.hpp:74
Real Rate
interest rates
Definition: types.hpp:70
ext::shared_ptr< QuantLib::Payoff > payoff
Definition: any.hpp:35
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
STL namespace.
ext::shared_ptr< BlackVolTermStructure > v