HPCCommunity.org
 
Register

Go Back   HPC Community - High Performance Computing (HPC) Community > Symphony Developer Edition (DE) > Applications, Enhancements and Modifications

Applications, Enhancements and Modifications Share your Symphony DE applications, enhancements and modifications with the community here.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 5th, 2008, 11:28 PM
Young's Avatar
Junior Member
 
Join Date: March 5th, 2008
Location: Toronto, Canada
Posts: 58
Blog Entries: 1
Send a message via Skype™ to Young
Default Simple option pricing applications using Symphony and QuantLib

1. Introduction

QuantLib is a C++ Open Source library for financial quantitative analysis that contains several kinds of source code; code that perform mathematical operations, such as constrained and unconstrained optimization and/or interpolation, code that generates random numbers sampled from a given probability distribution and code that computes the price of derivative contracts with assigned parameters. QuantLib usually requires another library called the Boost library.



bs_symphony and mc_symphony are packages containing Symphony applications that implement, using the QuantLib API, the evaluation of the price of a call option with the prescribed values of underlying volatility, discount factor and strike price with Black Scholes formula (bs_symphony) and a Monte Carlo method (mc_symphony), respectively.

The two packages have the following structure:

bs_symphony/
README
black.xml: Application profile
client/: Application client code
service/: Application service code
mathlib/: Library of Black and Scholes engine written with QuantLib API.
common/: Message classes used by client and service

mc_symphony/
README
mc.xml: Application profile
client/: Application client code
service/: Application service code
mathlib/: Library of QuantLib Monte Carlo engine written with QuantLib API
tools/: Tools to read files and process user input
common/: Message classes for by client and service


The Symphony environment can be configured to have service code depend on any libraries. In this case, it is necessary to convert the application originally written with C++ QuantLib into a static library with the extension 'a' (for example math.a). This library is put in a bigger library that also contains the Symphony libraries needed for the input/output operations. Note that the input/output instructions must be adapted to the input/output needs of the application.

In Section 2, instructions for the QuantLib installation are briefly explained.
In Section 3, we describe the steps that must be performed to make the pricing engines available in the Symphony environment as services.

2. QuantLib installation

The QuantLib applications were tested on Linux with kernel 2.4 and 2.6. The QuantLib applications were written in QuantLib 0.9.0, Boost 1.34.1 and Symphony DE 4.0 API and compiled with g++ 3.4.3
We assume that Symphony DE is installed in the directory ${HOME}/SymphonyDE

To install two libraries, Boost 1.34.1 and QuantLib 0.9.0, it is necessary to download the following compressed files: boost-1_34_1.tar.gz and boost-jam-3.1.13-1-linuxx86.tar in ${HOME}/boost/ from the website and QuantLib-0.90.tar.gz in /home/quantlib/ from the website

To install Boost 1.34.1 the following commands are necessary (we assume Bash):
>> cd ${HOME}/boost/
>> tar zxvf boost-1_34_1.tar.gz
>> cp boost-jam-3.1.13-1-linuxx86.tar ${HOME}/boost-1_34_1/.
>> tar zxvf boost-jam-3.1.13-1-linuxx86.tar
>> configure prefix = ${HOME}/boost/
>> make install
To install QuantLib-0.9.0 the following commands are necessary:
>> cd ${HOME}/quantlib/
>> tar zxvf QuantLib-0.90.tar.gz
>> configure -disable-shared --with-boost-include=${HOME}/boost/include/boost-1_34_1 --with-boost-lib=${HOME}/boost/lib -prefix=${HOME}/quantlib
>> make install
Finally, update the library path:
>> export LD_LIBRARY_PATH = ${HOME}/boost/
>> export LD_LIBRARY_PATH = ${HOME}/quantlib/
3. How to run bs_symphony

To make the Black Scholes pricing engine in QuantLib available in the Symphony environment as a service, you must perform the following steps:

1) Connect to the server where Symphony, Quantlib and Boost are installed. Source the necessary Symphony environment and start up Symphony through the following commands:
>> . profile.soam
>> soamstartup &
2) Uncompress the bs_symphony package, in ${HOME}/SymphonyDE/4.0/

