Class FeynmanKacEx5

java.lang.Object
com.imsl.test.example.math.FeynmanKacEx5

public class FeynmanKacEx5 extends Object

Solves for the "Greeks" of mathematical finance.

In this example, the FeynmanKac class is used to calculate the so-called "Greeks" of mathematical finance. The "Greeks" are defined in terms of various derivatives of Feynman-Kac solutions and have special interpretations in the pricing of options and related financial derivatives. In order to illustrate and verify these calculations, the Greeks are calculated by two methods. The first method involves the Feynman-Kac (FK) solution to the diffusion model for call options as described in example 2 FeynmanKacEx2, for the Black-Scholes case (\( \alpha \rightarrow 2\)). The second method calculates the Greeks using the closed-form Black-Scholes (BS) evaluations, which can be found here: Wikipedia: The Greeks.

Example 5 calculates FK and BS solutions \(V(S, t)\) to the BS problem and the following Greeks:

  • \(Delta\;=\;\frac{\partial V}{\partial S}\) is the first derivative of the Value, \(V(S,t)\), of a portfolio of derivative security derived from an underlying instrument with respect to the price, S of the underlying instrument.
  • \(Gamma\;=\;\frac{\partial^2 V}{\partial S^2}\)
  • \(Theta\;=\;-\frac{\partial V}{\partial t}\) is the negative first derivative of V with respect to time t
  • \(Charm\;=\;\frac{\partial^2 V}{\partial S \partial t}\)
  • \(Color\;=\;\frac{\partial^3 V}{\partial S^2 \partial t}\)
  • \(Rho\;=\;-\frac{\partial V}{\partial r}\) is the first derivative of V with respect to risk free rate r
  • \(Vega\;=\;\frac{\partial V}{\partial \sigma}\) measures sensitivity to volatility parameter \(\sigma\) of the underlying S
  • \(Volga\;=\;\frac{\partial^2 V}{\partial \sigma^2}\)
  • \(Vanna\;=\;\frac{\partial^2 V}{\partial S \partial \sigma}\)
  • \(Speed\;=\;\frac{\partial^3 V}{\partial S^3}\)

Intrinsic Greeks include derivatives involving only S and t, the intrinsic FK arguments. In the above list, Value, Delta, Gamma, Theta, Charm, Color, and Speed are all intrinsic Greeks. As is discussed in Hanson, R. (2008) Integrating Feynman-Kac equations Using Hermite Quintic Finite Elements, the expansion of the FK solution function \(V(S, t)\) in terms of quintic polynomial functions defined on S-grid subintervals and subject to continuity constraints in derivatives 0, 1, and 2 across the boundaries of these subintervals allows Value, Delta, Gamma, Theta, Charm, and Color to be calculated directly by the FK class methods getSplineCoefficients, getSplineCoefficientsPrime, and getSplineValue.

Non-intrinsic Greeks are derivatives of V involving FK parameters other than the intrinsic arguments S and t, such as r and \(\sigma\). Non-intrinsic Greeks in the above list include Rho, Vega, Volga, and Vanna. In order to calculate non-intrinsic Greek (parameter) derivatives or intrinsic Greek S- derivatives beyond the second (such as Speed) or t- derivatives beyond the first, the entire FK solution must be calculated 3 times (for a parabolic fit) or five times (for a quartic fit), at the point where the derivative is to be evaluated and at nearby points located symmetrically on either side.

Using a Taylor series expansion of \(f(\sigma + \epsilon)\) truncated to m+1 terms (to allow an m-degree polynomial fit of m+1 data points):

$$ f(\sigma + \epsilon)\;=\;\sum_{n = 0}^m {\frac{f^{(n)}(\sigma)}{n!} \epsilon^n} $$

we are able to derive the following parabolic (3 point) estimation of first and second derivatives \(f^{(1)}(\sigma)\) and \(f^{(2)}(\sigma)\) in terms of the three values: \(f(\sigma - \epsilon)\), \(f(\sigma)\), and \(f(\sigma + \epsilon)\), where \(\epsilon = \epsilon_{frac} \sigma\) and \(0 \lt \epsilon_{frac} \lt\lt 1\):

$$ f^{(1)}(\sigma)\; \equiv \;\frac{\partial f(\sigma)}{\partial \sigma}\;\approx\; f^{[1]}(\sigma, \epsilon)\; \equiv \;\frac{f(\sigma + \epsilon)-f(\sigma - \epsilon)}{2 \epsilon} $$

