Option Engine: a
grid enabled software package to
evaluate financial options *
Francesca Mariani, Maria
Cristina Recchioni, Francesco Zirilli
1. Introduction
3.
Some difficulties encountered in the
Option Engine project
4.
The Option Engine performance on a
grid: some numerical experiments
5.
Download the software package Option
Engine
6.
Appendix: Instructions to use the
Option Engine package
The development of parallel applications using service oriented grid-oriented
infrastructures is of great interest in several fields of practical relevance. Platform Computing is
interested in investigating the
applicability of Service Oriented Middleware (SOAM) to high performance
numerical computing. Products such as
the Platform LSF environment for Grids/Clusters, Platform Enterprise Grid
Orchestrator (EGO) grid resource management platform and Platform Symphony
Enterprise Grid package for financial services are an evidence of the work made
in this direction by Platform. The work presented in this website consists in a
software package named Option Engine that implements 27 modules of the QuantLib software library in a grid
environment consisting in the Platform Symphony Enterprise Grid package. These
modules evaluate the prices of several kinds of traded financial options. The
main novelty of the Option Engine software package is that it makes available
in the Symphony environment a relevant subset of QuantLib modules. Symphony
allows to optimize the computing resources once assigned a work load (i.e.: the
computation of the prices of several options through the use of the QuantLib
modules contained in Option Engine). As shown in Section 4
with an example, computing n modules on a computing grid in the Symphony
environment is computationally more efficient than computing the same modules
in the LSF environment (for example using a job-array).
The Option Engine package consists
of the following modules:
02. Barone-Adesi/Whaley
03. Bierksund/Stensland
04. Integral
05. Finite Differences
06. Binomial Jarrow-Rudd
07. Binomial Cox-Ross-Rubistein
08. Binomial equiprobabilities
09. Binomial Trigeorgis
10. Binomial Tian
11. Binomial Leisen-Reimer
12. Binomial Joshi
13. MC (crude)
14. QMC (Sobol)
15. MC (Longstaff Schwartz)
16. Digital payoff
17. Discrete dividends
18. Bates
19. Ju
20. FD for dividend options
21. Heston
22. Black-Scholes with Hull-White
23. Heston with Hull-White
24. MC (crude) Heston
25. QMC (Sobol) Heston
26. Heston Variance Option
27. Perturbative Barrier Option
The titles of the 27 modules are self explanatory for an user familiar with mathematical finance.
A reference for the first 25 modules can be found in http://quantlib.org/reference/group__vanillaengines.html, a reference for the 26th module can be found in
http://quantlib.org/reference/class_quant_lib_1_1_integral_heston_variance_ option_engine.html and finally a reference for the 27th module can be found in http://quantlib.org/reference/class_quant_lib_1_1_perturbative_barrier_option_engine.html
The modules 26 and 27 are derived from the
research work of the authors of this website and of their co-workers. More
specifically module 26 considers the
problem of pricing variance options (for further details see http://www.econ.univpm.it/recchioni/finance/w4)
and module 27 considers the problem of pricing barrier options in the Black Scholes
framework with time dependent coefficients (for further details see http://www.econ.univpm.it/recchioni/finance/w3).
The realization of the Option Engine package
has been made possible thank to the effort of CERI Università di Roma “
For the convenience of the reader we give below some information about Symphony
and QuantLib.
Symphony
is a grid computing middleware that enables to build and deploy rapidly
distributed services through a single, high-level paradigm for multi-core and
multi-node environments. Platform Symphony is widely deployed by financial
institutions to process computer and time-sensitive applications, such as
trading, pricing, risk analysis, profit and loss reporting and trade
settlement, in real time across an Enterprise Grid computing infrastructure. Recently
available as a free trial download, Platform Symphony Developer Edition (DE)
provides developers with powerful HPC tools to build and deploy
service-oriented applications. With comprehensive and easy to follow coding
examples, developers can create and test out high-performance application
services in the language of their choice in record time. The demo of
QuantLib is
a C++ Open Source library for financial quantitative analysis that contains
source codes of several kinds: codes that perform mathematical operations, such
as constrained and unconstrained optimization and/or interpolation, codes that
generate random numbers sampled from a given probability distribution, and
codes that compute the price of derivative contracts with assigned parameters.
The library boost must be installed to be able to use
QuantLib.
In
the past years we have carried out two projects that can be considered as
preliminary steps to the project presented here, that is:
1. The use of Symphony to grid enable a
Fortran routine for the pricing of variance options (see http://www.econ.univpm.it/recchioni/finance/w4).
The grid-enabled version of the Fortran routine has been realized providing a
Fortran dll and inglobing it in a suitable C++ program that calls the Fortran
dll. The Symphony enabled version of the Fortran routine used to price variance
options is available at the website http://www.econ.univpm.it/recchioni/finance/w4.
2. A preliminary work that shows the
feasibility of taking a specific algorithm in the QuantLib library (http://quantlib.org/) and enable it on the grid
through Symphony (see http://www.ceri.uniroma1.it/ceri/zirilli/w2).
In particular in http://hpccommunity.org/f13/simple-option-applications-using-symphony-quantlib-15/ two packages have been provided: bs_symphony
and mc_symphony. These packages contains
Symphony applications that make available in the Symphony environment two
QuantLib codes that implement the evaluation of the price of a European call/put
option with prescribed value of the underlying, of the volatility, of the
discount factor and of the strike price using the Black Scholes
formula (bs_symphony) and using the Monte Carlo method
(mc_symphony). These packages have been made available in Symphony
environment transforming the
applications originally written as C++
codes contained in QuantLib in dll
libraries that usually have extensions
“a” (for example math.a). These dll
libraries are put in a bigger dll
library that contains also the Symphony libraries needed for the input/output
operations and for the environment management. Note that the input/output instructions
must be adapted to the input/output needs of
the application. In the website http://www.ceri.uniroma1.it/ceri/zirilli/w2
the steps that must be performed to make available in the Symphony environment
the QuantLib pricing engines Black Scholes and
The new project that we are presenting
here can be summarized as follows:
3. The main idea of the project is the extension of the work described in 2
to develop a more complete software package. The workflow of the project has been the
following:
a)
QuantLib developers have provided a generic infrastructure to
grid-enable QuantLib algorithms and have integrated in the latest version of
QuantLib (version 0.9.7) two routines developed by the authors and their
co-workers. The first routine is a C++ version of the Fortran routines described in 1 for pricing variance options
(module 26) and the second routine is a routine to price barrier options with
time dependent parameters (module 27). These two routines integrated in
QuantLib are Heston Variance Option (see
http://quantlib.org/reference/class_quant_lib_1_1_integral_heston_variance_
option_engine.html, for further details see read_me_variance_options),
and Perturbative Barrier Option (see http://quantlib.org/reference/class_quant_lib_1_1_perturbative_barrier_option_engine.html,
for further details see read_me_perturbative_barrier_options),
b)
Symphony developers have provided a modified version of the bs_symphony
mentioned in 2 that runs under Symphony
DE 4.0 and is able to read data from a file and to provide its output on video
and on file,
c)
CERI - Università di Roma “
In this Section we describe some of
the difficulties encountered in the realization of the Option Engine project.
The items a) and b) of the project
have been realized making Symphony enabled some
C++ functions. This enabling can
be obtained easily using a C++ code that calls the functions that must be
Symphony enabled and using the files client.cpp and service.cpp to assign the input parameters. In
the realizations made in items a) and b) the input data are read by video and the file
client.cpp and service.cpp had to be modified when some new input parameters had
to be introduced. This structure is heavy and has been improved in the final
realization of item c).
A preliminary realization of item c)
is the package equi_symphony2.zip. This package has been
realized without improving the input output operations. In fact it was necessary
first of all to overcome the difficulty coming from the need of invoking a C++
class in a Symphony environment. The
package equi_symphony2.zip realized the
call to C++ classes in a Symphony environment
and made Symphony enabled fifteen
QuantLib routines (see http://quantlib.org/reference/examples.html)
to evaluate several kinds of vanilla options in financial applications (such as, for
example, call and put European, American and Bermudan options in the Black
Scholes world).
The package equi_symphony2.zip runs under
Symphony version 2.6. This version of Symphony does not allow to enable more
than one application at a time. This justify the use Symphony DE 4.0 instead
than Symphony version 2.6 to overcome this limitation and to complete the project producing a software package able
to read data from files. The Symphony
developers had produced a sample of how to proceed to go from Symphony version
2.6 to Symphony DE 4.0 that is available in the HPC forum http://hpccommunity.org/f13/simple-option-applications-using-symphony-quantlib-15/
. We have analyzed this software in order to realize the item c) of the project.
Some other difficulties encountered in pursuing the
realization of the Option Engine package are listed below.
(i-1) The Fortran codes that
price the variance options in the Heston
model framework available in the web-site http://www.econ.univpm.it/recchioni/finance/w4 and the Fortran code that prices barrier options
in the time dependent Black Scholes framework available in the web-site http://www.econ.univpm.it/recchioni/finance/w3 have been translated in C++ language to be integrated in QuantLib.
The main difficulty of the
translation work has been the correct
implementation of the input operations. In fact the input parameters in
QuantLib must be introduced using suitable QuantLib functions. Furthermore the C++ codes implemented (variance options
and barrier options) require user supplied functions and these input functions
must be introduced as input data. This difficulty has been overcome introducing
example codes to run these routines. These example codes are available in the test-suite of QuantLib in
the web-site: https://quantlib.svn.sourceforge.net/svnroot/quantlib/trunk/QuantLib/test-suite.
Thank to the work of QuantLib
developers the C++ codes
resulting from the translation have been integrated in the repository of QuantLib and are available in the website: https://quantlib.svn.sourceforge.net/svnroot/quantlib/trunk/QuantLib/ql/experimental.
These codes have been tested before
the integration in the new release of
the QuantLib library .
(i-2) The test of the C++ routines for pricing variance options
and barrier options as members of the repository of QuantLib has not been an easy
task since we had to run the routines with a QuantLib library subversion. This
last fact implied that some
modifications of the varianceoption.cpp and of the barrieroption.cpp files were
necessary because of some troubles with the boost and with some auxiliary QuantLib
routines (i.e. FlatRate).
(i-3) We made Symphony enabled the 25 routines of
the Vanilla Option Engine in Symphony DE 4.0 environment. This application reads
the input parameters from a file and produces an output file. The reading from
a file makes the structure of the file client.cpp independent of the particular module considered simplifying the Symphony enabling
procedure of scientific modules. In this
phase the main difficulty was the comprehension of the Symphony DE approach to the input/output operations and the
realization of the new client.cpp and service.cpp files.
(i-4) Once available the latest
version of QuantLib (version 0.9.7), we added to the 25 routines mentioned
(i-3) the two new QuantLib routines
(i.e.: modules 26 and 27) to realize
the Symphony enabled Option Engine
package. The main difficulty in the realization of the C++ code that calls the
27 routines has been the use of the QuantLib
“DayCounter” subprogram since the
Barrier Option module (module 27) uses a
DayCounter different from the others QuantLib modules.
The service.cpp application has been modified
in order to introduce the output of these 27 routines both on a file, named
“result.txt” and on video.
In this section we compare the
performance of Symphony with the performance of the LSF job array. The LSF job
array is a LSF instruction able to submit simultaneously up to 1000 copies
of the same code
with different input data. This instruction allocates the jobs on the free processors following a sequential order, that is when one
of the processors of the grid is free a job is allocated on it. Using the job array instruction no
considerations are made about the computing load of the grid at the time when
the jobs are submitted. An example of the job array instruction is:
bsub –m hostname
–J”name_we_want”[1-100] $PWD/nome_executable_file
The previous instruction submits 100
copies of the executable file named
“nome_executable_file”.
Symphony is able to perform a smart
allocation of the jobs that must be executed by a preliminary study of the free
resources of the grid and of the
computing load present on the grid at the time when the jobs are submitted.
The following results have been
obtained using a Linux machine with 4
processors and kernel 2.4 with LSF system software.
We have considered as computing load
the computation of six or twelve barrier options using module 27. The following
tables show the results of a comparison between the use of Symphony and the use of LSF job array.
Note that the Symphony jobs and the
LSF jobs are submitted at the same time.
Table 1
|
Method used to compute the 6 modules |
Execution Time (expressed in seconds) |
|
Interactive run with one processor |
1080 |
|
Symphony run |
535 |
|
LSF job-array [1-6] run |
575 |
Table 2
|
Method used to compute the 12 modules |
Execution Time (expressed in seconds) |
|
Interactive run with
one processor |
2124 |
|
Symphony run |
1064 |
|
LSF job-array [1-12]
run |
1118 |
We note that the use of the Symphony
package reduces the computing time of about 40 seconds in Table 1 and of about a
minute in Table 2 that is we have a time
reduction of 7.5 per cent and 6 per cent
respectively. This effect increases when we use a larger number of processors.
In this experiment Symphony was able to use immediately at least 50% of the
resources at our disposal and to distribute suitably the computing load among
the resources. On the contrary the distribution of the load in the job-array instruction
is fixed a priori by the user that chooses the number and the order of the jobs
and the job array instruction, in our experience, does not use at least the 50% of the available
resources as done by Symphony. Generally this percentage is smaller than 50%
and this fact probably is the reason of the difference between the execution
times shown in the tables. The advantage of using Symphony increases when the computation
to be executed, the computing grid used and the load present on the grid become
more complex. Note that as shown in
Table 1, 2 the advantage of using
Symphony reduces when the number of tasks that must be executed
increases, in fact the margin to improve the allocation of the jobs on the
computing resources reduces due to the heavy
load already present on the computing resources.
To
download the software package Option Engine click
here
The package has the following structure:
OptionEngine/
README
you are reading this file
OptionEngine.xml the service description file
client/ the application client code
service/ the application service code
mathlib/ the library of the QuantLib
Option Engine
common/
common classes to client and server
This
application has been tested on a Linux machine with kernel 2.4 where there are
installed LSF, Symphony, QuantLib-0.9.7, and boost-1_33_1.
The archive OptionEngine.zip
contains a Symphony DE 4.0 application named OptionEngine that computes 25 modules
of the Vanilla Option Engines of the QuantLib library and 2 extra modules of
the QuantLib library (0.9.7). That is 27 functions are implemented (see Introduction).
The
OptionEngine application reads the input data from a file and writes the
results on a file named result.txt and on the video.
We
provide the file example.txt that contains a
test case for each set of input parameters required by the modules. This file
is contained in the directory “output” .
Warning: Remind that in order to generate the executable version of
OptionEngine the user must run the
makefile contained in the directories: mathlib, common, service, client
(download read_me.txt).
Note that in the makefile
contained in the directory mathlib the user must change two paths that refer to
the QuantLib-0.9.7.a:
LIBF2C = insert the path to /lib/libQuantLib-0.9.7.a
and that refer to the boost:
$(G++) -I insert path to Quantlib
--> /include -I insert path to boost -->
/boost/include/boost-1_33_1 -c EquityOption1.cpp
Note that in the makefile
contained in the directory service the user must change a path that refers to
the QuantLib-0.9.0.a:
MATT= insert the path to /lib/libQuantLib-0.9.7.a
We
assume that Symphony is installed in the directory /$HOME/symphonyDE/DE40/.
To install the two libraries boost-1_33_1 and
QuantLib-0.9.7 it is necessary to download
in /home/boost/ from the website the
following compressed files: boost-1_33_1.tar.gz and boost-jam-3.1.13-1-linuxx86.tar
and in /$HOME/quantlib/ from the website
QuantLib-0.9.7.tar.gz.
To
install Boost-1_33_1 the following commands are necessary:
>>
cd /$HOME/boost/
>>
tar zxvf boost-1_33_1.tar.gz
>>
cp boost-jam-3.1.13-1-linuxx86.tar $HOME/boost-1_33_1/.
>>
tar zxvf boost-jam-3.1.13-1-linuxx86.tar
>>
configure –prefix = $HOME/boost/
>>
make install
To
install QuantLib-0.9.7 the following commands are necessary:
>>
cd $HOME/quantlib/
>>
tar zxvf QuantLib-0.9.7.tar.gz
>> configure –disable-shared
--with-boost-include=/home/boost/include/boost-1_33_1 –with-boost-lib= $HOME/boost/lib
–prefix= $HOME/quantlib
>> make install
Finally we update the library path:
>> export LD_LIBRARY_PATH = $HOME/boost/
>> export LD_LIBRARY_PATH = $HOME/quantlib/
In order to make available in the Symphony environment the Option Engine
we must perform the following steps:
1) We connect to a server, where
Symphony, Quantlib and boost are installed, with the network protocol ssh. We entry in the subdirectory $HOME/symphonyDE/DE40/conf and start Symphony
through the commands:
>> . profile.soam
>>
soamstartup &
2) We copy the content of the package
Option Engine, that can be downloaded from this website, in a new subdirectory
of $HOME/symphonyDE/DE40/4.0/ named OptionEngine
3)
We write a C++ code:
the EquityOption1.cpp that contains the call to the QuantLib class. Click here
to see the code EquityOption1.cpp. Go down in the directory of $HOME/symphonyDE/DE40/4.0/EquityOption/mathlib. The code EquityOption1.cpp can be compiled and
a suitable library generated using the command:
>>./make
4)
Go
down in the directory of $HOME/symphonyDE/DE40/4.0/EquityOption/common.
Generate the communication library using the command:
>>./make
5) Go down in the directory of $HOME/symphonyDE/DE40/4.0/EquityOption/service.
We modify the file service.cpp to call
the routine contained in EquityOption1.cpp. Create the executable file
service in the directory: $HOME/symphonyDE/DE40/4.0/EquityOption/output/
with the command:
>>./make
6)
Go down in the directory of $HOME/symphonyDE/DE40/4.0/EquityOption/client.
Generate the client executable file in the directory: $HOME/symphonyDE/DE40/4.0/EquityOption/output
using the command:
>>./make
7) In the directory $HOME/symphonyDE/DE40/4.0/OptionEngine/output/,
compress the file service and deploy the compressed file with the following commands:
>> tar cvf service.tar
service
>> gzip service.tar
>> soamdeploy add OptionEngineServicePkg -p service.tar.gz -c
/OptionEngine
8) In the directory $HOME/symphonyDE/DE40/4.0/OptionEngine/,
create the application profile, OptionEngine.xml.
>> soamreg $HOME/symphonyDE/DE40/4.0/OptionEngine/OptionEngine.xml
9) Confirm that the registration worked properly by
running the following command;
>> soamview app
that verifies if the application,
OptionEngine, is enabled.
10) Now you can run the client of new Symphony
application, OptionEngine, in the directory $HOME/symphonyDE/DE40/4.0/OptionEngine/output/
with the following command:
>>./client [input file name]
[number of tasks]
Note: [input file name] is a text file containing
input data (example.txt can be used). Each line in the file consists of the parameters that must be given
as input parameters to call QuantLib routines.
[number of tasks] is a number of splits applied
to your tasks input. If the input file contains 10,000 lines and [number of tasks]
= 4, then there will be 4 tasks, each containing 2,500 lines of input data.
Input file template (download template_data.txt):
Example of parameters necessary for modules: 01, 04, 13, 14, 22
module number, type call/put, month, day, year, maturity month, maturity day,
maturity year, underlying, strike, dividend, risk free interest rate, volatility
1, 1, 5, 20, 2008, 12, 20, 2012, 1.0, 0.85, 0.0, 0.03, 0.2
Example of parameters necessary for modules: 02,03,15,16,19
module number, type call/put, month, day, year, maturity month, maturity day,
maturity year, underlying, strike, dividend, risk free interest rate, volatility,
month (American options), day (American options), year (American options)
1, 1, 5, 20, 2008, 12, 20, 2012, 1.0, 0.85, 0.0, 0.03, 0.2, 9, 23, 2009
Example of parameters necessary for modules: 05,06,07,08,09,10,11,12
module number, type call/put, month, day, year, maturity month, maturity day,
maturity year, underlying, strike, dividend, risk free interest rate, volatility,
month (American options), day (American options), year (American options),
number of exercise dates (max 400) (Bermudan options), list of dates (month, day, year) at
which the option can be exercised.
1, 1, 5, 20, 2008, 12, 20, 2012, 1.0, 0.85, 0.0, 0.03, 0.2, 0, 0, 0, 3, 6, 20, 2008, 12, 20, 2009, 5, 20, 2010
Example of parameters necessary for modules: 17, 20
module number, type call/put, month, day, year, maturity month, maturity day,
maturity year, underlying, strike, dividend, risk free interest rate, volatility,
type of dividend months (1=one month, 2=two months,..., only for dividend options), number of dividend months
1, 1, 5, 20, 2008, 12, 20, 2012, 1.0, 0.85, 0.0, 0.03, 0.2, 2, 5
Example of parameters necessary for module: 18
module number, type call/put, month, day, year, maturity month, maturity day,
maturity year, underlying, strike, dividend, risk free interest rate, volatility,
initial stochastic variance, speed of mean reversion, long term mean variance, vol of vol, correlation coefficient,
lambda Poisson process intensity, mean of Poisson logarithm process, volatility of the Poisson logarithm process
1, 1, 5, 20, 2008, 12, 20, 2012, 1.0, 0.85, 0.0, 0.03, 0.2, 0.2, 3.2, 0.02, 0.14, -0.6, 0.2, 4, 0.4
Example of parameters necessary for methods when we want to price options under Heston model: 21,23,24,25
module number, type call/put, today month, today, today year, maturity month, maturity day,
maturity year, underlying, strike, dividend, risk free interest rate, volatility,
initial stochastic variance, speed of mean reversion, long term mean, vol of vol, correlation coefficients
1, 1, 5, 20, 2008, 12, 20, 2012, 1.0, 0.85, 0.0, 0.03, 0.2, 0.2, 3.2, 0.02, 0.14, -0.6
Example of parameters necessary for module: 26
module number, type call/put, today month, today, today year, maturity month, maturity day,
maturity year, underlying, strike, dividend, risk free interest rate, volatility,
initial stochastic variance, speed of mean reversion, long term mean, vol of vol, correlation coefficients
26, 1, 12, 18, 2008, 12, 18, 2009, 1.0, 0.05, 0.0, 0.0, 0.1, 2.0, 2.0, 0.02, 0.1, -0.5
Example of parameters necessary for module: 27
module number, type call/put, month, day, year, maturity month, maturity day,
maturity year, underlying, strike, dividend, risk free interest rate, volatility (this value is not used,
the volatility is defined in the code EquityOption1), barrier value
27, -1, 12, 18, 2008, 12, 18, 2009, 100.0, 101.0, 0.02, 0.03, 0.1, 101.0
References:
1. http://quantlib.org/index.shtml
2. http://www.ceri.uniroma1.it/ceri/zirilli/w2
3. http://www.econ.univpm.it/recchioni/finance/w3/
4. http://www.econ.univpm.it/recchioni/finance/w4/
* A
donation of Platform Computing (Toronto, Canada) to CERI – Università di Roma “