March 23, 2012
We are happy to announce the release of PyQL , a new set of Python wrappers for QuantLib.
The project is available here :
* URL: http://github.com/enthought/pyql
* License: BSD license.
* Authors: Didrik Pinte, Enthought and Patrick Henaff, IAE Paris.
Why another set of Python wrappers for QuantLib?
The SWIG wrappers provide a very good coverage of the library but have
a number of pain points:
- few Pythonic optimisation in the syntax: the code a user must writeon the Python side looks like the C++ version
- no docstring or function signature available on the Python side
- complex debugging and complex customization of the wrappers
- monolithic build process
- complete loss of the C++ code organisation with a flat namespace in Python
- SWIG typemaps development is not that fun
For those reasons and to have the ability to expose some of the
QuantLib internals that could be very useful on the Python side, we
chosed another road. PyQL is build on top of Cython and creates a thin
Pythonic layer on top of QuantLib. It allows a tight control on the
wrapping and provides higher level Python integration.
- Integration with standard datatypes (like datetime objects) and numpy arrays
- Simplifed API on the Python side (e.g. usage of Handles completely hidden from the user)
- Support full docstring and expose detailed function signatures to Python
- Code organised in subpackages to provide a decent namespace, very close to the C++ code organisation
- Easy extendibility thanks to Cython and shorter build time when adding new functionnalities
- Sphinx documentation
It supports QuantLib >= 1.1 and currently builds very nicely on MacOSX
and Linux. The Windows builds will be there soon. Regarding the build
process, make sure you read the build instruction!
(Cython 0.15 needs a simple patch available in the repo)
The library comes with a decent test suite and many examples: from the
very basic option valuation to more complex heston model calibration
within an IPython notebook.
For more details, take a look at the code, contact the authors, or
discuss on the list!
We are looking forward questions, comments, contributions.
 The name is still subject to modification as PyQL is already used
by other projects unrelated to QuantLib. Suggestions are welcome!
December 30, 2010
I needed to use Quantlib with Traits on MacOSX. As the Traits backends are not available in 64bit on MacOSX with EPD, I had to build a 32bit version of Quantlib and the related swig bindings to make it work. By default, Quantlib will be built in 64bit mode and you will get the following warning when building the Python swig bindings using a 32bit Python installation (python setup.py build):
ld: warning: in /opt/local/lib/libQuantLib.dylib, file was built for unsupported file format which is not the architecture being linked (i386)
and the following error when trying to run the test (python setup.py test)
ImportError: dlopen(build/lib.macosx-10.5-i386-2.6/QuantLib/_QuantLib.so, 2): Symbol not found: __ZN8QuantLib12SmileSection6updateEv
Referenced from: /Users/dpinte/Downloads/QuantLib-SWIG-1.0/Python/build/lib.macosx-10.5-i386-2.6/QuantLib/_QuantLib.so
Expected in: flat namespace
1. Build Quantlib after making sure you do have Boost installed (you can use MacPorts for that):
./configure --enable-static --with-boost-include=/opt/local/include/ \
2. Build the swig bindings:
python setup.py build
python setup.py test
python setup.py install
And it should work fine :
Ran 25 tests in 0.889s
March 30, 2010
Playing with Mayavi, I wanted to find an easy way to use the colormap in an mlab.surf() call to display of fourth dimension. It is a very nice way to explore datasets. The image here below shows an option valuation tool that overlays the Black & Scholes call delta value on top of the surface made using the strikes, time to expiry and Black & Scholes call value.
How can you do it ?
Read the rest of this entry »
January 20, 2010
The 3rd meeting of the LFPUG is to be held on February 3 at 7PM.
- Improving NumPy performance with the Intel MKL – Didrik Pinte
- Python to Excel bridges :
- “PyXLL, a user friendly Python-Excel bridge” – Tony Roberts
- Discussion on connecting Python and Excel (xlrd/xlwt, pyinex, win32com, pyxll, …)
- Speeding up Python code using Cython – Didrik Pinte
Location: The event will be hosted by KBC Financial Products that kindly proposed a meeting room for us. For security concerns, please do RSVP at firstname.lastname@example.org to be confirmed on the attendee list. Address of the day : 111 Old Broad Street, EC2N 1FP (just opposite Tower 42)
The details are available on the Python.org wiki page.