backtrader README

The project's README from github.com/mementum/backtrader. As one markdown file: README.md.

backtrader

.. image:: https://img.shields.io/pypi/v/backtrader.svg :alt: PyPi Version :scale: 100% :target: https://pypi.python.org/pypi/backtrader/

.. .. 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/backtrader/backtrader.png?branch=master :alt: Travis-ci Build Status :scale: 100% :target: https://travis-ci.org/backtrader/backtrader .. image:: https://img.shields.io/pypi/pyversions/backtrader.svg :alt: Python versions :scale: 100% :target: https://pypi.python.org/pypi/backtrader/

Yahoo API Note:

[2018-11-16] After some testing it would seem that data downloads can be again relied upon over the web interface (or API v7)

Tickets

The ticket system is (was, actually) more often than not abused to ask for advice about samples.

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)

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

backtrader (mementum/backtrader)

fintech
Searching Database…

What is this?backtrader is a Python library for backtesting trading strategies: you write a strategy as code, run it against historical market data and measure how it would have performed before risking real money.
Is this a program I install, or a library I code against?A library you code against, not a standalone app: your own Python scripts import backtrader to define strategies, feed them market data and run the backtests.
How do I get it into my project?From PyPI: pip install backtrader. Or, from source, place the backtrader directory found in the sources inside your project and import it from there.
Does it drag in a lot of other libraries?None by default — it is self-contained with no external dependencies. Only plotting is optional: pip install backtrader[plotting] adds matplotlib, and version 1.4.1 is the minimum.
Any gotchas I should know about before starting?IbPy, the Interactive Brokers interface, is not on PyPI and must be installed from git. Yahoo data downloads also went through an unreliable stretch, working again as of November 2018 via the web interface or API v7.
Where can it pull historical market data from?The README mentions Yahoo Finance downloads and data feed integrations for Interactive Brokers (via IbPy), Visual Chart and Oanda, plus TA-Lib support. Each integration has its own dependencies, listed in the documentation.
Can it place real trades, or is it backtesting only?Live trading is in scope: the README includes an Interactive Brokers example covering both data feeds and trading, and Oanda and Visual Chart integrations are mentioned alongside it.
How many indicators does it ship with?The count is baked into the version number: in the X.Y.Z.I scheme the trailing digit I is the number of indicators built into the platform, so every release tells you its own indicator count.
Is the project still actively developed?It dates back to 2015 and has around 23,500 GitHub stars, but the README's aside that the ticket system 'is (was, actually)' used for feedback suggests day-to-day activity has cooled; questions are pointed to the Community instead.
Creator
mementum
Size
21.9 MB
Stars
23.5K
Updated
CommitApr 19
Age
11y
Commits · 90 Days