1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb
5 Copyright (C) 2003 Ferdinando Ametrano
6 Copyright (C) 2004, 2005, 2006, 2007, 2009 StatPro Italia srl
7 Copyright (C) 2015 Peter Caspers
8
9 This file is part of QuantLib, a free-software/open-source library
10 for financial quantitative analysts and developers - http://quantlib.org/
11
12 QuantLib is free software: you can redistribute it and/or modify it
13 under the terms of the QuantLib license. You should have received a
14 copy of the license along with this program; if not, please email
15 <quantlib-dev@lists.sf.net>. The license is also available online at
16 <http://quantlib.org/license.shtml>.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the license for more details.
21*/
22
23/*! \file blackscholesprocess.hpp
24 \brief Black-Scholes processes
25*/
26
27#ifndef quantlib_black_scholes_process_hpp
28#define quantlib_black_scholes_process_hpp
29
30#include <ql/stochasticprocess.hpp>
31#include <ql/processes/eulerdiscretization.hpp>
32#include <ql/termstructures/yieldtermstructure.hpp>
33#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
34#include <ql/termstructures/volatility/equityfx/localvoltermstructure.hpp>
35#include <ql/quote.hpp>
36
37namespace QuantLib {
38
39 class LocalConstantVol;
40 class LocalVolCurve;
41
42 //! Generalized Black-Scholes stochastic process
43 /*! This class describes the stochastic process \f$ S \f$ governed by
44 \f[
45 d\ln S(t) = (r(t) - q(t) - \frac{\sigma(t, S)^2}{2}) dt
46 + \sigma dW_t.
47 \f]
48
49 \warning while the interface is expressed in terms of \f$ S \f$,
50 the internal calculations work on \f$ ln S \f$.
51
52 \ingroup processes
53 */
54 class GeneralizedBlackScholesProcess : public StochasticProcess1D {
55 public:
56 GeneralizedBlackScholesProcess(Handle<Quote> x0,
57 Handle<YieldTermStructure> dividendTS,
58 Handle<YieldTermStructure> riskFreeTS,
59 Handle<BlackVolTermStructure> blackVolTS,
60 const ext::shared_ptr<discretization>& d =
61 ext::shared_ptr<discretization>(new EulerDiscretization),
62 bool forceDiscretization = false);
63
64 GeneralizedBlackScholesProcess(Handle<Quote> x0,
65 Handle<YieldTermStructure> dividendTS,
66 Handle<YieldTermStructure> riskFreeTS,
67 Handle<BlackVolTermStructure> blackVolTS,
68 Handle<LocalVolTermStructure> localVolTS);
69
70 //! \name StochasticProcess1D interface
71 //@{
72 Real x0() const override;
73 /*! \todo revise extrapolation */
74 Real drift(Time t, Real x) const override;
75 /*! \todo revise extrapolation */
76 Real diffusion(Time t, Real x) const override;
77 Real apply(Real x0, Real dx) const override;
78 /*! \warning in general raises a "not implemented" exception.
79 It should be rewritten to return the expectation E(S)
80 of the process, not exp(E(log S)).
81 */
82 Real expectation(Time t0, Real x0, Time dt) const override;
83 Real stdDeviation(Time t0, Real x0, Time dt) const override;
84 Real variance(Time t0, Real x0, Time dt) const override;
85 Real evolve(Time t0, Real x0, Time dt, Real dw) const override;
86 //@}
87 Time time(const Date&) const override;
88 //! \name Observer interface
89 //@{
90 void update() override;
91 //@}
92 //! \name Inspectors
93 //@{
94 const Handle<Quote>& stateVariable() const;
95 const Handle<YieldTermStructure>& dividendYield() const;
96 const Handle<YieldTermStructure>& riskFreeRate() const;
97 const Handle<BlackVolTermStructure>& blackVolatility() const;
98 const Handle<LocalVolTermStructure>& localVolatility() const;
99 //@}
100 private:
101 Handle<Quote> x0_;
102 Handle<YieldTermStructure> riskFreeRate_, dividendYield_;
103 Handle<BlackVolTermStructure> blackVolatility_;
104 Handle<LocalVolTermStructure> externalLocalVolTS_;
105 bool forceDiscretization_;
106 bool hasExternalLocalVol_;
107 mutable RelinkableHandle<LocalVolTermStructure> localVolatility_;
108 mutable bool updated_, isStrikeIndependent_;
109 };
110
111 //! Black-Scholes (1973) stochastic process
112 /*! This class describes the stochastic process \f$ S \f$ for a stock
113 given by
114 \f[
115 d\ln S(t) = (r(t) - \frac{\sigma(t, S)^2}{2}) dt + \sigma dW_t.
116 \f]
117
118 \warning while the interface is expressed in terms of \f$ S \f$,
119 the internal calculations work on \f$ ln S \f$.
120
121 \ingroup processes
122 */
123 class BlackScholesProcess : public GeneralizedBlackScholesProcess {
124 public:
125 BlackScholesProcess(
126 const Handle<Quote>& x0,
127 const Handle<YieldTermStructure>& riskFreeTS,
128 const Handle<BlackVolTermStructure>& blackVolTS,
129 const ext::shared_ptr<discretization>& d =
130 ext::shared_ptr<discretization>(new EulerDiscretization),
131 bool forceDiscretization = false);
132 };
133
134 //! Merton (1973) extension to the Black-Scholes stochastic process
135 /*! This class describes the stochastic process ln(S) for a stock or
136 stock index paying a continuous dividend yield given by
137 \f[
138 d\ln S(t, S) = (r(t) - q(t) - \frac{\sigma(t, S)^2}{2}) dt
139 + \sigma dW_t.
140 \f]
141
142 \ingroup processes
143 */
144 class BlackScholesMertonProcess : public GeneralizedBlackScholesProcess {
145 public:
146 BlackScholesMertonProcess(
147 const Handle<Quote>& x0,
148 const Handle<YieldTermStructure>& dividendTS,
149 const Handle<YieldTermStructure>& riskFreeTS,
150 const Handle<BlackVolTermStructure>& blackVolTS,
151 const ext::shared_ptr<discretization>& d =
152 ext::shared_ptr<discretization>(new EulerDiscretization),
153 bool forceDiscretization = false);
154 };
155
156 //! Black (1976) stochastic process
157 /*! This class describes the stochastic process \f$ S \f$ for a
158 forward or futures contract given by
159 \f[
160 d\ln S(t) = -\frac{\sigma(t, S)^2}{2} dt + \sigma dW_t.
161 \f]
162
163 \warning while the interface is expressed in terms of \f$ S \f$,
164 the internal calculations work on \f$ ln S \f$.
165
166 \ingroup processes
167 */
168 class BlackProcess : public GeneralizedBlackScholesProcess {
169 public:
170 BlackProcess(
171 const Handle<Quote>& x0,
172 const Handle<YieldTermStructure>& riskFreeTS,
173 const Handle<BlackVolTermStructure>& blackVolTS,
174 const ext::shared_ptr<discretization>& d =
175 ext::shared_ptr<discretization>(new EulerDiscretization),
176 bool forceDiscretization = false);
177 };
178
179 //! Garman-Kohlhagen (1983) stochastic process
180 /*! This class describes the stochastic process \f$ S \f$ for an exchange
181 rate given by
182 \f[
183 d\ln S(t) = (r(t) - r_f(t) - \frac{\sigma(t, S)^2}{2}) dt
184 + \sigma dW_t.
185 \f]
186
187 \warning while the interface is expressed in terms of \f$ S \f$,
188 the internal calculations work on \f$ ln S \f$.
189
190 \ingroup processes
191 */
192 class GarmanKohlagenProcess : public GeneralizedBlackScholesProcess {
193 public:
194 GarmanKohlagenProcess(
195 const Handle<Quote>& x0,
196 const Handle<YieldTermStructure>& foreignRiskFreeTS,
197 const Handle<YieldTermStructure>& domesticRiskFreeTS,
198 const Handle<BlackVolTermStructure>& blackVolTS,
199 const ext::shared_ptr<discretization>& d =
200 ext::shared_ptr<discretization>(new EulerDiscretization),
201 bool forceDiscretization = false);
202 };
203
204}
205
206
207#endif
208

source code of quantlib/ql/processes/blackscholesprocess.hpp