Home

Awesome

Build Status PyPI Version PyPI License

bt - Flexible Backtesting for Python

bt is currently in alpha stage - if you find a bug, please submit an issue.

Read the docs here: http://pmorissette.github.io/bt.

What is bt?

bt is a flexible backtesting framework for Python used to test quantitative trading strategies. Backtesting is the process of testing a strategy over a given data set. This framework allows you to easily create strategies that mix and match different Algos. It aims to foster the creation of easily testable, re-usable and flexible blocks of strategy logic to facilitate the rapid development of complex trading strategies.

The goal: to save quants from re-inventing the wheel and let them focus on the important part of the job - strategy development.

bt is coded in Python and joins a vibrant and rich ecosystem for data analysis. Numerous libraries exist for machine learning, signal processing and statistics and can be leveraged to avoid re-inventing the wheel - something that happens all too often when using other languages that don't have the same wealth of high-quality, open-source projects.

bt is built atop ffn - a financial function library for Python. Check it out!

Features

Roadmap

Future development efforts will focus on:

Installing bt

The easiest way to install bt is from the Python Package Index using pip:

pip install bt

Since bt has many dependencies, we strongly recommend installing the Anaconda Scientific Python Distribution, especially on Windows. This distribution comes with many of the required packages pre-installed, including pip. Once Anaconda is installed, the above command should complete the installation.

Recommended Setup

We believe the best environment to develop with bt is the IPython Notebook. From their homepage, the IPython Notebook is:

"[...] a web-based interactive computational environment
where you can combine code execution, text, mathematics, plots and rich
media into a single document [...]"

This environment allows you to plot your charts in-line and also allows you to easily add surrounding text with Markdown. You can easily create Notebooks that you can share with colleagues and you can also save them as PDFs. If you are not yet convinced, head over to their website.

Contributing to bt

A Makefile is available to simplify local development. GNU Make is required to run the make targets directly, and it is not often preinstalled on Windows systems.

When developing in Python, it's advisable to create and activate a virtual environment to keep the project's dependencies isolated from the system.

After the usual preparation steps for contributing to a GitHub project (forking, cloning, creating a feature branch), run make develop to install dependencies in the environment.

While making changes and adding tests, run make lint and make test often to check for mistakes.

After commiting and pushing changes, create a Pull Request to discuss and get feedback on the proposed feature or fix.