Skip to content

ematvey/pybacktest

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
October 12, 2016 19:14
September 9, 2019 11:28
October 12, 2016 19:10
October 12, 2016 19:06

pybacktest

Simple yet powerful backtesting framework in python/pandas.

Currently I don't plan to continue working on this project.

About

It allows user to specify trading strategies using full power of pandas, at the same time hiding all boring things like manually calculating trades, equity, performance statistics and creating visualizations. Resulting strategy code is usable both in research and production setting.

Strategies could be defined as simple this:

ms = pandas.rolling_mean(ohlc.C, 50)
ml = pandas.rolling_mean(ohlc.C, 100)
buy = cover = (ms > ml) & (ms.shift() < ml.shift())
sell = short = (ms < ml) & (ms.shift() > ml.shift())

And then tested like this: pybacktest.Backtest(locals())

We use it in our research and production operations.

Installation

pip install git+https://github.com/ematvey/pybacktest.git

If you don't install it in virtualenv, you might need to prepend last line with sudo.

Tutorial

Tutorials are provided as ipython notebooks in folder examples. You run it from cloned repo or watch via nbviewer.

Status

Single-security backtester is ready. Multi-security testing could be implemented by running single-sec backtests and then combining equity. Later we will add easier way.

About

Vectorized backtesting framework in Python / pandas, designed to make your backtesting easier — compact, simple and fast

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages