Category Archives: Video

PyQL and QuantLib: A Comprehensive Finance Framework

Authors: Kelsey Jordahl, Brett Murphy

Earlier this month at the first New York Finance Python User’s Group (NY FPUG) meetup, Kelsey Jordahl talked about how PyQL streamlines the development of Python-based finance applications using QuantLib. There were about 30 people attending the talk at the Cornell Club in New York City. We have a recording of the presentation below.

FPUG Meetup Presentation Screenshot

QuantLib is a free, open-source (BSD-licensed) quantitative finance package. It provides tools for financial instruments, yield curves, pricing engines, creating simulations, and date / time management. There is a lot more detail on the QuantLib website along with the latest downloads. Kelsey refers to a really useful blog / open-source book by one of the core QuantLib developers on implementing QuantLib. Quantlib also comes with different language bindings, including Python.

So why use PyQL if there are already Python bindings in QuantLib? Well, PyQL provides a much more Pythonic set of APIs, in short. Kelsey discusses some of the differences between the original QuantLib Python API and the PyQL API and how PyQL streamlines the resulting Python code. You get better integration with other packages like NumPy, better namespace usage and better documentation. PyQL is available up on GitHub in the PyQL repo. Kelsey uses the IPython Notebooks in the examples directory to explore PyQL and QuantLib and compares the use of PyQL versus the standard (SWIG) QuantLib Python APIs.

PyQL remains a work in progress, with goals to make its QuantLib coverage more complete, the API even more Pythonic, and getting a successful build on Windows (works on Mac OS and Linux now). It’s open source, so feel free to step up and contribute!

For the details, check out the video of Kelsey’s presentation (44 minutes).

And here are the slides online if you want to check the links in the presentation.

If you are interested in working on either QuantLib or PyQL, let the maintainers know!

Advanced Cython Recorded Webinar: Typed Memoryviews

Author: Kurt SmithWebinar_screenshot

Typed memoryviews are a new Cython feature for accessing memory buffers, such as NumPy arrays, without any Python overhead. This makes them very useful for manipulating blocks of memory in Cython directly without calling into the Python-C API.  Typed memoryviews have a clean declaration syntax and have a NumPy-like look and feel, supporting slicing, striding and indexing.

I go into more detail and provide some specific examples on how to use typed memoryviews in this webinar: “Advanced Cython: Using the new Typed Memoryviews”.

If you would like to watch the recorded webinar, you can find a link below (the different formats will play directly in different browsers so check to see which one works for you, and you won’t have to download the whole recording ahead of time):

“Why We Built Enthought Canopy, An Inside Look” Recorded Webinar

We posted a recording of a 30 minute webinar that we did on the 20th that covers what Canopy is and why we developed it. There’s a few minutes of Brett Murphy(Product Manager at Enthought) discussing the “why” with some slides, and then Jason McCampbell (Development Manager for Canopy) gets into the interesting part with a 15+ minute demo of some of the key capabilities and workflows in Canopy. If you would like to watch the recorded webinar, you can find it here (the different formats will play directly in different browsers so check them and you won’t have to download the whole recording first):

Summed up in one line: Canopy provides the minimal set of tools for non-programmers to access, analyze and visualize data in an open-source Python environment.

The challenge in the past for scientists, engineers and analysts who wanted to use Python had been pulling together a working, integrated Python environment for scientific computing. Finding compatible versions of the dozens of Python packages, compiling them and integrating it all was very time consuming. That’s why we released the Enthought Python Distribution (EPD) many years back. It provided a single install of all the major packages you needed to do scientific and analytic computing with Python.

But the primary interface for a user of EPD was the command line. For a scientist or analyst used to an environment like MATLAB or one of the R IDEs, the command line is a little unapproachable and makes Python challenging to adopt. This is why we developed Canopy.

Enthought Canopy is both a Python distribution (like EPD) and an analysis environment. The analysis environment includes an integrated editor and IPython prompt to faciliate script development & testing and data analysis & plotting. The graphical package manager becomes the main interface to the Python ecosystem with its package search, install and update capabilities. And the documentation browser makes online documentation for Canopy, Python and the popular Python packages available on the desktop.

Check out the Canopy demo in the recorded webinar (link above). We hope it’s helpful.

Enthought Sponsors First NY QPUG Meetup

Though all eyes are probably on the aftermath of Pycon (which, from all reports, was another great conference), Enthought was happy to sponsor the first New York Quantitative Python User Group Meetup (wow that’s a mouthful) on March 6th. If you are in the New York area, you can sign up for the group here.

