QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
stickyratchet.hpp
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) 2007 Marco Bianchetti
5 Copyright (C) 2007 Giorgio Facchinetti
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file stickyratchet.hpp
22 \brief Payoffs for double nested options of sticky or ratchet type
23*/
24
25#ifndef quantlib_stickyratchet_hpp
26#define quantlib_stickyratchet_hpp
27
28#include <ql/option.hpp>
29#include <ql/payoff.hpp>
30
31namespace QuantLib {
32
33 class AcyclicVisitor;
34 //! Intermediate class for single/double sticky/ratchet payoffs.
35 // initialValues can be a (forward) rate or a coupon/accrualFactor
37 public:
39 Real gearing1, Real gearing2, Real gearing3,
40 Real spread1, Real spread2, Real spread3,
41 Real initialValue1, Real initialValue2,
42 Real accrualFactor)
43 : type1_(type1), type2_(type2),
44 gearing1_(gearing1), gearing2_(gearing2), gearing3_(gearing3),
45 spread1_(spread1), spread2_(spread2), spread3_(spread3),
46 initialValue1_(initialValue1), initialValue2_(initialValue2),
47 accrualFactor_(accrualFactor) {}
48 //! \name Payoff interface
49 //@{
50 std::string name() const override;
51 Real operator()(Real forward) const override;
52 std::string description() const override;
53 void accept(AcyclicVisitor&) override;
54 //@}
55 protected:
60 };
61
62 //! Ratchet payoff (single option)
64 public:
65 RatchetPayoff(Real gearing1, Real gearing2,
66 Real spread1, Real spread2,
67 Real initialValue, Real accrualFactor)
68 : DoubleStickyRatchetPayoff(-1.0, 0.0,
69 gearing1, 0.0, gearing2,
70 spread1, 0.0, spread2,
71 initialValue, 0.0,
72 accrualFactor) {}
73 //! \name Payoff interface
74 //@{
75 std::string name() const override { return "Ratchet"; }
76 //@}
77 };
78
79 //! Sticky payoff (single option)
81 public:
82 StickyPayoff(Real gearing1, Real gearing2,
83 Real spread1, Real spread2,
84 Real initialValue, Real accrualFactor)
85 : DoubleStickyRatchetPayoff(+1.0, 0.0,
86 gearing1, 0.0, gearing2,
87 spread1, 0.0, spread2,
88 initialValue, 0.0,
89 accrualFactor) {}
90 //! \name Payoff interface
91 //@{
92 std::string name() const override { return "Sticky"; }
93 //@}
94 };
95
96 //! RatchetMax payoff (double option)
98 public:
99 RatchetMaxPayoff(Real gearing1, Real gearing2, Real gearing3,
100 Real spread1, Real spread2, Real spread3,
101 Real initialValue1, Real initialValue2,
102 Real accrualFactor)
103 : DoubleStickyRatchetPayoff(-1.0, -1.0,
104 gearing1, gearing2, gearing3,
105 spread1, spread2, spread3,
106 initialValue1, initialValue2,
107 accrualFactor) {}
108 //! \name Payoff interface
109 //@{
110 std::string name() const override { return "RatchetMax"; }
111 //@}
112 };
113
114 //! RatchetMin payoff (double option)
116 public:
117 RatchetMinPayoff(Real gearing1, Real gearing2, Real gearing3,
118 Real spread1, Real spread2, Real spread3,
119 Real initialValue1, Real initialValue2,
120 Real accrualFactor)
121 : DoubleStickyRatchetPayoff(-1.0, +1.0,
122 gearing1, gearing2, gearing3,
123 spread1, spread2, spread3,
124 initialValue1, initialValue2,
125 accrualFactor) {}
126 //! \name Payoff interface
127 //@{
128 std::string name() const override { return "RatchetMin"; }
129 //@}
130 };
131
132 //! StickyMax payoff (double option)
134 public:
135 StickyMaxPayoff(Real gearing1, Real gearing2, Real gearing3,
136 Real spread1, Real spread2, Real spread3,
137 Real initialValue1, Real initialValue2,
138 Real accrualFactor)
139 : DoubleStickyRatchetPayoff(+1.0, -1.0,
140 gearing1, gearing2, gearing3,
141 spread1, spread2, spread3,
142 initialValue1, initialValue2,
143 accrualFactor) {}
144 //! \name Payoff interface
145 //@{
146 std::string name() const override { return "StickyMax"; }
147 //@}
148 };
149
150 //! StickyMin payoff (double option)
152 public:
153 StickyMinPayoff(Real gearing1, Real gearing2, Real gearing3,
154 Real spread1, Real spread2, Real spread3,
155 Real initialValue1, Real initialValue2,
156 Real accrualFactor)
157 : DoubleStickyRatchetPayoff(+1.0, +1.0,
158 gearing1, gearing2, gearing3,
159 spread1, spread2, spread3,
160 initialValue1, initialValue2,
161 accrualFactor) {}
162 //! \name Payoff interface
163 //@{
164 std::string name() const override { return "StickyMin"; }
165 //@}
166 };
167
168/*---------------------------------------------------------------------------------
169 // Old code for single sticky/ratchet payoffs,
170 // superated by DoubleStickyRatchetPayoff class above
171
172 //! Intermediate class for sticky/ratchet payoffs
173 // initialValue can be a (forward) rate or a coupon/accrualFactor
174 class StickyRatchetPayoff : public Payoff {
175 public:
176 StickyRatchetPayoff(Real type,
177 Real gearing1, Real gearing2,
178 Real spread1, Real spread2,
179 Real initialValue, Real accrualFactor)
180 : type_(type), gearing1_(gearing1), gearing2_(gearing2),
181 spread1_(spread1), spread2_(spread2), initialValue_(initialValue),
182 accrualFactor_(accrualFactor) {}
183 //! \name Payoff interface
184 //@{
185 Real operator()(Real forward) const;
186 std::string description() const;
187 virtual void accept(AcyclicVisitor&);
188 //@}
189 protected:
190 Real type_;
191 Real gearing1_, gearing2_;
192 Real spread1_, spread2_;
193 Real initialValue_, accrualFactor_;
194 };
195
196 //! Ratchet_2 payoff
197 class RatchetPayoff_2 : public StickyRatchetPayoff {
198 public:
199 RatchetPayoff_2(Real gearing1, Real gearing2,
200 Real spread1, Real spread2,
201 Real initialValue, Real accrualFactor)
202 : StickyRatchetPayoff(-1,
203 gearing1, gearing2,
204 spread1, spread2,
205 initialValue, accrualFactor) {}
206 //! \name Payoff interface
207 //@{
208 std::string name() const { return "Ratchet";}
209 //@}
210 };
211
212 //! Sticky_2 payoff
213 class StickyPayoff_2 : public StickyRatchetPayoff {
214 public:
215 StickyPayoff_2(Real gearing1, Real gearing2,
216 Real spread1, Real spread2,
217 Real initialValue, Real accrualFactor)
218 : StickyRatchetPayoff(+1,
219 gearing1, gearing2,
220 spread1, spread2,
221 initialValue, accrualFactor) {}
222 //! \name Payoff interface
223 //@{
224 std::string name() const { return "Sticky";}
225 //@}
226 };
227-----------------------------------------------------------------------------*/
228
229}
230
231#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Intermediate class for single/double sticky/ratchet payoffs.
DoubleStickyRatchetPayoff(Real type1, Real type2, Real gearing1, Real gearing2, Real gearing3, Real spread1, Real spread2, Real spread3, Real initialValue1, Real initialValue2, Real accrualFactor)
std::string description() const override
void accept(AcyclicVisitor &) override
std::string name() const override
Real operator()(Real forward) const override
Abstract base class for option payoffs.
Definition: payoff.hpp:36
RatchetMax payoff (double option)
std::string name() const override
RatchetMaxPayoff(Real gearing1, Real gearing2, Real gearing3, Real spread1, Real spread2, Real spread3, Real initialValue1, Real initialValue2, Real accrualFactor)
RatchetMin payoff (double option)
RatchetMinPayoff(Real gearing1, Real gearing2, Real gearing3, Real spread1, Real spread2, Real spread3, Real initialValue1, Real initialValue2, Real accrualFactor)
std::string name() const override
Ratchet payoff (single option)
RatchetPayoff(Real gearing1, Real gearing2, Real spread1, Real spread2, Real initialValue, Real accrualFactor)
std::string name() const override
StickyMax payoff (double option)
StickyMaxPayoff(Real gearing1, Real gearing2, Real gearing3, Real spread1, Real spread2, Real spread3, Real initialValue1, Real initialValue2, Real accrualFactor)
std::string name() const override
StickyMin payoff (double option)
std::string name() const override
StickyMinPayoff(Real gearing1, Real gearing2, Real gearing3, Real spread1, Real spread2, Real spread3, Real initialValue1, Real initialValue2, Real accrualFactor)
Sticky payoff (single option)
std::string name() const override
StickyPayoff(Real gearing1, Real gearing2, Real spread1, Real spread2, Real initialValue, Real accrualFactor)
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
Base option class.
Option payoff classes.