Skip to content


backtrader is a fully features open source framework for backtesting and live trading, with support for strategies, indicators, performance analysis, position sizing and additional paradigms.


Let us enumerate the features of backtrader

  • Open Source. If you need to modify it or understand how it works, you can.

  • Written in Python. The language is renowned for being easy to write and read whilst being powerful and with libraries (standard or with extra packages installed via pypi)

  • Self-contained: except for plotting, it does only require a Python installation and no third party packages

  • It can be used with Python 2.7 and 3.2+

  • Supports multiple data feeds and new data feeds can be easily added

  • Includes a built-in library with over 100 indicators

  • Transparent Integration with ta-lib indicators

  • Includes several built-in analyzers to evaluate performance

  • Observers for plotting statistics

  • Data feeds and indicators can be easily created/extended to include new fields

  • Support rolling over of data feeds (to simulate continuous futures streams)

  • Supports timeframes from Ticks up to Years

  • Multiple data feeds with mixed timeframes can be used

  • Built-in data resampling and replaying

  • Data Filters to modify data feeds on-the-fly

  • Sizers to support automated position sizing schemes

  • Timers, Trading Calendars and multiple Timezone support

  • Automated Strategies through Signals and support for multiple simultaneous strategies

  • Multi-Core Strategy Parameter Optimization

  • Writer abstraction to enable logging from all elements (to a file, standard output or anything else)

  • Automated plotting if matplotlib is available

  • The simulating broker supports:

    • Order types: Market, Limit, Stop, StopLimit, StopTrail, StopTrailLimit Close (aka MarketOnClose), OCO (One Cancel Others), Bracket (which combines 3 orders which play the following roles: Main Order, Take-Profit, Stop-Loss)

    • Slippage

    • Commission Schemes (customizable and extensible)

    • Future-like, Stock-like and other types of instruments

    • Energy Market Future vs Spot operations

    • Continuous cash adjustment for future-like instruments

    • Cash check on order submission and execution

    • Cheat-on-Close to match against the current closing price

    • Cheat-on-Open to allow for pre-open order management

    • Volume Filling Strategies

What backtrader does not do

  • Make use of Bid/Ask prices for order execution

    Although there are examples online to convert Bid/Ask into an OHLC stream, the broker does not use the bid/ask prices.

  • Run at incredible speeds

    backtrader is written in Python and Python is slow. The incredible introspection power and the dynamism offered by Python and the lack of real multi-threading for CPU-bound tasks, make it slow when compared to other languages/environments.

    And the RAM usage is not low.

  • Use your GPU for optimization. The code would have to be specifically written for it

  • Offer you the closing price as the execution price unless you activate cheat-on-close

    This comes to a surprise to many, but once you have seen the closing price, the price is simply gone and may not be there ever again.

  • Offer you incredible powers which allow you to go over the available cash of your account for All-In strategies.

    The usual scenario is someone making all-in calculations on the close and not getting matched because the opening price gaps away from the closing price.

    A cheat-on-open mode is in any case available to do that.

  • Commercial data feed and/or brokering service

    No. backtrader is an open source framework and not a commercial service. There are data feeds to connect to commercial APIs like Interactive Brokers, Oanda and more, but the service is not offered by backtrader.