The program for the evening featured Marcos Lopez de Prado and our own Kelsey Jordahl (with an assist from yours truly). The meetup focused on the topic of portfolio optimization and some of its foibles. Marcos conducted an in-depth discussion of portfolio optimization in general and outlined his open source implementation of the CLA algorithm. He also discussed why he is such a fan of Python.

Our contribution to the evening focused on the the theme “From Research to Application.” And by “research” we meant both research code (Marcos’ CLA code is one example) and actual investment research. Firms are wrestling with data and trying to marshal all the expertise within the organization to make decisions. Increasingly, software is being used to help synthesize this information. In our thought experiment, we imagined a hypothetical portfolio manager or strategist that is trying to integrate the quantitative and fundamental expertise within the firm. What kind of information would this PM want to see? How could we make the application visually appealing and intuitively interactive?

We chose to use the Black-Litterman model to tie some of these threads together. In a nutshell, Black-Litterman takes a Bayesian approach to portfolio optimization. It assumes that the capital allocations in the market are decent and reverses the classical optimization process to infer expected returns (rather than weights). It also allows modification of these expected returns to reflect analyst views on a particular asset. For those of you not familiar with this subject, you can find an accessible discussion of the approach in He and Litterman (1999). Using the Black-Litterman model as our organizing principle, we put together an application that provides context for historical returns, relative value, and pairwise asset correlations, all wired together to provide full interactivity.

Given the limited time we had to put this together, there are obviously things we would have changed and things we would have liked to include. Nevertheless, we think the demo is a good example of how one can use open source technology to not only take advantage of research code but also integrate quantitative models and fundamental research.

FYI, the libraries used in the app are: Numpy/Pandas, Scipy, Traits, Chaco, and Enaml.

Videos of the talks are below. Tell us what you think!

QPUG_20130306_PortfolioDemo from NYQPUG on Vimeo.

QPUG_20130306_Marcos from NYQPUG on Vimeo.

TGIF: SciPy 2012 Recap Video

As we wait for the SciPy talk videos to make their way onto the web, we’d like to share a short film recapping SciPy 2012.

The latest iteration of the SciPy conference was another great example of the scientific python community coming together to share “the latest and greatest.” Most organizations want to change the world in some way or another. At Enthought, we attempt to do this by building tools that help our customers – in both academia and industry – concentrate on solving their actual problems rather than wrestling with technology. We believe Python’s ability to operate smoothly in different contexts (e.g., desktop, web, array-based and distributed computing, etc.) makes it a highly productive and pragmatic tool with which to build solutions.

The SciPy community is changing the world by continually pushing technical computing forward in a pragmatic way. One just has to look at the content and tools presented at SciPy historically to know that this community has been been up to its neck in “data science” for some time. One could also argue, however, that SciPy is one of the best kept secrets in technical computing. As the recent focus on MapReduce solutions illustrates, the world is in the grips of “big computation.” It will only get tougher in the foreseeable future. At the same time, “big data” is a relative term. “Big” for a bioinformatician is different than for a macro hedge fund analyst, and these differences can often be measured in orders of magnitude. And when it comes to solutions, rarely does one size fit all.

In contrast, SciPy addresses a broad array of problems. SciPy 2012 offered High Performance Computing and Visualization tracks, with tutorials on machine learning, plotting, parallel computing, and time series analysis. Sometimes all these topics could be found in a single talk (see VisIt). The community also demonstrated some open-mindedness by inviting Jeff Bezanson, one of the authors of Julia, to share his experience building a language specifically designed for technical computing. It turns out there is a fair amount of overlap between what the SciPy community and the Julia team are planning. With LLVM IR increasingly being viewed as a common target, there is real excitement about what the future holds for language development and interaction.

This is all to say that SciPy has a lot to offer the world. Stay tuned for a bigger and better SciPy next year!

Mayavi – Talk at Fifth Elephant

The lead developer and creator of the 3D visualization package Mayavi, Dr. Prabhu Ramachandran, will provide a brief overview of Mayavi followed by his experience throughout the development of the package at the Fifth Elephant conference to be held in Bangalore, India.

Here is a brief video preview of the Mayavi user interface and Prabhu’s talk at Fifth Elephant.

Chaco Pygotham Talk

The penultimate video in our series of talks is an overview of Chaco, Enthought’s interactive plotting toolkit. Sit back and enjoy! You can find the github page here.

Clyther Pygotham Talk

Here is a screencast of the Clyther talk at Pygotham. Clyther is an open source project, along the lines of Cython, that allows users to program a GPU with Python via a JIT OpenCL engine. Unfortunately, the multiple monitor setup resulted in some odd aspect ratio’s. Nevertheless, the content has been captured for posterity. You can find the github page here. Enjoy!