backtrader


Namebacktrader JSON
Version 1.9.78.123 PyPI version JSON
download
home_pagehttps://github.com/mementum/backtrader
SummaryBackTesting Engine
upload_time2023-04-19 14:13:18
maintainer
docs_urlNone
authorDaniel Rodriguez
requires_python
licenseGPLv3+
keywords trading development
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            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.

  - Live Data Feed and Trading with

    - Interactive Brokers (needs ``IbPy`` and benefits greatly from an
      installed ``pytz``)
    - *Visual Chart* (needs a fork of ``comtypes`` until a pull request is
      integrated in the release and benefits from ``pytz``)
    - *Oanda* (needs ``oandapy``) (REST API Only - v20 did not support
      streaming when implemented)

  - Data feeds from csv/files, online sources or from *pandas* and *blaze*
  - Filters for datas, like breaking a daily bar into chunks to simulate
    intraday or working with Renko bricks
  - Multiple data feeds and multiple strategies supported
  - Multiple timeframes at once
  - Integrated Resampling and Replaying
  - Step by Step backtesting or at once (except in the evaluation of the Strategy)
  - Integrated battery of indicators
  - *TA-Lib* indicator support (needs python *ta-lib* / check the docs)
  - Easy development of custom indicators
  - Analyzers (for example: TimeReturn, Sharpe Ratio, SQN) and ``pyfolio``
    integration (**deprecated**)
  - Flexible definition of commission schemes
  - Integrated broker simulation with *Market*, *Close*, *Limit*, *Stop*,
    *StopLimit*, *StopTrail*, *StopTrailLimit*and *OCO* orders, bracket order,
    slippage, volume filling strategies and continuous cash adjustmet for
    future-like instruments
  - Sizers for automated staking
  - Cheat-on-Close and Cheat-on-Open modes
  - Schedulers
  - Trading Calendars
  - Plotting (requires matplotlib)

Documentation
=============

The blog:

  - `Blog <http://www.backtrader.com/blog>`_

Read the full documentation at:

  - `Documentation <http://www.backtrader.com/docu>`_

List of built-in Indicators (122)

  - `Indicators Reference <http://www.backtrader.com/docu/indautoref.html>`_

Python 2/3 Support
==================

  - Python >= ``3.2``

  - It also works with ``pypy`` and ``pypy3`` (no plotting - ``matplotlib`` is
    not supported under *pypy*)

Installation
============

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

From *pypi*:

  - ``pip install backtrader``

  - ``pip install backtrader[plotting]``

    If ``matplotlib`` is not installed and you wish to do some plotting

.. note:: The minimum matplotlib version is ``1.4.1``

An example for *IB* Data Feeds/Trading:

  - ``IbPy`` doesn't seem to be in PyPi. Do either::

      pip install git+https://github.com/blampe/IbPy.git

    or (if ``git`` is not available in your system)::

      pip install https://github.com/blampe/IbPy/archive/master.zip

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

From source:

  - Place the *backtrader* directory found in the sources inside your project

Version numbering
=================

