{"id":13394756,"url":"https://github.com/mementum/backtrader","last_synced_at":"2025-05-13T17:04:13.462Z","repository":{"id":25615150,"uuid":"29050338","full_name":"mementum/backtrader","owner":"mementum","description":"Python Backtesting library for trading strategies","archived":false,"fork":false,"pushed_at":"2024-08-19T17:47:36.000Z","size":22460,"stargazers_count":17034,"open_issues_count":55,"forks_count":4355,"subscribers_count":641,"default_branch":"master","last_synced_at":"2025-05-06T16:14:51.868Z","etag":null,"topics":["backtesting","metaclass","python","trading"],"latest_commit_sha":null,"homepage":"https://www.backtrader.com","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mementum.png","metadata":{"files":{"readme":"README.rst","changelog":"changelog.txt","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"mementum","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2015-01-10T07:14:52.000Z","updated_at":"2025-05-06T14:22:54.000Z","dependencies_parsed_at":"2023-01-14T03:01:17.579Z","dependency_job_id":"a92d0478-24b4-4705-946b-48af677a185e","html_url":"https://github.com/mementum/backtrader","commit_stats":{"total_commits":2289,"total_committers":58,"mean_commits":39.46551724137931,"dds":0.09086937527304495,"last_synced_commit":"b853d7c90b6721476eb5a5ea3135224e33db1f14"},"previous_names":["backtrader/backtrader"],"tags_count":139,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mementum%2Fbacktrader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mementum%2Fbacktrader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mementum%2Fbacktrader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mementum%2Fbacktrader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mementum","download_url":"https://codeload.github.com/mementum/backtrader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990456,"owners_count":21995773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backtesting","metaclass","python","trading"],"created_at":"2024-07-30T17:01:30.561Z","updated_at":"2025-05-13T17:04:13.393Z","avatar_url":"https://github.com/mementum.png","language":"Python","readme":"backtrader\n==========\n\n.. image:: https://img.shields.io/pypi/v/backtrader.svg\n   :alt: PyPi Version\n   :scale: 100%\n   :target: https://pypi.python.org/pypi/backtrader/\n\n..  .. image:: https://img.shields.io/pypi/dm/backtrader.svg\n       :alt: PyPi Monthly Donwloads\n       :scale: 100%\n       :target: https://pypi.python.org/pypi/backtrader/\n\n.. image:: https://img.shields.io/pypi/l/backtrader.svg\n   :alt: License\n   :scale: 100%\n   :target: https://github.com/backtrader/backtrader/blob/master/LICENSE\n.. image:: https://travis-ci.org/backtrader/backtrader.png?branch=master\n   :alt: Travis-ci Build Status\n   :scale: 100%\n   :target: https://travis-ci.org/backtrader/backtrader\n.. image:: https://img.shields.io/pypi/pyversions/backtrader.svg\n   :alt: Python versions\n   :scale: 100%\n   :target: https://pypi.python.org/pypi/backtrader/\n\n**Yahoo API Note**:\n\n  [2018-11-16] After some testing it would seem that data downloads can be\n  again relied upon over the web interface (or API ``v7``)\n\n**Tickets**\n\n  The ticket system is (was, actually) more often than not abused to ask for\n  advice about samples.\n\nFor **feedback/questions/...** use the `Community \u003chttps://community.backtrader.com\u003e`_\n\nHere a snippet of a Simple Moving Average CrossOver. It can be done in several\ndifferent ways. Use the docs (and examples) Luke!\n::\n\n  from datetime import datetime\n  import backtrader as bt\n\n  class SmaCross(bt.SignalStrategy):\n      def __init__(self):\n          sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)\n          crossover = bt.ind.CrossOver(sma1, sma2)\n          self.signal_add(bt.SIGNAL_LONG, crossover)\n\n  cerebro = bt.Cerebro()\n  cerebro.addstrategy(SmaCross)\n\n  data0 = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1),\n                                    todate=datetime(2012, 12, 31))\n  cerebro.adddata(data0)\n\n  cerebro.run()\n  cerebro.plot()\n\nIncluding a full featured chart. Give it a try! This is included in the samples\nas ``sigsmacross/sigsmacross2.py``. Along it is ``sigsmacross.py`` which can be\nparametrized from the command line.\n\nFeatures:\n=========\n\nLive Trading and backtesting platform written in Python.\n\n  - Live Data Feed and Trading with\n\n    - Interactive Brokers (needs ``IbPy`` and benefits greatly from an\n      installed ``pytz``)\n    - *Visual Chart* (needs a fork of ``comtypes`` until a pull request is\n      integrated in the release and benefits from ``pytz``)\n    - *Oanda* (needs ``oandapy``) (REST API Only - v20 did not support\n      streaming when implemented)\n\n  - Data feeds from csv/files, online sources or from *pandas* and *blaze*\n  - Filters for datas, like breaking a daily bar into chunks to simulate\n    intraday or working with Renko bricks\n  - Multiple data feeds and multiple strategies supported\n  - Multiple timeframes at once\n  - Integrated Resampling and Replaying\n  - Step by Step backtesting or at once (except in the evaluation of the Strategy)\n  - Integrated battery of indicators\n  - *TA-Lib* indicator support (needs python *ta-lib* / check the docs)\n  - Easy development of custom indicators\n  - Analyzers (for example: TimeReturn, Sharpe Ratio, SQN) and ``pyfolio``\n    integration (**deprecated**)\n  - Flexible definition of commission schemes\n  - Integrated broker simulation with *Market*, *Close*, *Limit*, *Stop*,\n    *StopLimit*, *StopTrail*, *StopTrailLimit*and *OCO* orders, bracket order,\n    slippage, volume filling strategies and continuous cash adjustmet for\n    future-like instruments\n  - Sizers for automated staking\n  - Cheat-on-Close and Cheat-on-Open modes\n  - Schedulers\n  - Trading Calendars\n  - Plotting (requires matplotlib)\n\nDocumentation\n=============\n\nThe blog:\n\n  - `Blog \u003chttp://www.backtrader.com/blog\u003e`_\n\nRead the full documentation at:\n\n  - `Documentation \u003chttp://www.backtrader.com/docu\u003e`_\n\nList of built-in Indicators (122)\n\n  - `Indicators Reference \u003chttp://www.backtrader.com/docu/indautoref.html\u003e`_\n\nPython 2/3 Support\n==================\n\n  - Python \u003e= ``3.2``\n\n  - It also works with ``pypy`` and ``pypy3`` (no plotting - ``matplotlib`` is\n    not supported under *pypy*)\n\nInstallation\n============\n\n``backtrader`` is self-contained with no external dependencies (except if you\nwant to plot)\n\nFrom *pypi*:\n\n  - ``pip install backtrader``\n\n  - ``pip install backtrader[plotting]``\n\n    If ``matplotlib`` is not installed and you wish to do some plotting\n\n.. note:: The minimum matplotlib version is ``1.4.1``\n\nAn example for *IB* Data Feeds/Trading:\n\n  - ``IbPy`` doesn't seem to be in PyPi. Do either::\n\n      pip install git+https://github.com/blampe/IbPy.git\n\n    or (if ``git`` is not available in your system)::\n\n      pip install https://github.com/blampe/IbPy/archive/master.zip\n\nFor other functionalities like: ``Visual Chart``, ``Oanda``, ``TA-Lib``, check\nthe dependencies in the documentation.\n\nFrom source:\n\n  - Place the *backtrader* directory found in the sources inside your project\n\nVersion numbering\n=================\n\nX.Y.Z.I\n\n  - X: Major version number. Should stay stable unless something big is changed\n    like an overhaul to use ``numpy``\n  - Y: Minor version number. To be changed upon adding a complete new feature or\n    (god forbids) an incompatible API change.\n  - Z: Revision version number. To be changed for documentation updates, small\n    changes, small bug fixes\n  - I: Number of Indicators already built into the platform\n","funding_links":["https://github.com/sponsors/mementum"],"categories":["Uncategorized","Backtesting and Live Trading","Python","金融数据处理","By Industry","金融股票","Backtest + live trading","Backtesters","Curated List","trading","回测引擎","Open source bots"],"sub_categories":["Uncategorized","General - Event Driven Frameworks","Finance","网络服务_其他","General purpose","Arbitrage","Trading Frameworks (support backtesting and live trading)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmementum%2Fbacktrader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmementum%2Fbacktrader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmementum%2Fbacktrader/lists"}