Numerical Options Models Without Programming Abstract ... - CiteSeerX

1 downloads 0 Views 378KB Size Report
equations for option valuation using the SciNapse software synthesis system. ... and outside barrier options, convertible bonds with stochastic interest rateĀ ...
Numerical Options Models Without Programming Curt Randall and Elaine Kant SciComp Incy , 5806 Mesa Drive, Suite 250, Austin, TX 78731

Abstract We describe the automatic generation of nite di erence codes for solving the Black-Scholes and related equations for option valuation using the SciNapse software synthesis system. Analysts can specify codes at a very high level that mirrors the mathematical description of the problem. A typical option pricing speci cation occupies less than a half page. From such concise input, the system automatically generates validated, documented codes of several hundred lines of either C or Fortran in minutes, codes of several thousand lines in about an hour.

1 The Opportunity Rapid development of numerical models for pricing and hedging has become essential to the derivatives industry. New types of derivatives proliferate as customers demand instruments structured to speci c requirements. Analysts must generate pricing models for the new instruments quickly and inexpensively, often within days or hours. The current method of developing nancial models, and scienti c modeling software in general, is a tedious cycle of programming, debugging, and re-testing, quite ill-suited to this new environment. Software synthesis can deliver an order of magnitude increase in software productivity. Software synthesis is the process of transforming high level speci cations that mirror the mathematical description of the problem into ecient code in a conventional programming language such as C or Fortran. In this paper, we describe how analysts can specify options models to the SciNapse software synthesis system and display results from the generated codes. We also outline how SciNapse synthesizes programs. Modeling codes that have been synthesized by SciNapse include simple European and American put and call options, compound options, Asians and lookbacks with continuous and discrete sampling, inside and outside barrier options, convertible bonds with stochastic interest rate models, many types of rainbow options, and more. Underlying equities may pay continuous or discrete dividends of very general forms. Equation parameters may have arbitrary functional forms and dependencies, or may be even interpolated from tabular data. Volatilities, for example, may be assigned price and time structures obtained from current market data. In short, any option pricing problem that can be posed in terms of a PDE (possibly nonlinear) is suitable for SciNapse.

2 Some Example Pricing Model Speci cations

In this section we illustrate how to specify pricing models to SciNapse. We begin with a simple speci cation of an American put and discuss some basic speci cation features. Then we discuss some additional features in a more complex speci cation for a program that allows run-time European/American and put/call choices, discrete dividends, and calculation of the greeks.

 This was work supported in part by the National Institute of Standards and Technology Advanced Technology Program under Cooperative Agreement #70NANB5H1017. y e-mail: [email protected]; web: http://www.sig.net/scicomp/

1

2.1 A simple American put

When producing modeling codes, scientists or analysts begin with an abstract speci cation for the problem to be solved and the techniques to be applied. A ve-minute description to a knowledgable colleague is usually sucient to completely specify a desired code. Suppose we wish to generate a nite di erence model of American put options. An abstract speci cation might be: \Solve the Black-Scholes equation in a region with one Cartesian space dimension, S the underlying stock price, and one time dimension, t backward time. At the minimum price boundary the option value is the strike price K , and at the maximum price boundary the option value is zero. The initial condition is the standard payo . Constrain the option value to be greater than or equal to the payo . Use Crank-Nicholson di erencing for stability, and a SOR solver to invert the resulting matrix. Write the code in C." Many details have been omitted, to be lled in by mathematics and nancial knowledge and common modeling practice. Such human translation is routine, but the process is error-fraught and time consuming. The SciNapse system automatically synthesizes the required numerical code from a speci cation which is remarkably similar to the abstract description above: Region[0True, put->True].

3 The Program Synthesis Process

Here we brie y describe how SciNapse synthesizes code. More detailed descriptions of this process can be found, in the context of options valuation, in [3], and also, for applications in areas such as modeling seismic and sonic wave propagation, in [2]. Discussions of the general software synthesis process can be found in a variety of conference proceedings (e.g., [6]), books (e.g., [4]), and journals (e.g., [5]). To transform speci cations to code, SciNapse combines object-oriented, application speci c representations of algorithm and programming constructs with generic program transformations for numerical approximation, data structure selection, and program optimization. The speci cation is successively re ned through a series of levels that attempt to duplicate the analysts' problem-solving processes. The re nement process is guided by a goal mechanism that allows a mixed user/system decision making process. Design choices include questions about the desired results (which only the user can answer), and selection from among boundary conditions, numerical techniques, solvers, and so on. SciNapse will make any decision choices not speci ed by the analyst and will warn about incorrect or highly inappropriate choices speci ed by the analyst. 5

2

3

0.8

2

1

1.5 1 V 0.5 0

3 2

0.6 S

0.4

1

0.2

0.6 S

t

0.4

1

0.2

0.8

1

1 0.75 0.5delta 0.25 0

t

0

0

