QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
blackscholesprocess.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) 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
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 */
55 public:
60 const ext::shared_ptr<discretization>& d =
61 ext::shared_ptr<discretization>(new EulerDiscretization),
62 bool forceDiscretization = false);
63
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;
99 //@}
100 private:
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 */
124 public:
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 */
145 public:
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 */
169 public:
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 */
193 public:
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
Black volatility term structure base classes.
Black (1976) stochastic process.
Merton (1973) extension to the Black-Scholes stochastic process.
Black-Scholes (1973) stochastic process.
Concrete date class.
Definition: date.hpp:125
Euler discretization for stochastic processes.
Garman-Kohlhagen (1983) stochastic process.
Generalized Black-Scholes stochastic process.
Real apply(Real x0, Real dx) const override
const Handle< Quote > & stateVariable() const
const Handle< LocalVolTermStructure > & localVolatility() const
RelinkableHandle< LocalVolTermStructure > localVolatility_
Handle< LocalVolTermStructure > externalLocalVolTS_
Handle< BlackVolTermStructure > blackVolatility_
const Handle< YieldTermStructure > & dividendYield() const
Time time(const Date &) const override
Real diffusion(Time t, Real x) const override
Real stdDeviation(Time t0, Real x0, Time dt) const override
Real evolve(Time t0, Real x0, Time dt, Real dw) const override
Real drift(Time t, Real x) const override
Real expectation(Time t0, Real x0, Time dt) const override
const Handle< BlackVolTermStructure > & blackVolatility() const
Real x0() const override
returns the initial value of the state variable
const Handle< YieldTermStructure > & riskFreeRate() const
Shared handle to an observable.
Definition: handle.hpp:41
Relinkable handle to an observable.
Definition: handle.hpp:117
1-dimensional stochastic process
const DefaultType & t
Euler discretization for stochastic processes.
Date d
LinearInterpolation variance
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Local volatility term structure base class.
Definition: any.hpp:35
purely virtual base class for market observables
stochastic processes
Interest-rate term structure.