/pyfolio

Portfolio and risk analytics in Python

Primary LanguageJupyter NotebookApache License 2.0Apache-2.0

pyfolio

pyfolio

Join the chat at https://gitter.im/quantopian/pyfolio build status

pyfolio is a Python library for performance and risk analysis of financial portfolios developed by Quantopian Inc. It works well with the Zipline open source backtesting library.

At the core of pyfolio is a so-called tear sheet that consists of various individual plots that provide a comprehensive image of the performance of a trading algorithm. Here's an example tear sheet analyzing a strategy's returns:

example tear 0 example tear 1

Also see slides of a talk about pyfolio.

Installation

To install pyfolio, run:

pip install pyfolio

Development

For development, you may want to use a virtual environment to avoid dependency conflicts between pyfolio and other Python projects you have. To get set up with a virtual env, run:

mkvirtualenv pyfolio

Next, clone this git repository and run python setup.py develop and edit the library files directly.

Bayesian tear sheet

Generating a Bayesian tearsheet requires PyMC3 and Theano. You can install these packages with the following commands:

pip install theano
pip install pymc3

Matplotlib on OSX

If you are on OSX and using a non-framework build of Python, you may need to set your backend:

echo "backend: TkAgg" > ~/.matplotlib/matplotlibrc

Usage

A good way to get started is to run the pyfolio examples in a Jupyter notebook. To do this, you first want to start a Jupyter notebook server:

jupyter notebook

From the notebook list page, navigate to the pyfolio examples directory and open a notebook. Execute the code in a notebook cell by clicking on it and hitting Shift+Enter.

Questions?

If you find a bug, feel free to open an issue in this repository.

You can also join our mailing list or our Gitter channel.

Contributing

If you'd like to contribute, a great place to look is the issues marked with help-wanted.

For a list of contributors, see https://github.com/quantopian/pyfolio/graphs/contributors.