Figure 5: Value (left plot) and delta (right plot) as a function of spot price S and backward time t for an American call on a stock paying discrete dividends. The term of the option is one year and dividends of 0.05 are paid quarterly. american = 1, put = 0, TMax = 1., D0 = .0, K = 1., SMax = 3., sigma = .4, r=.08, divamount = 0.05, ndiv = 4, tdiv=(.125, .375, .625, .875), 100 S grid points, 40 timesteps

Knowledge Representation. SciNapse uses a mix of rules and objects to represent its knowledge of mathematics and programming. The objects parallel the way that experts think about scienti c computing so that design choices can be presented in appropriate terms and in a logical order. For example, objects represent equation sets, individual equations, and variables. Some attributes on instances of objects store relationships between the objects, such as linking an equation to all the variables it uses and linking a variable to all its equations. Attributes also store the design choices that must be made for speci c problems. For example, a representation attribute on a variable can be lled by alternatives such as full, diagonal, time-independent, and stencil. Associated design choice rules encapsulate the details of the knowledge about how to make choices. Representation choice rules, for example, examine the equations in which a variable participates to determine which alternatives are possible. Design Choice Rules. Associated with each choice (object attribute) can be constraint rules, heuristic rules, and defaults. Constraints are de nite requirements on the legal values of the alternatives; they can be based on choices made. Constraints cannot be ignored because violated constraints will lead to incorrect codes. For example, despite what might be in the speci cation, a tridiagonal solver cannot be selected if the stencil is not appropriate. Heuristics, on the other hand, are SciNapse's suggestions (also based on previous choices) and can be overridden by speci cations. For example, SciNapse might suggest using a tridiagonal solver whenever the stencil size is three, but the analyst might insist on using SOR. A default rule would be to use a speci c solver, such as SOR, in the absence of decisions made by the analyst or heuristics. Algorithm Templates. After the basic design choices are made, SciNapse constructs a program by instantiating the algorithm templates (for the evolution algorithm, the solver, etc.) as pseudo-code, inserting assignment statements based on the discretized equations. Templates also de ne interpolation methods, stopping criteria, and initializations. After lling out the template network, SciNapse globally optimizes the entire pseudo-code program and nally transforms it into C or Fortran target code. Global Optimization. SciNapse performs extensive optimization, and not just on the nal code. For example, the system keeps track of parallelism based on equation dependencies, and makes space-time tradeo s via algorithm choices and representation selections. When possible it eliminates problem variables 6

algebraically early on, reducing overhead forever thereafter. As already noted, SciNapse can recognize when a matrix has banded or other special characteristics and choose optimal data representations (based on the stencil determined by discretization methods) and iterative constructs accordingly. Computer Algebra. SciNapse derives some of its power from the use of computer algebra (it is implemented in Mathematica [1]). Computer algebra is applied, for example, to expand coordinate free equations into scalar equations in a speci ed coordinate system, transform equations in general coordinates, discretize terms with arbitrarily higher order di erencing formulas, and estimate truncation errors. Computer algebra also helps compute derived quantities such as the greeks, helps determine stencils, and helps optimize array operations for the speci c data structures (such as a stencil) in a problem.

4 Advantages of Software Synthesis Software synthesis, a powerful technology for nancial modeling as well as for scienti c computing in general,  Encourages users to explore new techniques and to experiment with novel speci cations and algorithms, because modi cations are made in terms of application-speci c and mathematical concepts instead of at the code level. For example, the change from a second order to a fourth order nite di erence scheme can be e ected by modifying one character in the speci cation le.  Easily produces high quality programs because the algebraic and clerical errors inevitable in manual coding are avoided. Accuracy analyses and convergence tests can be automated.  Provides intelligent assistance in making design choices but allows user total control if desired.  Frees users from having to learn optimizations for new architectures. Such knowledge will reside in the synthesis system itself which can make global optimizations and suggest algorithms considering both the problem and the hardware of interest.  Allows for user extension through keyword macros and equation generators, discretization rules, and abstract algorithm templates.

Acknowledgments We thank Robert Akers, Paul Ba es, Stanly Steinberg, and Robert L. Young for critical contributions to the work reported here and suggestions for improving the manuscript.

References [1] S. Wolfram, Mathematica, A System for Doing Mathematics by Computer, Addison-Wesley, 1991. [2] E. Kant, Synthesis of Mathematical Modeling Software, IEEE Software, 10 no. 3, (1993), 30-41. [3] C. Randall, E. Kant, and S. Kostek, Automatic Synthesis of Financial Modeling Codes, Proceedings of the First Annual Computational Finance Conference, International Association of Financial Engineers, Stanford CA, August 23 1996. [4] M. R. Lowry and R. D. McCartney, eds. Automating Software Design, AAAI Press / The MIT Press, Menlo Park CA, 1991. [5] W. L. Johnson and B. Nuseibeh, eds., Automated Software Engineering: An International Journal, Kluwer, The Netherlands. [6] Automating Software Design: Domain-Speci c Software Design, American Association for Arti cial Intelligence, San Jose CA, 1992. 7