PyQL : a new set of Python wrappers for QuantLib

March 23, 2012

Hi folks,

We are happy to announce the release of PyQL [1], 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.

Features:

  1. Integration with standard datatypes (like datetime objects) and numpy arrays
  2. Simplifed API on the Python side (e.g. usage of Handles completely hidden from the user)
  3. Support full docstring and expose detailed function signatures to Python
  4. Code organised in subpackages to provide a decent namespace, very close to the C++ code organisation
  5. Easy extendibility thanks to Cython and shorter build time when adding new functionnalities
  6. 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.

[1] The name is still subject to modification as PyQL is already used
by other projects unrelated to QuantLib. Suggestions are welcome!

Advertisements

Cloud computing with Python and Excel : picloud integration

March 12, 2010

Further to my previous post about making Python GUI interact with Excel, we thought it would be interesting to test how cloud computing could be easily accessible from Excel using Python and the picloud library.

We have just added interfaced some Python code that do compute the put and call price of a stock based on a Black & Scholes Monte-Carlo simulation. We end up with one function call in Excel :

Pyxll integration with picloud

Implementation details
Read the rest of this entry »


Interactive Python graphics/visualisation with Excel

March 12, 2010

Making Excel users benefit of the quick and powerful Python GUI tools was an idea that looked pretty interesting.

The two main arguments for that are :

  1. Python code is easily maintainable, tested and integrated compared to what can be inside of an Excel sheet
  2. Python has some powerful libraries for numerical computing, 2D/3D visualisation, etc.

For the last London Financial PUG meeting (March 11), Travis and I had the idea of making Chaco playing with Excel thanks to a cool tool named pyxll and the pywin32 extension. The example allows the user to select a range of columns in Excel, send them to a Chaco regression tool where the user can select points. A Chaco tool does lively compute a regression on those points and update the Excel sheets.

The result is pretty interesting as shown on the screenshot here below. (I will most probably post a video showing how interactive it is).

Pyxll Chaco interactive session

Pyxll is a very interesting library allowing you to very easily make your Python function available within Excel (either as menu or functions). Thanks a lot to Tony Roberts for his excellent pieces of advice on using pyxll for the demo.

Chaco Python plotting application toolkit that facilitates writing plotting applications at all levels of complexity, from simple scripts with hard-coded data to large plotting programs with complex data interrelationships and a multitude of interactive tools. Chaco is part of the Enthought Tool Suite and available under the BDS license

Implementation details
Read the rest of this entry »