Computing Implied Volatilities Using Automatic Differentiation
Lucas Roh - Argonne National Laboratory
Given a computation model, we are often interested in adjusting certain
model parameters so that the model agrees with the experimental results
(this is typically called parameter identification or data assimilation).
This is performed typically with the help of numerical optimization algorithms.
In finance, an option pricing equation, such as the Black-Scholes formula, are sometimes used in computing the implied volatility of the underlying security. In general, the pricing equation, whether solved analytically or numerically, are given as a computer code C that computes a function f : x -> y with n inputs and m outputs (typically m is one - the price of the option). In the Black-Scholes formula, the price of the option is c = f (X, S, r, t, *) where the inputs, represent, respectively, the strike price, underlying security price, riskless interest rate, option expiration time, and volatility. Since the volatility cannot be directly observed, we can solve
e-f (* ) = 0
for *, using the observed data for the c and the rest of the parameters. To solve the above equation using the Newton's method, we need to compute the derivative f'. Note that in general the option pricing code C may be an arbitrary code that may not even be directly related to any differential equation. Thus, we would like to create directly from C a new code C' that computes f' = dy/do. Ideally, C' should be accurate, fast, and require little development time. The derivative code C' can be produced in a number of different ways. It can be developed by hand which typically is laborious and error-prone. On the other hand, a skilled user can take advantage of domain-specific knowledge that can result in a very efficient code. C' can also be developed with the help of a symbolic-mathematics package such as Mathematica or Maple. However, this approach is applicable only for expressions (formulae) and not directly applicable to large computer codes written in languages such as FORTRAN 77 or C. It also suffers from a significant code expansion. Another alternative, divided differences, does not directly produce a derivative code but rather approximates the derivatives by evaluating f at multiple input points, While it requires little effort to produce these derivatives, the main drawback is that it is not early to determine the accuracy of the approximation due to inherent errors.
By using an automatic differentiation (AD) tool such as ADIC and ADIFOR, we can automatically produce an accurate and reasonably fast derivative code C'. AD works by automatically applying the chain rule of differential calculus at the elementary operator or intrinsic function level (e.g., add, multiply, sine and cosine). AD does not incur the errors inherent in divided difference approximations. Unlike the symbolic method, AD can be applied to codes containing loops and function calls — generally any code. Also, if C changes, an up-to-date C' is produced by simply re-running the tools.
2 The ADIC Tool
There are several existing AD tools that operate mostly on FORTRAN 77 or FORTRAN 90 programs (e.g. ADIFOR, TAMC, and Odyssey). However, ANSI-C is also widely used in scientific and engineering applications, and thus robust AD tools that handle ANSI-C programs are needed. We have developed an extensible AD tool called ADIC (Automatic Differentiation of C) that is based on source-to-source transformation. ADIC currently produces first and second-order derivative codes and provides the following benefits and features:
A flexible and tunable black-box tool: Users only need to supply the
ANSI-C code and write a simple driver that specifies the independent
variables. It will produce a new ANSI-C code that computes the derivatives
with respect to the specified independent variables.
| Generality and Portability: ADIC provides AD functionality for general
ANSI-C program and handles many features of C++. The generated ANSI-C code
is portable across different platforms and compilers.
| Extensibility: Due to the associativity of the chain rule, there are
many ways to carry out the derivative computation each exhibiting possibly
different time and memory complexity. AD technology is still in its infancy-
the development of better algorithms for exploiting chain rule
associativity and their incorporation into AD tools promise significant
improvement in the performance of generated derivative codes. ADIC
incorporates a component architecture that allows novel AD algorithms to be
developed as components to be directly plugged into ADIC.
| |
3 Example
We show an application of ADIC for solving implied volatilities given a code that computes the price of an option. In our particular example, the code process the European call options using the Black-Scholes formula. We run the code through ADIC and write a simple driver that uses the Newton's method to solve for the volatility o. We measure the cost of computing the derivatives in terms of the cost of the function evaluation. If the pricing model is extended that makes use of multiple volatilities (either of different securities or at different times), we can easily handle them by extending the Newton's scheme for multiple variables and re-running ADIC.
Scheduled for Session 5.1 Automatic Differentiation: A Tutorial Session