The Logilab team attended (and co-organized) EuroScipy 2011, at the end of
August in Paris.
We saw some interesting posters and a presentation dealing with Python in
finance and derivative analytics [1].
In order to debunk the idea that "all computation libraries dedicated to
financial applications must be written in C/C++ or some other compiled
programming language", I would like to introduce a more Pythonic way.
You may know that financial applications such as risk management have in most
cases high computational needs. For instance, it can be necessary to quickly
perform a large number of Monte Carlo simulations to evaluate an American option
in a few seconds.
The Python community provides several reliable and efficient libraries and
packages dedicated to numerical computations:
- the well-known SciPy and NumPy libraries. They provide a complete set of
tools to work with matrix, linear algebra operations, singular values
decompositions, multi-variate regression models, ...
- scikits is a set of add-on toolkits for SciPy. For instance there are
statistical models in statsmodels packages, a toolkit dedicated to
timeseries manipulation and another one dedicated to numerical
optimization;
- pandas is a recent Python package which provides "fast, flexible, and
expressive data structures designed to make working with relational or labeled
data both easy and intuitive.". pandas uses Cython to improve its
performance. Moreover, pandas has been used extensively in production in
financial applications;
- Cython is a way to write C extensions for the Python language. Since you
write Cython code in the same way as you write Python code, it's easy to
use it. Is it fast? Yes ! I compared a simple example from Cython's
official documentation with a full Python code -- a piece of code which
computes the first kth prime numbers. The Cython code is almost thirty times
faster than the full-Python code (non-official). Furthermore, you can use
NumPy in Cython code !
I believe that thanks to several useful tools and libraries, Python can be used
in numerical computation, even in Finance (both research and production). It is
easy-to-maintain without sacrificing performances.
Note that you can find some other references on Visixion webpages:
|
Comments
When using Python and looking for performance in computations, it is useful to know about Cython of course, since it is mature, but also about Nuitka that works already and about NumPy-in-PyPy that may work some day.