QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
blackformula.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, 2004, 2005, 2006, 2008 Ferdinando Ametrano
6 Copyright (C) 2006 Mark Joshi
7 Copyright (C) 2006 StatPro Italia srl
8 Copyright (C) 2007 Cristina Duminuco
9 Copyright (C) 2007 Chiara Fornarola
10 Copyright (C) 2013 Gary Kennedy
11 Copyright (C) 2015 Peter Caspers
12 Copyright (C) 2017 Klaus Spanderen
13 Copyright (C) 2019 Wojciech Ślusarski
14 Copyright (C) 2020 Marcin Rybacki
15
16 This file is part of QuantLib, a free-software/open-source library
17 for financial quantitative analysts and developers - http://quantlib.org/
18
19 QuantLib is free software: you can redistribute it and/or modify it
20 under the terms of the QuantLib license. You should have received a
21 copy of the license along with this program; if not, please email
22 <quantlib-dev@lists.sf.net>. The license is also available online at
23 <http://quantlib.org/license.shtml>.
24
25 This program is distributed in the hope that it will be useful, but WITHOUT
26 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
27 FOR A PARTICULAR PURPOSE. See the license for more details.
28*/
29
30/*! \file blackformula.hpp
31 \brief Black formula
32*/
33
34#ifndef quantlib_blackformula_hpp
35#define quantlib_blackformula_hpp
36
38#include <ql/option.hpp>
39
40namespace QuantLib {
41
42 /*! Black 1976 formula
43 \warning instead of volatility it uses standard deviation,
44 i.e. volatility*sqrt(timeToMaturity)
45 */
47 Real strike,
48 Real forward,
49 Real stdDev,
50 Real discount = 1.0,
51 Real displacement = 0.0);
52
53 /*! Black 1976 formula
54 \warning instead of volatility it uses standard deviation,
55 i.e. volatility*sqrt(timeToMaturity)
56 */
57 Real blackFormula(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
58 Real forward,
59 Real stdDev,
60 Real discount = 1.0,
61 Real displacement = 0.0);
62
63 /*! Black 1976 model forward derivative
64 \warning instead of volatility it uses standard deviation,
65 i.e. volatility*sqrt(timeToMaturity)
66 */
68 Real strike,
69 Real forward,
70 Real stdDev,
71 Real discount = 1.0,
72 Real displacement = 0.0);
73
74 /*! Black 1976 model forward derivative
75 \warning instead of volatility it uses standard deviation,
76 i.e. volatility*sqrt(timeToMaturity)
77 */
78 Real blackFormulaForwardDerivative(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
79 Real forward,
80 Real stdDev,
81 Real discount = 1.0,
82 Real displacement = 0.0);
83
84 /*! Approximated Black 1976 implied standard deviation,
85 i.e. volatility*sqrt(timeToMaturity).
86
87 It is calculated using Brenner and Subrahmanyan (1988) and Feinstein
88 (1988) approximation for at-the-money forward option, with the
89 extended moneyness approximation by Corrado and Miller (1996)
90 */
92 Real strike,
93 Real forward,
94 Real blackPrice,
95 Real discount = 1.0,
96 Real displacement = 0.0);
97
98 /*! Approximated Black 1976 implied standard deviation,
99 i.e. volatility*sqrt(timeToMaturity).
100
101 It is calculated using Brenner and Subrahmanyan (1988) and Feinstein
102 (1988) approximation for at-the-money forward option, with the
103 extended moneyness approximation by Corrado and Miller (1996)
104 */
105 Real blackFormulaImpliedStdDevApproximation(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
106 Real forward,
107 Real blackPrice,
108 Real discount = 1.0,
109 Real displacement = 0.0);
110
111 /*! Approximated Black 1976 implied standard deviation,
112 i.e. volatility*sqrt(timeToMaturity).
113
114 It is calculated following "An improved approach to computing
115 implied volatility", Chambers, Nawalkha, The Financial Review,
116 2001, 89-100. The atm option price must be known to use this
117 method.
118 */
120 Real strike,
121 Real forward,
122 Real blackPrice,
123 Real blackAtmPrice,
124 Real discount = 1.0,
125 Real displacement = 0.0);
126
127 /*! Approximated Black 1976 implied standard deviation,
128 i.e. volatility*sqrt(timeToMaturity).
129
130 It is calculated following "An improved approach to computing
131 implied volatility", Chambers, Nawalkha, The Financial Review,
132 2001, 89-100. The atm option price must be known to use this
133 method.
134 */
135 Real blackFormulaImpliedStdDevChambers(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
136 Real forward,
137 Real blackPrice,
138 Real blackAtmPrice,
139 Real discount = 1.0,
140 Real displacement = 0.0);
141
142 /*! Approximated Black 1976 implied standard deviation,
143 i.e. volatility*sqrt(timeToMaturity).
144
145 It is calculated using
146
147 "An Explicit Implicit Volatility Formula"
148 R. Radoicic, D. Stefanica,
149 https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2908494
150
151 "Tighter Bounds for Implied Volatility",
152 J. Gatheral, I. Matic, R. Radoicic, D. Stefanica
153 https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2922742
154 */
156 Real strike,
157 Real forward,
158 Real blackPrice,
159 Real discount = 1.0,
160 Real displacement = 0.0);
161
162 Real blackFormulaImpliedStdDevApproximationRS(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
163 Real forward,
164 Real blackPrice,
165 Real discount = 1.0,
166 Real displacement = 0.0);
167
168
169 /*! Black 1976 implied standard deviation,
170 i.e. volatility*sqrt(timeToMaturity)
171 */
173 Real strike,
174 Real forward,
175 Real blackPrice,
176 Real discount = 1.0,
177 Real displacement = 0.0,
178 Real guess = Null<Real>(),
179 Real accuracy = 1.0e-6,
180 Natural maxIterations = 100);
181
182 /*! Black 1976 implied standard deviation,
183 i.e. volatility*sqrt(timeToMaturity)
184 */
185 Real blackFormulaImpliedStdDev(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
186 Real forward,
187 Real blackPrice,
188 Real discount = 1.0,
189 Real displacement = 0.0,
190 Real guess = Null<Real>(),
191 Real accuracy = 1.0e-6,
192 Natural maxIterations = 100);
193
194 /*! Black 1976 implied standard deviation,
195 i.e. volatility*sqrt(timeToMaturity)
196
197 "An Adaptive Successive Over-relaxation Method for Computing the
198 Black-Scholes Implied Volatility"
199 M. Li, http://mpra.ub.uni-muenchen.de/6867/
200
201
202 Starting point of the iteration is calculated based on
203
204 "An Explicit Implicit Volatility Formula"
205 R. Radoicic, D. Stefanica,
206 https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2908494
207 */
209 Real strike,
210 Real forward,
211 Real blackPrice,
212 Real discount = 1.0,
213 Real displacement = 0.0,
214 Real guess = Null<Real>(),
215 Real omega = 1.0,
216 Real accuracy = 1.0e-6,
217 Natural maxIterations = 100);
218
219 Real blackFormulaImpliedStdDevLiRS(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
220 Real forward,
221 Real blackPrice,
222 Real discount = 1.0,
223 Real displacement = 0.0,
224 Real guess = Null<Real>(),
225 Real omega = 1.0,
226 Real accuracy = 1.0e-6,
227 Natural maxIterations = 100);
228
229 /*! Black 1976 probability of being in the money (in the bond martingale
230 measure), i.e. N(d2).
231 It is a risk-neutral probability, not the real world one.
232 \warning instead of volatility it uses standard deviation,
233 i.e. volatility*sqrt(timeToMaturity)
234 */
236 Option::Type optionType, Real strike, Real forward, Real stdDev, Real displacement = 0.0);
237
238 /*! Black 1976 probability of being in the money (in the bond martingale
239 measure), i.e. N(d2).
240 It is a risk-neutral probability, not the real world one.
241 \warning instead of volatility it uses standard deviation,
242 i.e. volatility*sqrt(timeToMaturity)
243 */
244 Real blackFormulaCashItmProbability(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
245 Real forward,
246 Real stdDev,
247 Real displacement = 0.0);
248
249 /*! Black 1976 probability of being in the money in the asset martingale
250 measure, i.e. N(d1).
251 It is a risk-neutral probability, not the real world one.
252 */
254 Option::Type optionType, Real strike, Real forward, Real stdDev, Real displacement = 0.0);
255
256 /*! Black 1976 probability of being in the money in the asset martingale
257 measure, i.e. N(d1).
258 It is a risk-neutral probability, not the real world one.
259 */
260 Real blackFormulaAssetItmProbability(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
261 Real forward,
262 Real stdDev,
263 Real displacement = 0.0);
264
265 /*! Black 1976 formula for standard deviation derivative
266 \warning instead of volatility it uses standard deviation, i.e.
267 volatility*sqrt(timeToMaturity), and it returns the
268 derivative with respect to the standard deviation.
269 If T is the time to maturity Black vega would be
270 blackStdDevDerivative(strike, forward, stdDev)*sqrt(T)
271 */
273 Real strike, Real forward, Real stdDev, Real discount = 1.0, Real displacement = 0.0);
274
275 /*! Black 1976 formula for derivative with respect to implied vol, this
276 is basically the vega, but if you want 1% change multiply by 1%
277 */
279 Real forward,
280 Real stdDev,
281 Real expiry,
282 Real discount = 1.0,
283 Real displacement = 0.0);
284
285
286 /*! Black 1976 formula for standard deviation derivative
287 \warning instead of volatility it uses standard deviation, i.e.
288 volatility*sqrt(timeToMaturity), and it returns the
289 derivative with respect to the standard deviation.
290 If T is the time to maturity Black vega would be
291 blackStdDevDerivative(strike, forward, stdDev)*sqrt(T)
292 */
293 Real blackFormulaStdDevDerivative(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
294 Real forward,
295 Real stdDev,
296 Real discount = 1.0,
297 Real displacement = 0.0);
298
299 /*! Black 1976 formula for second derivative by standard deviation
300 \warning instead of volatility it uses standard deviation, i.e.
301 volatility*sqrt(timeToMaturity), and it returns the
302 derivative with respect to the standard deviation.
303 */
305 Rate strike, Rate forward, Real stdDev, Real discount, Real displacement);
306
307 /*! Black 1976 formula for second derivative by standard deviation
308 \warning instead of volatility it uses standard deviation, i.e.
309 volatility*sqrt(timeToMaturity), and it returns the
310 derivative with respect to the standard deviation.
311 */
312 Real blackFormulaStdDevSecondDerivative(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
313 Real forward,
314 Real stdDev,
315 Real discount = 1.0,
316 Real displacement = 0.0);
317
318 /*! Black style formula when forward is normal rather than
319 log-normal. This is essentially the model of Bachelier.
320
321 \warning Bachelier model needs absolute volatility, not
322 percentage volatility. Standard deviation is
323 absoluteVolatility*sqrt(timeToMaturity)
324 */
326 Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount = 1.0);
327
328 /*! Black style formula when forward is normal rather than
329 log-normal. This is essentially the model of Bachelier.
330
331 \warning Bachelier model needs absolute volatility, not
332 percentage volatility. Standard deviation is
333 absoluteVolatility*sqrt(timeToMaturity)
334 */
335 Real bachelierBlackFormula(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
336 Real forward,
337 Real stdDev,
338 Real discount = 1.0);
339
340 /*! Bachelier Black model forward derivative.
341
342 \warning Bachelier model needs absolute volatility, not
343 percentage volatility. Standard deviation is
344 absoluteVolatility*sqrt(timeToMaturity)
345 */
347 Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount = 1.0);
348
349 /*! Bachelier Black model forward derivative.
350
351 \warning Bachelier model needs absolute volatility, not
352 percentage volatility. Standard deviation is
353 absoluteVolatility*sqrt(timeToMaturity)
354 */
356 const ext::shared_ptr<PlainVanillaPayoff>& payoff,
357 Real forward,
358 Real stdDev,
359 Real discount = 1.0);
360
361 /*! Approximated Bachelier implied volatility
362
363 It is calculated using the analytic implied volatility approximation
364 of J. Choi, K Kim and M. Kwak (2009), “Numerical Approximation of the
365 Implied Volatility Under Arithmetic Brownian Motion”,
366 Applied Math. Finance, 16(3), pp. 261-268.
367 */
369 Real strike,
370 Real forward,
371 Real tte,
372 Real bachelierPrice,
373 Real discount = 1.0);
374
375 /*! Bachelier formula for standard deviation derivative
376 \warning instead of volatility it uses standard deviation, i.e.
377 volatility*sqrt(timeToMaturity), and it returns the
378 derivative with respect to the standard deviation.
379 If T is the time to maturity Black vega would be
380 blackStdDevDerivative(strike, forward, stdDev)*sqrt(T)
381 */
382
384 Real forward,
385 Real stdDev,
386 Real discount = 1.0);
387
388 Real bachelierBlackFormulaStdDevDerivative(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
389 Real forward,
390 Real stdDev,
391 Real discount = 1.0);
392
393 /*! Bachelier formula for probability of being in the money in the asset martingale
394 measure, i.e. N(d).
395 It is a risk-neutral probability, not the real world one.
396 */
398 Real strike,
399 Real forward,
400 Real stdDev);
401
402 /*! Bachelier formula for of being in the money in the asset martingale
403 measure, i.e. N(d).
404 It is a risk-neutral probability, not the real world one.
405 */
406 Real bachelierBlackFormulaAssetItmProbability(const ext::shared_ptr<PlainVanillaPayoff>& payoff,
407 Real forward,
408 Real stdDev);
409
410}
411
412#endif
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Rate
interest rates
Definition: types.hpp:70
ext::shared_ptr< QuantLib::Payoff > payoff
Definition: any.hpp:35
Real blackFormulaAssetItmProbability(Option::Type optionType, Real strike, Real forward, Real stdDev, Real displacement)
Real blackFormulaCashItmProbability(Option::Type optionType, Real strike, Real forward, Real stdDev, Real displacement)
Real blackFormulaImpliedStdDevLiRS(Option::Type optionType, Real strike, Real forward, Real blackPrice, Real discount, Real displacement, Real guess, Real w, Real accuracy, Natural maxIterations)
Real blackFormulaImpliedStdDevChambers(Option::Type optionType, Real strike, Real forward, Real blackPrice, Real blackAtmPrice, Real discount, Real displacement)
Real bachelierBlackFormulaAssetItmProbability(Option::Type optionType, Real strike, Real forward, Real stdDev)
Real bachelierBlackFormulaStdDevDerivative(Rate strike, Rate forward, Real stdDev, Real discount)
Real bachelierBlackFormula(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount)
Real blackFormulaImpliedStdDev(Option::Type optionType, Real strike, Real forward, Real blackPrice, Real discount, Real displacement, Real guess, Real accuracy, Natural maxIterations)
Real blackFormulaForwardDerivative(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount, Real displacement)
Real bachelierBlackFormulaForwardDerivative(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount)
Real blackFormulaVolDerivative(Rate strike, Rate forward, Real stdDev, Real expiry, Real discount, Real displacement)
Real blackFormula(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount, Real displacement)
Real bachelierBlackFormulaImpliedVol(Option::Type optionType, Real strike, Real forward, Real tte, Real bachelierPrice, Real discount)
Real blackFormulaStdDevSecondDerivative(Rate strike, Rate forward, Real stdDev, Real discount, Real displacement)
Real blackFormulaImpliedStdDevApproximation(Option::Type optionType, Real strike, Real forward, Real blackPrice, Real discount, Real displacement)
Real blackFormulaImpliedStdDevApproximationRS(Option::Type type, Real K, Real F, Real marketValue, Real df, Real displacement)
Real blackFormulaStdDevDerivative(Rate strike, Rate forward, Real stdDev, Real discount, Real displacement)
Base option class.
Payoffs for various options.