QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
rangeaccrual.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
5 Copyright (C) 2006, 2007 Giorgio Facchinetti
6 Copyright (C) 2006, 2007 Mario Pucci
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 <http://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/*! \file rangeaccrual.hpp
23 \brief range-accrual coupon
24*/
25
26#ifndef quantlib_range_accrual_h
27#define quantlib_range_accrual_h
28
32#include <ql/time/schedule.hpp>
33#include <vector>
34
35namespace QuantLib {
36
37 class IborIndex;
38 class RangeAccrualPricer;
39
41
42 public:
43 RangeAccrualFloatersCoupon(const Date& paymentDate,
45 const ext::shared_ptr<IborIndex>& index,
46 const Date& startDate,
47 const Date& endDate,
52 const Date& refPeriodStart,
53 const Date& refPeriodEnd,
54 ext::shared_ptr<Schedule> observationsSchedule,
57
58 Real startTime() const {return startTime_; }
59 Real endTime() const {return endTime_; }
60 Real lowerTrigger() const {return lowerTrigger_; }
61 Real upperTrigger() const {return upperTrigger_; }
63 const std::vector<Date>& observationDates() const {
64 return observationDates_;
65 }
66 const std::vector<Real>& observationTimes() const {
67 return observationTimes_;
68 }
69 ext::shared_ptr<Schedule> observationsSchedule() const { return observationsSchedule_; }
70
72 const Handle<YieldTermStructure>& discountCurve) const;
73 //! \name Visitability
74 //@{
75 void accept(AcyclicVisitor&) override;
76 //@}
77 private:
78
81
82 const ext::shared_ptr<Schedule> observationsSchedule_;
83 std::vector<Date> observationDates_;
84 std::vector<Real> observationTimes_;
86
89 };
90
92 public:
93 //! \name Observer interface
94 //@{
95 Rate swapletRate() const override;
96 Real capletPrice(Rate effectiveCap) const override;
97 Rate capletRate(Rate effectiveCap) const override;
98 Real floorletPrice(Rate effectiveFloor) const override;
99 Rate floorletRate(Rate effectiveFloor) const override;
100 void initialize(const FloatingRateCoupon& coupon) override;
101 //@}
102
103 protected:
108 std::vector<Real> observationTimeLags_; // d
109 std::vector<Real> observationTimes_; // U
110 std::vector<Real> initialValues_;
118
119 };
120
122
123 public:
124 RangeAccrualPricerByBgm(Real correlation,
125 ext::shared_ptr<SmileSection> smilesOnExpiry,
126 ext::shared_ptr<SmileSection> smilesOnPayment,
127 bool withSmile,
128 bool byCallSpread);
129 //! \name Observer interface
130 //@{
131 Real swapletPrice() const override;
132 //@}
133
134 protected:
135
136 Real drift(Real U, Real lambdaS, Real lambdaT, Real correlation) const;
137 Real derDriftDerLambdaS(Real U, Real lambdaS, Real lambdaT,
138 Real correlation) const;
139 Real derDriftDerLambdaT(Real U, Real lambdaS, Real lambdaT,
140 Real correlation) const;
141
142 Real lambda(Real U, Real lambdaS, Real lambdaT) const;
145
146 std::vector<Real> driftsOverPeriod(Real U, Real lambdaS, Real lambdaT,
147 Real correlation) const;
148 std::vector<Real> lambdasOverPeriod(Real U, Real lambdaS,
149 Real lambdaT) const;
150
151 Real digitalRangePrice(Real lowerTrigger,
152 Real upperTrigger,
153 Real initialValue,
154 Real expiry,
155 Real deflator) const;
156
157 Real digitalPrice(Real strike,
158 Real initialValue,
159 Real expiry,
160 Real deflator) const;
161
163 Real initialValue,
164 Real expiry,
165 Real deflator) const;
166
168 Real initialValue,
169 Real expiry,
170 Real deflator) const;
171
172 Real callSpreadPrice(Real previousInitialValue,
173 Real nextInitialValue,
174 Real previousStrike,
175 Real nextStrike,
176 Real deflator,
177 Real previousVariance,
178 Real nextVariance) const;
179
181 Real initialValue,
182 Real expiry,
183 Real deflator) const;
184
185 private:
186 Real correlation_; // correlation between L(S) and L(T)
189
190 ext::shared_ptr<SmileSection> smilesOnExpiry_;
191 ext::shared_ptr<SmileSection> smilesOnPayment_;
192 Real eps_ = 1.0e-8;
193 };
194
195
196 //! helper class building a sequence of range-accrual floating-rate coupons
198 public:
199 RangeAccrualLeg(Schedule schedule, ext::shared_ptr<IborIndex> index);
201 RangeAccrualLeg& withNotionals(const std::vector<Real>& notionals);
205 RangeAccrualLeg& withFixingDays(const std::vector<Natural>& fixingDays);
207 RangeAccrualLeg& withGearings(const std::vector<Real>& gearings);
209 RangeAccrualLeg& withSpreads(const std::vector<Spread>& spreads);
211 RangeAccrualLeg& withLowerTriggers(const std::vector<Rate>& triggers);
213 RangeAccrualLeg& withUpperTriggers(const std::vector<Rate>& triggers);
216 operator Leg() const;
217 private:
219 ext::shared_ptr<IborIndex> index_;
220 std::vector<Real> notionals_;
223 std::vector<Natural> fixingDays_;
224 std::vector<Real> gearings_;
225 std::vector<Spread> spreads_;
226 std::vector<Rate> lowerTriggers_, upperTriggers_;
229 };
230
231}
232
233
234#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
virtual Real nominal() const
Definition: coupon.hpp:100
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
base floating-rate coupon class
Natural fixingDays() const
fixing days
Real gearing() const
index gearing, i.e. multiplicative coefficient for the index
DayCounter dayCounter() const override
day counter for accrual calculation
const ext::shared_ptr< InterestRateIndex > & index() const
floating index
Spread spread() const
spread paid over the fixing of the underlying index
generic pricer for floating-rate coupons
Shared handle to an observable.
Definition: handle.hpp:41
const std::vector< Real > & observationTimes() const
Real priceWithoutOptionality(const Handle< YieldTermStructure > &discountCurve) const
void accept(AcyclicVisitor &) override
ext::shared_ptr< Schedule > observationsSchedule() const
const std::vector< Date > & observationDates() const
const ext::shared_ptr< Schedule > observationsSchedule_
helper class building a sequence of range-accrual floating-rate coupons
BusinessDayConvention paymentAdjustment_
RangeAccrualLeg & withPaymentDayCounter(const DayCounter &)
RangeAccrualLeg & withGearings(Real gearing)
RangeAccrualLeg & withObservationConvention(BusinessDayConvention)
RangeAccrualLeg & withLowerTriggers(Rate trigger)
RangeAccrualLeg & withFixingDays(Natural fixingDays)
RangeAccrualLeg & withObservationTenor(const Period &)
std::vector< Real > notionals_
std::vector< Spread > spreads_
std::vector< Rate > lowerTriggers_
std::vector< Rate > upperTriggers_
RangeAccrualLeg & withUpperTriggers(Rate trigger)
RangeAccrualLeg & withPaymentAdjustment(BusinessDayConvention)
std::vector< Natural > fixingDays_
RangeAccrualLeg & withNotionals(Real notional)
std::vector< Real > gearings_
RangeAccrualLeg & withSpreads(Spread spread)
BusinessDayConvention observationConvention_
ext::shared_ptr< IborIndex > index_
Real drift(Real U, Real lambdaS, Real lambdaT, Real correlation) const
std::vector< Real > driftsOverPeriod(Real U, Real lambdaS, Real lambdaT, Real correlation) const
Real derDriftDerLambdaS(Real U, Real lambdaS, Real lambdaT, Real correlation) const
Real digitalRangePrice(Real lowerTrigger, Real upperTrigger, Real initialValue, Real expiry, Real deflator) const
Real derDriftDerLambdaT(Real U, Real lambdaS, Real lambdaT, Real correlation) const
Real callSpreadPrice(Real previousInitialValue, Real nextInitialValue, Real previousStrike, Real nextStrike, Real deflator, Real previousVariance, Real nextVariance) const
ext::shared_ptr< SmileSection > smilesOnPayment_
Real derLambdaDerLambdaT(Real U) const
Real lambda(Real U, Real lambdaS, Real lambdaT) const
Real derLambdaDerLambdaS(Real U) const
std::vector< Real > lambdasOverPeriod(Real U, Real lambdaS, Real lambdaT) const
ext::shared_ptr< SmileSection > smilesOnExpiry_
Real digitalPriceWithSmile(Real strike, Real initialValue, Real expiry, Real deflator) const
Real smileCorrection(Real strike, Real initialValue, Real expiry, Real deflator) const
Real digitalPriceWithoutSmile(Real strike, Real initialValue, Real expiry, Real deflator) const
Real swapletPrice() const override
Real digitalPrice(Real strike, Real initialValue, Real expiry, Real deflator) const
std::vector< Real > observationTimes_
Real capletPrice(Rate effectiveCap) const override
Rate floorletRate(Rate effectiveFloor) const override
std::vector< Real > initialValues_
void initialize(const FloatingRateCoupon &coupon) override
std::vector< Real > observationTimeLags_
const RangeAccrualFloatersCoupon * coupon_
Real floorletPrice(Rate effectiveFloor) const override
Rate swapletRate() const override
Rate capletRate(Rate effectiveCap) const override
Payment schedule.
Definition: schedule.hpp:40
Coupon pricers.
Coupon paying a variable index-based rate.
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
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
date schedule
Smile section base class.