backtrader - Python backtesting

backtrader offers a complete backtesting/trading platform with this (not fully comprehensive) list of features:

  • Live Data Feed and Trading
  • Datas with different timeframes can be mixed (days and weeks)
  • Data Resampling
  • Data Replaying (i.e: indicators/strategies see 5 bars in a weekly timeframe)
  • Multiple Datas at the same Time
  • Multiple Strategies at the same time
  • Strategy optimization (including multicore support)
  • Indicators (several) which can of course take datas and/or indicators as input
  • TA-Lib support
  • Plotting support for visual inspection
  • Broker implementation with Market, Close, Limit, Stop, StopLimit orders
  • Commission schemes supporting futures-like and stocks-like objects and customizable
  • Performance analyzers including integration with pyfolio
  • Event based (strategy/indicator ‘next’ will be called with all subordinate indicators calculated and data fetched)
  • Vector (in the form on inner tight for loops) based for a one shot calculation This applies to indicators ... Strategies always are executed one step at a time
  • Natural python language/operations for Indicator development and object comparison/operations (arithmetic, logical operators) As much as permitted by Pthon overriding capabilities (if, and, or cannot be overriden ... but they are provided as logical functions)
  • Index 0 approach to access the currently produced (or to be produced) data
  • Index -1 approach to access the last produced data (to remain Pythonic)

The Blog Entries

  • Notebook - Automatic Inline Plotting by mementum on Sep 17

    Release adds automatic inline plotting when running inside a Jupyter Notebook.

  • Data Synchronization Rework by mementum on Sep 17

    In the latest release the minor number has been moved from 8 to 9 to indicate a change which may have some behavioral impact, regardless, even if compatibility has been taken into account.

  • Variability Weighted Return (or VWR) by mementum on Sep 06

    Following some hints about an improved SharpeRatio, backtrader has added this analyzer to its arsenal.

  • Optimization improvements by mementum on Sep 05

    Version of backtrader includes an improvement in how data feeds and results are managed during multiprocessing.

  • Target Orders by mementum on Sep 02

    Until version smart staking was possible with backtrader over the Strategy methods: buy and sell. It was all about adding a Sizer to the equation which is responsible for the size of the stake.