3) Build the application with following commands;
>> cd ${HOME}/SymphonyDE/4.0
>> export QUANTLIB path_to_the_quanlib_library
>> make
4) In the directory ${HOME}/SymphonyDE/4.0/bs_symphony/output/, compress the file service and deploy the compressed file with the following commands;
>> tar cvf service.tar service
>> gzip service.tar
>> soamdeploy add BlackScholesServicePgk -p service.tar.gz -c /BlackScholes
5) In the directory ${HOME}/SymphonyDE/4.0/bs_symphony/, create the application profile, black.xml.
>> soamreg ${HOME}/SymphonyDE/4.0/bs_symphony/black.xml
6) Confirm that the registration worked by running the following command;
>> soamview app
Verify that the application, BlackScholes, is enabled.

7) Now you can run the client of new Symphony application, BlackScholes (bs_symphony), in the directory ${HOME}/SymphonyDE/4.0/bs_symphony/output/ with:
>>./client [input file name] [number of tasks]
Note: [input file name] is a text file containing input data. Each line in the file that consists of 4 input parameters, value of underlying, volatility, discount factor and striking price, is separated by comma. [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.

4. How to run mc_symphony

1) Make sure you did step 1) in section 3.

2) Uncompress the bs_symphony package, in ${HOME}/SymphonyDE/4.0/

3) Build the application with following commands;
>> cd ${HOME}/SymphonyDE/4.0
>> export QUANTLIB path_to_the_quanlib_library
>> make
4) In the directory ${HOME}/SymphonyDE/4.0/mc_symphony/output/, compress the service executable file and deploy the compressed file with the following commands;
>> tar cvf service.tar service
>> gzip service.tar
>> soamdeploy add MonteCarloServicePkg -p service.tar.gz -c /MonteCarlo
5) In the directory ${HOME}/SymphonyDE/4.0/mc_symphony/, create the application profile, mc.xml.
>> soamreg ${HOME}/SymphonyDE/4.0/mc_symphony/mc.xml
6) Confirm the registration by running the following command;
>> soamview app
Verify that the application, MonteCarlo, is enabled.

7) Now you can run the client of new Symphony application, MonteCarlo (mc_symphony), in the directory ${HOME}/SymphonyDE/4.0/bs_symphony/output/ with:
>> ./client
Note: The program will prompt the user for the following parameters: strike price, dividend, risk free rate, volatility. Once all parameters are entered, the client passes the input parameters to the Monte-Carlo engine in the Symphony service and the service will return the result. The user is then prompted for a new set of values. To exit from the program press enter entering an empty line or press ctrl^D.

Example:
>> ./client
connection ID=85ed12c6-ffff-ffff-c000-00096be63153-3033787312-7879
Session ID:104
value of underlying = 42.5
strike_price = 42.5
dividend = 0.8
risk free rate = 0.1
volatility = 0.239
Computing.....
The option discounted value is 3.8345
done

5. Performance implication

Note that bs_symphony is slightly different from mc_symphony in terms of client interface. It takes multiple sets of inputs and creates tasks in larger chunks, because sending small tasks one by one is less efficient due to the network overhead. You may control the size of a chunk by specifying the second argument, [number_of_tasks] to the client command of bs_symphony, to find the optimal task granularity.

6. Acknowledgement

Francesca Mariani (fra_mariani@libero.it) and Francesco Zirilli (f.zirilli@caspur.it) from CERI University of Roma have contributed to the implementation of samples.
Attached Files
File Type: email bs_symphony.tar.gz (169.5 KB, 23 views)
File Type: email mc_symphony.tar.gz (112.4 KB, 14 views)

Last edited by Ajith; March 28th, 2008 at 03:10 PM..
Reply With Quote
  #2 (permalink)  
Old August 5th, 2008, 04:10 PM
Junior Member
 
Join Date: August 5th, 2008
Posts: 1
Default

thank you to young for posting this thread
i am a high school student, currently working at the university of alberta
for my thesis (IB Extended Essay) i chose to develop a simple options pricing model
and it looks like if i implement symphony, quantlib, and boost i will have some success

i do have background in C++, so i should be able to work with this code

do you think i am going about this the right way, or i have i misunderstood something?
Reply With Quote
  #3 (permalink)  
Old August 11th, 2008, 07:23 PM
Junior Member
 
Join Date: May 16th, 2008
Posts: 4
Default Trouble Building Sample

Below some facts and a request for your help.

Facts:
1 the bs_symphony available in the Forum for Symphony DE done by Young has been downloaded and compiled in the Symphony DE 4.0 environment installed by David on the ENEA lin4p machines,
2 the client and service make files of bs_symphony give some compilation errors,
3 the MyMessage.Cpp and the MyMessage.h files of the Symphony DE 4.0 and of the Symphony 3.0 are different and incompatible.Is this the way it should be?

