All Projects → mementum → Backtrader

mementum / Backtrader

Licence: gpl-3.0
Python Backtesting library for trading strategies

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Backtrader

dukascopy-tools
✨ Download historical price tick data for Crypto, Stocks, ETFs, CFDs, Forex via CLI and Node.js ✨
Stars: ✭ 128 (-98.37%)
Mutual labels:  trading, backtesting
TradeBot
Crypto trading bot using Binance API (Java)
Stars: ✭ 292 (-96.28%)
Mutual labels:  trading, backtesting
backtrader template
Basic template for managing Backtrader backtests.
Stars: ✭ 131 (-98.33%)
Mutual labels:  trading, backtesting
binance-downloader
Python tool to download Binance Candlestick (k-line) data from REST API
Stars: ✭ 44 (-99.44%)
Mutual labels:  trading, backtesting
bitfinex-ohlc-import
Imports historical OHLC data from Bitfinex
Stars: ✭ 27 (-99.66%)
Mutual labels:  trading, backtesting
SierraChartZorroPlugin
A Zorro broker API plugin for Sierra Chart, written in Win32 C++.
Stars: ✭ 22 (-99.72%)
Mutual labels:  trading, backtesting
autoxd
A股回测框架, 模拟实盘账户交易, 适合编写T+0策略
Stars: ✭ 71 (-99.1%)
Mutual labels:  trading, backtesting
gym-mtsim
A general-purpose, flexible, and easy-to-use simulator alongside an OpenAI Gym trading environment for MetaTrader 5 trading platform (Approved by OpenAI Gym)
Stars: ✭ 196 (-97.5%)
Mutual labels:  trading, backtesting
gekko-batcher
Batch backtest tool for Gekko.
Stars: ✭ 34 (-99.57%)
Mutual labels:  trading, backtesting
gdax-ohlc-import
Import historical OHLC data from GDAX
Stars: ✭ 26 (-99.67%)
Mutual labels:  trading, backtesting
awesome-tradingview
Curated list of noteworthy TradingView Strategies, Indicators and Alert Scripts for Trading Bots (PineScript)
Stars: ✭ 173 (-97.8%)
Mutual labels:  trading, backtesting
aku
Aku - Toy Backtesting/Trading Engine
Stars: ✭ 27 (-99.66%)
Mutual labels:  trading, backtesting
roq-samples
How to use the Roq C++20 API for Live Cryptocurrency Algorithmic and High-Frequency Trading as well as for Back-Testing and Historical Simulation
Stars: ✭ 119 (-98.48%)
Mutual labels:  trading, backtesting
TAcharts
Apply popular TA tools and charts to candlestick data with NumPy.
Stars: ✭ 131 (-98.33%)
Mutual labels:  trading, backtesting
AI-for-Trading
📈This repo contains detailed notes and multiple projects implemented in Python related to AI and Finance. Follow the blog here: https://purvasingh.medium.com
Stars: ✭ 59 (-99.25%)
Mutual labels:  trading, backtesting
Stocksharp
Algorithmic trading and quantitative trading open source platform to develop trading robots (stock markets, forex, crypto, bitcoins, and options).
Stars: ✭ 4,601 (-41.36%)
Mutual labels:  trading, backtesting
Volatility Trading
A complete set of volatility estimators based on Euan Sinclair's Volatility Trading
Stars: ✭ 538 (-93.14%)
Mutual labels:  trading
Tda Api
A TD Ameritrade API client for Python. Includes historical data for equities and ETFs, options chains, streaming order book data, complex order construction, and more.
Stars: ✭ 608 (-92.25%)
Mutual labels:  trading
Redtorch
Java开源量化交易开发框架
Stars: ✭ 528 (-93.27%)
Mutual labels:  trading
Lean
Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
Stars: ✭ 5,675 (-27.67%)
Mutual labels:  trading

backtrader

PyPi Version License Travis-ci Build Status Python versions

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

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:

Read the full documentation at:

List of built-in Indicators (122)

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].