Challenge an ad-hoc way to make giant projects (in case of Quantlib, about half million LOC) work in a parallel computing style that supports both multiple processes and multiple threads by adding as little codes as possible.
It's NOT an integral version-up for Quantlib users but a test bed of the integrity and extensibility of HPC how a fulcrum can pry to a whole project. In this case, I added about few hundreds of lines (less than 1% of the whole project) of code and started working from the base classes which are inherited by many top-level objects and functions.
For now it supports multiple threads in a particle size of Instrument, that is, one pricing engine (in some case it's bounded with a certain time-consuming stochastic process) works in an independent single thread for a single instrument.
Meanwhile, it provides a protocol to use MPI that can support multiple processes to manage the main thread and the instruments can be grouped to different processes in a in a particle size of "Portfolio" as to be a future work.
You have a basket of options to be monitored and performed by calculations using different pricing engines for different option types. And each option may use different engines (BSM, Binomial, MC for an example) to compare the NPV or other indicators for the purpose of your strategy.
std::cout << europeanOption->NPV() << std::endl;
bermudanOption->setPricingEngine(binomialEngine);
std::cout << bermudanOption->NPV() << std::endl;
americanOption->setPricingEngine(mcEngine);
std::cout << americanOption->NPV() << std::endl;
In a new asynchronous mode, it works like
bermudanOption->setPricingEngine(binomialEngine);
americanOption->setPricingEngine(mcEngine);
portfolio->reset();
portfolio->subscribeSignal(europeanOption);
portfolio->subscribeSignal(bermudanOption);
portfolio->subscribeSignal(americanOption);
portfolio->start();
It supports three kinds of broadcasting strategies to communicate all the signals from different processes and threads.
All signals from each process and its threads will be broadcasted to all other processes (full connection).
Main processes will gather all signals from other processes and their threads. (inward start connection)
Main processes will broadcast its signals to other processes and their threads. (outward start connection)
Run " .\mpiexec.exe -n [Number of Processes] Solution Directory\Examples\EquityOption\bin\EquityOption-x64-mt-gd.exe"
# define QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN
-- Boost (http://www.boost.org)
https://github.com/lballabio/QuantLib
The QuantLib project (http://quantlib.org) is aimed at providing a comprehensive software framework for quantitative finance. QuantLib is a free/open-source library for modeling, trading, and risk management in real-life.
QuantLib is Non-Copylefted Free Software and OSI Certified Open Source Software.
QuantLib can be downloaded from http://quantlib.org/download.shtml; installation instructions are available at http://quantlib.org/install.shtml for most platforms.
Documentation for the usage and the design of the QuantLib library is available from http://quantlib.org/docs.shtml.
A list of changes for each past versions of the library can be browsed at http://quantlib.org/reference/history.html.
The preferred channel for questions (and the one with the largest audience) is the quantlib-users mailing list. Instructions for subscribing are at http://quantlib.org/mailinglists.shtml.
Bugs can be reported as a GitHub issue at https://github.com/lballabio/QuantLib/issues; if you have a patch available, you can open a pull request instead (see "Contributing" below).
The preferred way to contribute is through pull requests on GitHub. Get a GitHub account if you don't have it already and clone the repository at https://github.com/lballabio/QuantLib with the "Fork" button in the top right corner of the page. Check out your clone to your machine, code away, push your changes to your clone and submit a pull request; instructions are available at https://help.github.com/articles/fork-a-repo.
In case you need them, more detailed instructions for creating pull requests are at https://help.github.com/articles/using-pull-requests, and a basic guide to GitHub is at https://guides.github.com/activities/hello-world/. GitHub also provides interactive learning at https://lab.github.com/.
It's likely that we won't merge your code right away, and we'll ask for some changes instead. Don't be discouraged! That's normal; the library is complex, and thus it might take some time to become familiar with it and to use it in an idiomatic way.
We're looking forward to your contributions.