Help:
1 can you give us a version of the work of Young that works in the Symphony DE 4.0 environment installed by David on the ENEA machines ?

Thank you very much for your help.
Regards
Francesco
Reply With Quote
  #4 (permalink)  
Old August 11th, 2008, 07:45 PM
Ajith's Avatar
Symphony DE Moderator
 
Join Date: February 28th, 2008
Location: Markham, Ontario
Posts: 86
Blog Entries: 2
Default Trying Sample

Quote:
Originally Posted by alexsahu View Post
thank you to young for posting this thread
i am a high school student, currently working at the university of alberta
for my thesis (IB Extended Essay) i chose to develop a simple options pricing model
and it looks like if i implement symphony, quantlib, and boost i will have some success

i do have background in C++, so i should be able to work with this code

do you think i am going about this the right way, or i have i misunderstood something?
Hi Alexsahu,

If you are familiar with coding in C++ and have Windows or a Supported Linux version, then you should have no trouble building our sample.

If you are just interested in creating an option pricing model, start with Quantlib and see whether you can implement what you want with it. Check the Quantlib community forums for more information about it; Nabble - QuantLib forum

Symphony will grid-enable Quantlib. This means that if you have 1000's of sets of parameters you want calculated, Symphony will run those calculations in parallel and give you a result faster than running all those calculations on one machine. This project is still in progress, so we still need to do some optimizations to make Quantlib run well on Symphony.

- Ajith
Reply With Quote
  #5 (permalink)  
Old August 11th, 2008, 08:13 PM
Ajith's Avatar
Symphony DE Moderator
 
Join Date: February 28th, 2008
Location: Markham, Ontario
Posts: 86
Blog Entries: 2
Default Building Sample

Quote:
Originally Posted by f.zirilli View Post
Below some facts and a request for your help.

Facts:
1 the bs_symphony available in the Forum for Symphony DE done by Young has been downloaded and compiled in the Symphony DE 4.0 environment installed by David on the ENEA lin4p machines,
2 the client and service make files of bs_symphony give some compilation errors,
3 the MyMessage.Cpp and the MyMessage.h files of the Symphony DE 4.0 and of the Symphony 3.0 are different and incompatible.Is this the way it should be?

Help:
1 can you give us a version of the work of Young that works in the Symphony DE 4.0 environment installed by David on the ENEA machines ?

Thank you very much for your help.
Regards
Francesco
Hi Francesco,

MyMessage.cpp may change, but according to our SDK expert, you should be able to use your 3.0 code with the 3.0 MyMessage and 4.0 code with the 4.0 MyMessage. Just don't mix them up.

Are you just trying to build Young's sample with no changes? This should work. Can you send me the compile errors?

Note: Make sure that the TOP variable in each Makefile points to your $SOAM_HOME/4.0 directory.

- Ajith

Last edited by admin_soam; August 11th, 2008 at 08:29 PM..
Reply With Quote
  #6 (permalink)  
Old October 4th, 2008, 06:50 AM
Junior Member
 
Join Date: May 16th, 2008
Posts: 4
Default vanillaDE: a Symphony enabled version of QuantLib Vanilla Option Engine

The archive vanillaDE.zip contains a Symphony DE 4.0 application named vanillaDE that computes
the modules of the Vanilla Option Engine of the library QuantLib 0.9.0.

In particular 25 functions are implemented:

01. Black-Scholes
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 Svhwartz)
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

The vanillaDE application reads the input data from a file and writes the results on a file named result.txt and
on the video.

We provide two files: template_data.txt and example.txt

a) template_data.txt explains how the user must provide the input data according with the module number (i.e.: 01 (Black Scholes), 02 (Barone Adesi/Whaley,
...,25 (QMC (Sobol) Heston)).

b) example.txt is an input file that contains a test case for each set of input parameters required by the modules.


Remind that in order to generate the executable version of vanillaDE the user must run the makefile contained in the directories: mathlib, common, service, client.


Note that in the makefile contained in the directory mathlib the user must change two paths that refer to
the QuantLib-0.9.0.a:

LIBF2C = insert the path to /lib/libQuantLib-0.9.0.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.0.a

Regards
Francesco
Attached Files
File Type: zip vanillaDE.zip (49.6 KB, 1 views)
File Type: txt example.txt (1.2 KB, 0 views)
File Type: txt template_data.txt (3.9 KB, 0 views)
Reply With Quote
Reply

Tags
black-scholes, boost, monte carlo, option pricing, quantitative analysis, quantlib, symphony

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:07 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.