CHAPTER 22Extending the Software Framework

22.1 Introduction and Objectives

This chapter is an application of the methods and code from Chapters 20 and 21. We are particularly interested in estimating delta and gamma, which are the first and second derivatives of the option price with respect to the stock, respectively. These two sensitivities are used to manage risk due to an option position. It is for this reason that we discuss them in some detail and we propose several methods to compute them.

The approach taken is to compute the option price array at expiration and then use it to compute delta and gamma using divided differences. We must take care with the choice of the finite difference scheme because some schemes (such as Crank–Nicolson, for example) can produce oscillations due to the fact that the payoff can be discontinuous or can have kinks at certain points, most notably at the strike (see Duffy, 2004A for a discussion). We resolve the problem by taking more time steps to dampen unwanted eigenvalues (see Lawson and Morris, 1978) or by using the fully implicit (BTCS) scheme. However, this scheme is only first-order accurate. Another alternative is to use BTCS for the first few time steps and then switch to Crank–Nicolson when the oscillations near the strike have disappeared.

We can also view this chapter from a software testing perspective, namely the code uses the functions and classes from Chapters 13, 20 and 21. Since we have analytical formulae for delta and ...

Get Financial Instrument Pricing Using C++, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.