$$ f^{(2)}(\sigma)\; \equiv \;\frac{\partial^2 f(\sigma)}{\partial \sigma^2}\;\approx\; f^{[2]}(\sigma, \epsilon)\; \equiv \;\frac{f(\sigma + \epsilon)+f(\sigma - \epsilon)-2f(\sigma)}{\epsilon^2} $$

Similarly, the quartic (5 point) estimation of \(f^{(1)}(\sigma)\) and \(f^{(2)}(\sigma)\) in terms of \(f(\sigma - 2\epsilon)\), \(f(\sigma - \epsilon)\), \(f(\sigma)\), \(f(\sigma + \epsilon)\), and \(f(\sigma + 2\epsilon)\) is:

$$ f^{(1)}(\sigma)\;\approx\;\frac{4}{3} f^{[1]}(\sigma, \epsilon) \;-\; \frac{1}{3}f^{[1]}(\sigma, 2\epsilon) $$

$$ f^{(2)}(\sigma)\;\approx\;\frac{4}{3} f^{[2]}(\sigma, \epsilon) \;-\; \frac{1}{3}f^{[2]}(\sigma, 2\epsilon) $$

For our example, the quartic estimate does not appear to be significantly better than the parabolic estimate, so we have produced only parabolic estimates by setting variable iquart to 0. The user may try the example with the quartic estimate simply by setting iquart to 1.

As is pointed out in Hanson, R. (2008), the quintic polynomial expansion function used by Feynman-Kac only allows for continuous derivatives through the second derivative. While up to fifth derivatives can be calculated from the quintic expansion (indeed class FeynmanKac method getSplineValue will allow the third derivative to be calculated by setting parameter ideriv to 3 as is done in this Example), the accuracy is compromised by the inherent lack of continuity across grid points (i.e. subinterval boundaries).

The accurate second derivatives in S returned by the FK method getSplineValue can be leveraged into a third derivative estimate by calculating three FK second derivative solutions, the first solution for grid and evaluation point sets \(\{S,\; f^{(2)}(S)\}\) and the second and third solutions for solution grid and evaluation point sets \(\{S+\epsilon,\; f^{(2)}(S+\epsilon)\}\) and \(\{S-\epsilon,\; f^{(2)}(S-\epsilon)\}\), where the solution grid and evaluation point sets are shifted up and down by \(\epsilon\). In this example, \(\epsilon\) is set to \(\epsilon_{frac} \bar{S}\), where \(\bar{S}\) is the average value of S over the range of grid values and \(0 \lt \epsilon_{frac} \lt\lt 1\). The third derivative solution can then be obtained using the parabolic estimate:

$$ f^{(3)}(S)\;=\;\frac{\partial f^{(2)}(S)}{\partial S}\;\approx\;\frac{f^{(2)}(S + \epsilon)-f^{(2)}(S - \epsilon)}{2 \epsilon} $$

This procedure is implemented in this example to calculate the Greek Speed. (For comparison purposes, Speed is also calculated directly in this example by setting the getSplineValue input S derivative parameter iSDeriv to 3. The output from this direct calculation is called "Speed2".)

The average and maximum relative errors (defined as the absolute value of the difference between the BS and FK values divided by the BS value) for each of the Greeks is given at the end of the output. (These relative error statistics are given for nine combinations of Strike Price and Volatility, but only one of the nine combinations is actually printed in the output.) Both intrinsic and non-intrinsic Greeks have good accuracy (average relative error is in the range 0.01 -- 0.0001) except for Volga, which has an average relative error of about 0.05. This is probably a result of the fact that Volga involves differences of differences, which will more quickly erode accuracy than calculations using only one difference to approximate a derivative. Possible ways to improve upon the 2 to 4 significant digits of accuracy achieved in this example include increasing FK integration accuracy by reducing the initial step size (using method setInitialStepsize), by choosing more closely spaced S and t grid points (by adjusting method computeCoefficients input parameter arrays xGrid and tGrid), and by adjusting \(\epsilon_{frac}\) so that the central differences used to calculate the derivatives are not too small to compromise accuracy.

See Also:
  • Constructor Details

    • FeynmanKacEx5

      public FeynmanKacEx5()
  • Method Details