backtrader2 / backtrader

Python Backtesting library for trading strategies
https://www.backtrader.com
GNU General Public License v3.0
221 stars 52 forks source link

backtrader2 : An on going and open project

.. image:: https://img.shields.io/pypi/dm/backtrader.svg :alt: PyPi Monthly Donwloads :scale: 100% :target: https://pypi.python.org/pypi/backtrader/

.. image:: https://img.shields.io/pypi/l/backtrader.svg :alt: License :scale: 100% :target: https://github.com/backtrader/backtrader/blob/master/LICENSE .. image:: https://travis-ci.org/backtrader2/backtrader.png?branch=master :alt: Travis-ci Build Status :scale: 100% :target: https://travis-ci.org/backtrader2/backtrader .. image:: https://img.shields.io/pypi/pyversions/backtrader.svg :alt: Python versions :scale: 100% :target: https://pypi.python.org/pypi/backtrader/

Important Update

Backtrader is a flexible and powerful backtesting engine written in python. The original project found wide appeal due to its versatility. Over time however, the original code base became inaccessible to bug fixes and enhancements.

Backtrader2 is a forked copy of backtrader by the community of users that seeks to make backtrader an ongoing project.

Initially backtrader2 will fix bugs. Just submit an issue and pull requests.

New code ideas are welcome but will not be addressed at this time. But please do enter them as an issue and tag it with 'enhancement' so that we can track your idea down the road.

Backtrader's back and we look forward to its future!

For feedback/questions/... use the Community <https://community.backtrader.com>_

Here a snippet of a Simple Moving Average CrossOver. It can be done in several different ways. Use the docs (and examples) Luke! ::

from datetime import datetime import backtrader as bt

class SmaCross(bt.SignalStrategy): def init(self): sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30) crossover = bt.ind.CrossOver(sma1, sma2) self.signal_add(bt.SIGNAL_LONG, crossover)

cerebro = bt.Cerebro() cerebro.addstrategy(SmaCross)

data0 = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1), todate=datetime(2012, 12, 31)) cerebro.adddata(data0)

cerebro.run() cerebro.plot()

Including a full featured chart. Give it a try! This is included in the samples as sigsmacross/sigsmacross2.py. Along it is sigsmacross.py which can be parametrized from the command line.

Features:

Live Trading and backtesting platform written in Python.

Documentation

The blog:

Read the full documentation at:

List of built-in Indicators (122)

Python 2/3 Support

Installation

backtrader is self-contained with no external dependencies (except if you want to plot)

Install the latest version from the backtrader2 repository:

Or install the original version of backtrader from pypi:

.. note:: The minimum matplotlib version is 1.4.1

An example for IB Data Feeds/Trading:

For other functionalities like: Visual Chart, Oanda, TA-Lib, check the dependencies in the documentation.

From source:

Version numbering

X.Y.Z.I