QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
digitalcoupon.hpp
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
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
25#ifndef quantlib_digital_coupon_hpp
26#define quantlib_digital_coupon_hpp
27
28#include <ql/cashflows/floatingratecoupon.hpp>
29#include <ql/cashflows/couponpricer.hpp>
30#include <ql/cashflows/replication.hpp>
31#include <ql/position.hpp>
32#include <ql/utilities/null.hpp>
33
34namespace QuantLib {
35
37
80 public:
82
83
84 DigitalCoupon(const ext::shared_ptr<FloatingRateCoupon>& underlying,
86 Position::Type callPosition = Position::Long,
87 bool isCallITMIncluded = false,
90 Position::Type putPosition = Position::Long,
91 bool isPutITMIncluded = false,
93 ext::shared_ptr<DigitalReplication> replication = {},
94 bool nakedOption = false);
95
97
99 void deepUpdate() override;
101
103 void performCalculations() const override;
105
107 Rate rate() const override;
108 Rate convexityAdjustment() const override;
110
111
113 Rate callStrike() const;
114 Rate putStrike() const;
115 Rate callDigitalPayoff() const;
116 Rate putDigitalPayoff() const;
117 bool hasPut() const { return hasPutStrike_; }
118 bool hasCall() const {return hasCallStrike_; }
119 bool hasCollar() const {return (hasCallStrike_ && hasPutStrike_); }
120 bool isLongPut() const { return (putCsi_==1.); }
121 bool isLongCall() const { return (callCsi_==1.); }
122 ext::shared_ptr<FloatingRateCoupon> underlying() const { return underlying_; }
126 Rate callOptionRate() const;
130 Rate putOptionRate() const;
132
134 void accept(AcyclicVisitor&) override;
135
136 void setPricer(const ext::shared_ptr<FloatingRateCouponPricer>& pricer) override {
137 if (pricer_ != nullptr)
139 pricer_ = pricer;
140 if (pricer_ != nullptr)
142 update();
143 underlying_->setPricer(pricer);
144 }
145
146 protected:
148
149
150 ext::shared_ptr<FloatingRateCoupon> underlying_;
176 bool hasPutStrike_ = false, hasCallStrike_ = false;
181
183 private:
184 Rate callPayoff() const;
185 Rate putPayoff() const;
186
187 };
188
189}
190
191#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Digital-payoff coupon.
Real callLeftEps_
the left and right gaps applied in payoff replication for call
void performCalculations() const override
Rate putDigitalPayoff_
digital put option payoff rate, if any
ext::shared_ptr< FloatingRateCoupon > underlying() const
void deepUpdate() override
bool isPutCashOrNothing_
digital put option type: if true, cash-or-nothing, if false asset-or-nothing
ext::shared_ptr< FloatingRateCoupon > underlying_
Rate rate() const override
accrued rate
bool isCallATMIncluded_
inclusion flag og the call payoff if the call option ends at-the-money
void accept(AcyclicVisitor &) override
bool isPutATMIncluded_
inclusion flag og the put payoff if the put option ends at-the-money
bool nakedOption_
underlying excluded from the payoff
Rate callStrike_
strike rate for the the call option
void setPricer(const ext::shared_ptr< FloatingRateCouponPricer > &pricer) override
bool isCallCashOrNothing_
digital call option type: if true, cash-or-nothing, if false asset-or-nothing
Real callCsi_
multiplicative factor of call payoff
Replication::Type replicationType_
Type of replication.
Rate callDigitalPayoff() const
Rate putStrike_
strike rate for the the put option
Rate callDigitalPayoff_
digital call option payoff rate, if any
Real putLeftEps_
the left and right gaps applied in payoff replication for put
Rate convexityAdjustment() const override
convexity adjustment
Real putCsi_
multiplicative factor of put payoff
base floating-rate coupon class
ext::shared_ptr< FloatingRateCouponPricer > pricer_
ext::shared_ptr< FloatingRateCouponPricer > pricer() const
void update() override
Definition: lazyobject.hpp:188
template class providing a null value for a given type.
Definition: null.hpp:76
Size unregisterWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:245
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35