X.Y.Z.I

  - X: Major version number. Should stay stable unless something big is changed
    like an overhaul to use ``numpy``
  - Y: Minor version number. To be changed upon adding a complete new feature or
    (god forbids) an incompatible API change.
  - Z: Revision version number. To be changed for documentation updates, small
    changes, small bug fixes
  - I: Number of Indicators already built into the platform

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mementum/backtrader",
    "name": "backtrader",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "trading,development",
    "author": "Daniel Rodriguez",
    "author_email": "danjrod@gmail.com",
    "download_url": "https://github.com/mementum/backtrader/tarball/1.9.78.123",
    "platform": null,
    "description": "backtrader\r\n==========\r\n\r\n.. image:: https://img.shields.io/pypi/v/backtrader.svg\r\n   :alt: PyPi Version\r\n   :scale: 100%\r\n   :target: https://pypi.python.org/pypi/backtrader/\r\n\r\n..  .. image:: https://img.shields.io/pypi/dm/backtrader.svg\r\n       :alt: PyPi Monthly Donwloads\r\n       :scale: 100%\r\n       :target: https://pypi.python.org/pypi/backtrader/\r\n\r\n.. image:: https://img.shields.io/pypi/l/backtrader.svg\r\n   :alt: License\r\n   :scale: 100%\r\n   :target: https://github.com/backtrader/backtrader/blob/master/LICENSE\r\n.. image:: https://travis-ci.org/backtrader/backtrader.png?branch=master\r\n   :alt: Travis-ci Build Status\r\n   :scale: 100%\r\n   :target: https://travis-ci.org/backtrader/backtrader\r\n.. image:: https://img.shields.io/pypi/pyversions/backtrader.svg\r\n   :alt: Python versions\r\n   :scale: 100%\r\n   :target: https://pypi.python.org/pypi/backtrader/\r\n\r\n**Yahoo API Note**:\r\n\r\n  [2018-11-16] After some testing it would seem that data downloads can be\r\n  again relied upon over the web interface (or API ``v7``)\r\n\r\n**Tickets**\r\n\r\n  The ticket system is (was, actually) more often than not abused to ask for\r\n  advice about samples.\r\n\r\nFor **feedback/questions/...** use the `Community <https://community.backtrader.com>`_\r\n\r\nHere a snippet of a Simple Moving Average CrossOver. It can be done in several\r\ndifferent ways. Use the docs (and examples) Luke!\r\n::\r\n\r\n  from datetime import datetime\r\n  import backtrader as bt\r\n\r\n  class SmaCross(bt.SignalStrategy):\r\n      def __init__(self):\r\n          sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)\r\n          crossover = bt.ind.CrossOver(sma1, sma2)\r\n          self.signal_add(bt.SIGNAL_LONG, crossover)\r\n\r\n  cerebro = bt.Cerebro()\r\n  cerebro.addstrategy(SmaCross)\r\n\r\n  data0 = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1),\r\n                                    todate=datetime(2012, 12, 31))\r\n  cerebro.adddata(data0)\r\n\r\n  cerebro.run()\r\n  cerebro.plot()\r\n\r\nIncluding a full featured chart. Give it a try! This is included in the samples\r\nas ``sigsmacross/sigsmacross2.py``. Along it is ``sigsmacross.py`` which can be\r\nparametrized from the command line.\r\n\r\nFeatures:\r\n=========\r\n\r\nLive Trading and backtesting platform written in Python.\r\n\r\n  - Live Data Feed and Trading with\r\n\r\n    - Interactive Brokers (needs ``IbPy`` and benefits greatly from an\r\n      installed ``pytz``)\r\n    - *Visual Chart* (needs a fork of ``comtypes`` until a pull request is\r\n      integrated in the release and benefits from ``pytz``)\r\n    - *Oanda* (needs ``oandapy``) (REST API Only - v20 did not support\r\n      streaming when implemented)\r\n\r\n  - Data feeds from csv/files, online sources or from *pandas* and *blaze*\r\n  - Filters for datas, like breaking a daily bar into chunks to simulate\r\n    intraday or working with Renko bricks\r\n  - Multiple data feeds and multiple strategies supported\r\n  - Multiple timeframes at once\r\n  - Integrated Resampling and Replaying\r\n  - Step by Step backtesting or at once (except in the evaluation of the Strategy)\r\n  - Integrated battery of indicators\r\n  - *TA-Lib* indicator support (needs python *ta-lib* / check the docs)\r\n  - Easy development of custom indicators\r\n  - Analyzers (for example: TimeReturn, Sharpe Ratio, SQN) and ``pyfolio``\r\n    integration (**deprecated**)\r\n  - Flexible definition of commission schemes\r\n  - Integrated broker simulation with *Market*, *Close*, *Limit*, *Stop*,\r\n    *StopLimit*, *StopTrail*, *StopTrailLimit*and *OCO* orders, bracket order,\r\n    slippage, volume filling strategies and continuous cash adjustmet for\r\n    future-like instruments\r\n  - Sizers for automated staking\r\n  - Cheat-on-Close and Cheat-on-Open modes\r\n  - Schedulers\r\n  - Trading Calendars\r\n  - Plotting (requires matplotlib)\r\n\r\nDocumentation\r\n=============\r\n\r\nThe blog:\r\n\r\n  - `Blog <http://www.backtrader.com/blog>`_\r\n\r\nRead the full documentation at:\r\n\r\n  - `Documentation <http://www.backtrader.com/docu>`_\r\n\r\nList of built-in Indicators (122)\r\n\r\n  - `Indicators Reference <http://www.backtrader.com/docu/indautoref.html>`_\r\n\r\nPython 2/3 Support\r\n==================\r\n\r\n  - Python >= ``3.2``\r\n\r\n  - It also works with ``pypy`` and ``pypy3`` (no plotting - ``matplotlib`` is\r\n    not supported under *pypy*)\r\n\r\nInstallation\r\n============\r\n\r\n``backtrader`` is self-contained with no external dependencies (except if you\r\nwant to plot)\r\n\r\nFrom *pypi*:\r\n\r\n  - ``pip install backtrader``\r\n\r\n  - ``pip install backtrader[plotting]``\r\n\r\n    If ``matplotlib`` is not installed and you wish to do some plotting\r\n\r\n.. note:: The minimum matplotlib version is ``1.4.1``\r\n\r\nAn example for *IB* Data Feeds/Trading:\r\n\r\n  - ``IbPy`` doesn't seem to be in PyPi. Do either::\r\n\r\n      pip install git+https://github.com/blampe/IbPy.git\r\n\r\n    or (if ``git`` is not available in your system)::\r\n\r\n      pip install https://github.com/blampe/IbPy/archive/master.zip\r\n\r\nFor other functionalities like: ``Visual Chart``, ``Oanda``, ``TA-Lib``, check\r\nthe dependencies in the documentation.\r\n\r\nFrom source:\r\n\r\n  - Place the *backtrader* directory found in the sources inside your project\r\n\r\nVersion numbering\r\n=================\r\n\r\nX.Y.Z.I\r\n\r\n  - X: Major version number. Should stay stable unless something big is changed\r\n    like an overhaul to use ``numpy``\r\n  - Y: Minor version number. To be changed upon adding a complete new feature or\r\n    (god forbids) an incompatible API change.\r\n  - Z: Revision version number. To be changed for documentation updates, small\r\n    changes, small bug fixes\r\n  - I: Number of Indicators already built into the platform\r\n",
    "bugtrack_url": null,
    "license": "GPLv3+",
    "summary": "BackTesting Engine",
    "version": "1.9.78.123",
    "split_keywords": [
        "trading",
        "development"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3ef328c6ec332435f63b3e18febd263686b8ba07e990676a862cc8522ba38f5",
                "md5": "890e9eca5774fb2a4ab6208aec691c36",
                "sha256": "9a07a516b0de9155539a35c56e9404d8711dd7020b3d37b30495e83e1b9d5dfd"
            },
            "downloads": -1,
            "filename": "backtrader-1.9.78.123-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "890e9eca5774fb2a4ab6208aec691c36",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 419517,
            "upload_time": "2023-04-19T14:13:18",
            "upload_time_iso_8601": "2023-04-19T14:13:18.842786Z",
            "url": "https://files.pythonhosted.org/packages/f3/ef/328c6ec332435f63b3e18febd263686b8ba07e990676a862cc8522ba38f5/backtrader-1.9.78.123-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-19 14:13:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "mementum",
    "github_project": "backtrader",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "backtrader"
}
        
Elapsed time: 0.05859s