Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Finite difference methods for sensitivity computations Marco Marchioro www.statpro.com Version 0.99 April 2016∗ Abstract We describe some basic finite-difference methods to estimate the derivatives of a generic smooth function. For a function of one variable we provide the derivation of the standard forward difference, backward difference, and central difference approximation of the first and second derivatives. We also derive the expression for the second-order cross partial derivative for a function of two variables. Then we show how to compute the first and second derivative, to the second order, for a smooth function when only non-symmetric displacements in the underlying variable are available. Finally in the appendix we show an example quantitative-finance application to compute the equity-option sensitivities according to different definitions. Keywords: finite difference,forward difference, backward difference, central difference, local sensitivities, greeks, option-adjusted exposure, vanilla option 1 Introduction typical use of this work is in the computation of sensitivities of a financial security, the main assumption that we make is that the pricing function is so smooth in its arguments so that we can perform a Taylor expansion. In this paper we consider functions in one or two variables and derive the finite-difference approximations up to the fourth order. Since the topic of finite-difference approximations is very large and we refer to the specialised literature, for example see reference [2], for more details on the subject. Very often in quantitative finance one has to compute the sensitivities of a pricing function with respect its fast-changing financial variables: the risk drivers. For example in reference [4] the variations of a generic pricing function are computed both for small and for large values of the risk-driver displacements. Another important example of the application of the methods described in this paper is the computation of sensitivities needed to perform the fixed-income attribution of a portfolio as seen, for example, in reference [3]. While there many different ways to approximate the derivative of a function with respect to its variables, the 2 Expansions in one variable class of methods known as finite differences stand out We start with the case of a function that depends because of their generality and usability by employing on a single variable. Hence consider a smooth function a limited number of function evaluations. Since the f (x) of a real variable x. Since the function is smooth ∗ Latest minor review January 11, 2017 1 2 Marco Marchioro it is possible to compute its Taylor expansion around x. compute a similar approximation for the first derivative Therefore given a small increment δ along the x axis of f in terms of f (x − δ) and f (x), we write, 1 δ f 0 (x) = [f (x) − f (x − δ)] + f 00 (x) (4) 2 δ 2 δ (1) f (x + δ) = f (x) + δ · f 0 (x) + f 00 (x) δ2 δ3 δ 4 (5) 2 − f 000 (x) + f (4) (x) − f (x) + O(δ 5 ) . 3 4 5 6 24 120 δ δ δ (5) + f 000 (x) + f (4) (x) + f (x) + O(δ 6 ) , This equation truncated to the first term, 6 24 120 where the expression O(δ 6 ) is meant to be a placeholder for terms of order δ 6 or higher. Furthermore, we denote respectively with f 0 , f 0 , f 00 , f 000 ,f (4) , and f (5) , the first, the second, the third, the fourth, and the fifth derivatives of f . Since we are investigating the symmetric expansion with respect to the evaluation point x we consider a shift −δ together to the displacement +δ. Hence, substituting δ → −δ in equation (1) we obtain f 0 (x) = 1 [f (x) − f (x − δ)] + O(δ) , δ provides the backward difference approximation of the first derivative. We do not derive the first order approximation of the second derivative as the formula is not interesting and is seldom used in practice. 2.2 The second order approximation The sum of both sides of equations (3) and (4) implies, δ 2 00 f (x) (2) 1 δ2 2 2 f 0 (x) = [f (x + δ) − f (x − δ)] − f 000 (x) + O(δ 4 ) , 3 4 5 δ δ δ (5) δ 3 − f 000 (x) + f (4) (x) − f (x) + O(δ 6 ) . 6 24 120 so that, f (x − δ) = f (x) − δ · f 0 (x) + In the reminder of this section we use these two equaf (x + δ) − f (x − δ) δ 2 000 0 f (x) = − f (x) + O(δ 4 ) . (5) tions to compute the finite difference approximation of 2δ 6 the first and second derivative up to the fourth order. Truncating this expression to the first term, namely 2.1 The first order approximation f 0 (x) = f (x + δ) − f (x − δ) + O(δ 2 ) , 2δ Using expression (1) we can compute the following approximation for the first derivative of f in terms of we obtain the central-difference second-order approximation of f 0 (x). f (x + δ) and f (x), On the other hand, subtracting equation (4) from 1 δ (3) we obtain, f 0 (x) = [f (x + δ) − f (x)] − f 00 (x) (3) δ 2 1 1 δ 2 000 δ 3 (4) δ 4 (5) 0 = [f (x + δ) − f (x)] − [f (x) − f (x − δ)] 5 − f (x) − f (x) − f (x) + O(δ ) . δ δ 6 24 120 δ3 −δ f 00 (x) − f (4) (x) + O(δ 5 ) , 12 Truncating this expression to the first term we can write f 0 (x) = 1 [f (x + δ) − f (x)] + O(δ) , δ known as the forward difference approximation of the first derivative. Similarly using equation (2) we can that implies f 00 (x) = f (x + δ) − 2 f (x) + f (x − δ) (6) δ2 δ2 − f (4) (x) + O(δ 4 ) . 12 . uant Island and Statpro Italia. All rights reserved. c 2011, 2012, 2014, 2016Copyright by Q Finite difference methods for sensitivity computations Truncating this expression to the first term, namely f 00 (x) f (x + δ) − 2 f (x) + f (x − δ) + O(δ 2 ) , δ2 we obtain the central-difference second-order approximation of f 00 (x). 2.3 Approximation for the logarithmic derivative We show in this subsection how to approximate the second order logarithmic derivative of a function when only two observations of the pricing function are available. Recall that the logarithmic derivative of f (x) with respect to x is defined as Now we sum 34 of equation (5) and subtract tion (12), to obtain, 3 1 3 of equa- 4 0 1 4 f (x + δ) − f (x − δ) f (x) − f 0 (x) = 3 3 3 2δ 1 f (x + 2 δ) − f (x − 2 δ) 4 − − f 000 (x)δ 2 3 4δ 18 2 000 + f (x)δ 2 + O(δ 4 ) , 9 so that, 4 f (x + δ) − f (x − δ) 0 f (x) = (13) 3 2δ 1 f (x + 2 δ) − f (x − 2 δ) + O(δ 4 ) , − 3 4δ is the fourth-order approximation of the first derivative. Similarly, we can derive the fourth-order approxima(7) tion for the second derivative of f from equation (6) substituting δ → 2 δ to give, With the help of equations (1) and (2) we can workout f (x + 2 δ) − 2 f (x) + f (x − 2 δ) expression (8) in figure 1 so that so that f 00 (x) = (14) 4δ 2 1 f (x + δ) − f (x − δ) f 0 (x) δ2 = · + O(δ 2 ) . (9) − f (4) (x) + O(δ 3 ) ; f (x) δ f (x + δ) + f (x − δ) 3 4 we then sum 3 of equation (6) and subtract 13 of equaSometimes this expression is used to compute the time tion (15), to obtain, derivative of a pricing function at an intermediate half 4 f (x + δ) − 2 f (x) + f (x − δ) step, in this case it can be useful to perform the fol00 f (x) = (15) 3 δ2 lowing change of variable: 1 f (x + 2 δ) − 2 f (x) + f (x − 2 δ) ε ε + O(δ 4 ) , − δ= and x =t+ , (10) 3 4δ 2 2 2 i.e. the fourth-order approximation of the second so that expression (9) becomes derivative of f . f 0 (x) d log[f (x)] = . dx f (x) f 0 (t + ε/2) 2 f (x + ε) − f (t) = · + O(ε2 ) . f (t + ε/2) ε f (t + ε) + f (t) (11) 2.5 Simplified notation We can understand a bit more of the approximations derived in finite-difference methods described so 2.4 The fourth-order approximations far by introducing the simplified notation. In the simIn order to derive the fourth order approximation plified notation we define a symbol for the first-order for the first derivative of f , we rewrite equation (5) approximation of the right and left first derivatives: substituting δ → 2 δ, f (x + δ) − f (x) ∆+ = δ f (x + 2 δ) − f (x − 2 δ) f 0 (x) = (12) and 4δ 2 f (x) − f (x − δ) − f 000 (x)δ 2 + O(δ 4 ) . ∆− = , 3 δ Statpro Quantitative Research Series: Mathematical Methods in Quantitative Finance 4 Marco Marchioro δ 2 00 2 f (x) δ 2 00 2 f (x) O(δ 3 ) f (x + δ) − f (x − δ) f (x) + δ f 0 (x) + = f (x + δ) + f (x − δ) f (x) + δ f 0 (x) + = − f (x) + f 0 (x)δ − + f (x) − f 0 (x)δ + δ 2 00 2 f (x) δ 2 00 2 f (x) + O(δ 3 ) + O(δ 3 ) 2 δ f 0 (x) + f 0 (x) =δ + O(δ 3 ) , 2 00 3 2 f (x) + δ f (x) + O(δ ) f (x) (8) Figure 1: Worked out computation for the finite difference approximation of the logarithmic first derivative. for a grid step of δ; also we define ∆++ = f (x + 2 δ) − f (x) 2δ and the fourth-order expression for the second derivative, see equation (15), simply becomes 4 ∆+ + ∆− 1 ∆++ + ∆−− f (x) = − + O(δ 3 ) 3 δ 3 δ 4 1 00 = fδ00 − f2δ + O(δ 4 ) . (19) 3 3 00 and ∆−− = f (x) − f (x − 2 δ) , 2δ for a grid step of 2 δ. Using this notation equations (3) The similarities between the two equations (18) and (4) can be simply written as and (19) are striking. In short, to obtain the fourthorder derivatives from the second-order ones one has to 0 + 0 − f (x) = ∆ + O(δ) , and f (x) = ∆ + O(δ) . give a weight of 43 to the expression for the single-grid 1 Similarly the second-order approximation, equation (5), step and a weight of - 3 to the expression of two-grid steps. Also notice how, as expected, the sum of the can be written in this simplified notation as two weights equals one. ∆+ − ∆− 2 2 0 0 (16) + O(δ ) = fδ + O(δ ) . f (x) = 2 We can also define symbols for the second-order approximation: 3 Expansions in two variables We use a method similar to that of the previous ∆++ − ∆−− section to compute the finite-difference approximation and = . (17) 2 of the cross second derivative of a function with respect The fourth order approximation of the first derivative, to two distinct variables. We start by considering a function f (x, y ) of two from equation (13), can simply be written as variables x and y . The Taylor approximation for a dis + 4 ∆ − ∆− 1 ∆++ − ∆−− 0 4 placement pair (δ, ε) in (x, y ) can be written as, f (x) = − + O(δ ) 3 2 3 2 4 1 0 = fδ0 − f2δ + O(δ 4 ) . (18) f (x + δ, y + ε) ' f (x, y ) + δ ∂f + ε ∂f 3 3 ∂x ∂y fδ0 ∆+ − ∆− = 2 f20 δ In the same notation the second-order second derivative of f , computed in equation (6), can be written as ∆+ + ∆− f (x) = + O(δ 3 ) = fδ00 + O(δ 4 ) , δ 00 + δ2 ∂ 2f ε2 ∂ 2 f ∂2f + + δε . 2 ∂x 2 2 ∂y 2 ∂x∂y Using the above expression also for f (x − δ, y − ε), f (x − δ, y + ε), and f (x + δ, y − ε), after some easy . uant Island and Statpro Italia. All rights reserved. c 2011, 2012, 2014, 2016Copyright by Q Finite difference methods for sensitivity computations algebra, one can show that, 5 and f (x + δ, y + ε) + f (x − δ, y − ε) −f (x − δ, y + ε) − f (x + δ, y − ε) ∂2f . ' 4 δε ∂x∂y From this expression we can derive an approximation for the cross derivative of f , ∂2f 1 ' f (x + δ, y + ε) + f (x − δ, y − ε) ∂x∂y 4δε −f (x − δ, y + ε) − f (x + δ, y − ε) , that can be used to compute the local cross sensitivities such as those defined in reference [4]. 1 2 2 f+ + f− − 2 f0 ' f 0 (x) (δ+ − δ− ) + f 00 (x) δ+ + δ− . 2 (23) Since, 2 2 δ+ − δ− = (δ+ − δ− ) (δ+ + δ− ) , we can derive from equation (22) an expression for the first derivative of f , f 0 (x) ' 1 f+ − f− − f 00 (x) (δ+ − δ− ) . δ+ + δ− 2 (24) This expression for f 0 (x) can then be substituted into equation (23) gives 4 Asymmetric expansions f+ + f− − 2 f0 f+ − f− 00 − f (x) (δ+ − δ− ) · 2 ' 2 2 + δ2 δ+ + δ− δ+ − δ+ − δ− · 2 + f 00 (x) , 2 δ+ + δ− It is sometime necessary to compute an approximation to the first or the second derivative of a function when we only have available evaluations on nonsymmetric displacements above and below the reference point. While the subject of asymmetric expansions is rather large we provide here only some basics We solve this approximate equation to obtain the second-order derivative of f (x), results. We begin writing the Taylor expansion, equations + −δ− ) (1) and (2), for a smooth function f (x) around x with f+ + f− − 2 f0 − (f+ −fδ−+)(δ +δ− 00 h i . f (x) ' 2 (25) two different displacements δ+ and δ− (the first with (δ+ −δ− )2 2 2 δ + δ 1 − 2 2 + − δ+ +δ− a positive sign while the second with a negative one): f+ = f (x + δ+ ) ' f0 + δ+ f 0 (x) + 2 δ+ 00 2 f (x) , f− = f (x − δ− ) (20) Substituting this equation into equation (24) we obtain the result for the first derivative: (21) δ2 ' f0 − δ− f 0 (x) + − f 00 (x) , 2 f 0 (x) ' f+ − f− + δ+ + δ− (26) + −δ− ) f+ + f− − 2 f0 − (f+ −fδ−+)(δ +δ− i (δ+ − δ− ) . − h 2 −) 2 + δ2 δ+ 1 − (δδ+2−δ 2 − +δ where f0 = f (x) and terms of order (δ+ )3 and (δ− )3 + − or higher have beed neglected. We assume that the displacements δ+ and δ− are not necessarily the same Neglecting terms of order (δ+ − δ− )2 and higher in (in practical applications, however, they are typically equations (25) and (26) we obtain the simplified fornot too far apart). We then compute f+ − f− and mulas, f+ + f− − 2 f0 from equations (20) and (21) to obtain 1 2 2 f+ − f− ' f 0 (x) (δ+ + δ− ) + f 00 (x) δ+ − δ− (22) 2 f 0 (x) ' f+ − f− f+ + f− − 2 f0 − (δ+ − δ− ) , (27) 2 + δ2 δ+ + δ− δ+ − Statpro Quantitative Research Series: Mathematical Methods in Quantitative Finance 6 Marco Marchioro and price first and second derivatives evaluated at the current equity price. In mathematical terms we define f+ + f− − 2 f0 δ+ − δ− f+ − f− f 00 (x) ' 2 −2 . 2 + δ2 2 + δ2 δ+ + δ− δ+ δ+ ∂ 2 P ∂P − − and ΓS = ∆S = , (28) ∂S S=S̄ ∂S 2 S=S̄ Notice that when δ+ =δ− =δ, i.e. in the symmetrical case, we have, where S̄ is the fundamental equity price. As we are about to show, this definition is slightly different from f+ + f− − 2 f0 f+ − f− and f 00 (x) ' , f 0 (x) ' the definition of ∆x and Γx given in reference [4]. 2δ δ2 (29) which are exactly the second-order results derived ear- Normalised pricing function Since the equity price S is always positive the equity risk driver can be considlier. ered of stock type. Hence rather than applying a shock directly to S we apply a displacement as a percentage Conclusions We have shown in this paper how to variation of the fundamental equity price S̄. We then compute a number of different approximations for the perform the change of variable from the underlying eqfirst and second derivative of a generic smooth func- uity price S to the normalised equity price x, so that tion. The methods shown in this brief paper are rather S = S̄(1 + x) . straightforward and the reader should be able to adapt them to cases that are similar to those considered here. In the following appendix we show an application of At this point, observing that for equity options we have the finite-difference methods in the computation of an a unitary basis, i.e. b=1, we assume a reference price Pr = P (S̄) and define the normalised pricing function equity-option sensitivity. as P S̄(1 + x) − 1. (A-1) f (x) = P (S̄) A Sensitivities for equity options As a practical example of the finite-difference meth- We then compute the delta and gamma sensitivities as ods we describe in this paper we show the sensitivity in reference [4]: computations for an equity-option and we evaluate the S̄ dP S̄ 2 d2 P option-adjusted delta and gamma. In this appendix we ∆x = and Γx = , P (S̄) dS S=S̄ P (S̄) dS 2 S=S̄ use the notation of reference [4]. Traditional option sensitivities Consider an equity option with a non-normalised pricing function P (S), depending on the underlying stock price S and possibly on some other risk drivers or parameters. Since we are only interested in the variations with respect to the underlying stock price in the pricing function we omit the other risk drivers such as interest rates and volatilities. The textbook definitions of delta and gamma are the first and the second derivatives of the option price with respect to the underlying asset price S (see, for example, reference [1]). Hence we use the terms traditional delta and the traditional gamma, and denote them respectively by the symbols ∆S and ΓS , for the option by simply computing the derivative of f (x) using the chain rule on definition (A-1). Option-adjusted equity exposures The optionadjusted equity exposure, OAEE for short, is defined as ∂P S̄(1 + x) OAEE = . (A-2) ∂x We can use this definition of exposure in practice by applying a small percentage value h, for example h=1%, to the equity price, P S̄(1 + h) − P (S̄) ' h · OAEE , . uant Island and Statpro Italia. All rights reserved. c 2011, 2012, 2014, 2016Copyright by Q Finite difference methods for sensitivity computations to obtain the cash profit and loss, the so called P&L, incurred in holding the option when the underlying stock price moves by 1%. Thus the reason behind the popularity of the OAEE is that the P&L is approximately equal to the exposure multiplied by the percentage h. In other words the practitioner can quickly compute the new option P&L by observing the variations of the underlying equity price. Since the equity price moves quickly with the stock market so do the sensitivities, hence traders are keen also to observe the gamma exposure defined next. Given a small percentage h we define the gamma equity exposure, GEEh for short, as GEEh = h P (S̄) ∂2f . ∂x 2 7 OAEE, and the definition of delta given in the previous sections ∆x , i.e. OAEE = P (S̄) ∆x = S̄ ∆S . Similarly for the second-order local sensitivities we have GEEh = h P (S̄) Γx = h S̄ 2 ΓS . Finally we can compute numerically the traditional delta and gamma at the fourth order as, P (S̄) 4 0 1 0 ∂P 4 = f − f + O(δ ) , ∆S = ∂S 3 δ 3 2δ S̄ ∂2P P (S̄) 4 00 1 00 4 ΓS = = f − f2δ + O(δ ) , ∂S 2 3 δ 3 S̄ 2 (A-3) where all derivatives, as usual, are computed in x=0 and The gamma equity exposure provides the following ap- the symbols f 0 and f 00 are the second-order symmetric proximation finite-difference expansions as defined in equations (13) and (15). ∂OAEE GEEh = h ' OAEE(h) − OAEE(0) , ∂x for the difference of the option-adjusted equity expo- References sure caused by a change in S of h percent. Observe [1] John Hull. Options, Futures, and Other Derivaalso that, h tives. Pearson Prentice Hall, 9th edition, 2014. 6 GEE = P (S̄) Γx , h [2] Randall J LeVeque. Finite difference methods for where Γx has been computed according to the definiordinary and partial differential equations: steadytions of reference [4]. Practitioners often set h = 1% state and time-dependent problems, volume 98. and compute GEE1% to obtain an easy way to quickly Siam, 2007. 1 determine OAEE variations. [3] Marco Marchioro. Fixed-income performance conComparing the different definitions of equity-option tributions of complex bonds. In Risk and Perforsensitivities Keeping in mind the definition of the normance Attribution, StatPro Quantitative Research malised pricing function f , i.e. equation (A-1), and usSeries. StatPro website, July 2014. Permanent link ing the rules of partial differentiation we can show that marchioro.org/papers/fixed-income-contributions/. 1 1 ∂f 1 ∂P = (A-4) S̄ ∂x P̄ ∂S [4] Marco Marchioro. Risk-driver chord sensitivities of financial instruments. In Risk and Perforand 1 ∂2f 1 ∂2P mance Attribution, Quantitative Research Series. = . (A-5) S̄ 2 ∂x 2 P̄ ∂S 2 StatPro website, April 2017. Permanent link marchioro.org/papers/risk-driver-sensitivities/. 1, Therefore we have a relationship between the traditional delta ∆S , the option-adjusted equity exposure 5, 6, 7 Statpro Quantitative Research Series: Mathematical Methods in Quantitative Finance