Posted in 2016

BTFD - Reality Bites

  • Dec 28, 2016

The previous post managed to replicate the BTFD strategy, finding out that the real gains were 16x rather than 31x.

Read more ...

BTFD (Buy The F... Dip)

  • Dec 26, 2016
  • Dec 30, 2016

Added operations log for the CloseClose approach (updated sample below too)

A post in Reddit calling for replication of a BTFD strategy turned out to be the little push needed to add yet another feature to backtrader: leverage

The links:

Read more ...

Gold vs SP500

  • Dec 13, 2016

Sometimes getting hints about where backtrader is in use helps understanding what people may be looking for and using the platform for.

The reference:

Read more ...

Arrows for the BuySell Observer

  • Dec 10, 2016

backtrader was conceived to try to deliver ease of use. Creation of indicators and other usual suspects should be easy.

And of course, customizing existing items should also be part of the deal.

Read more ...

Shorting the cash

  • Dec 06, 2016

From the very first moment backtrader was enabled for shorting anything, including stock-like and future-like instruments. When a short was done, the cash was decreased and the value of the shorted asset used for the total net liquidation value.

Removing from one side and adding to the other keeps things in balance.

It seems that people prefer to have cash increased, which probably lends to more spending.

Read more ...

Hidden Powers of Python (3)

  • Nov 25, 2016

Last, but not least, in this series about how the hidden powers of Python are used in backtrader is how some of the magic variables show up.

Read more ...

Hidden Powers of Python (2)

  • Nov 23, 2016

Let’s tackle a bit more how the hidden powers of Python are used in backtrader and how this is implemented to try to hit the main goal: ease of use

Read more ...

Hidden Powers of Python (1)

  • Nov 20, 2016

It’s only when meeting real users of backtrader when one can realize if the abstractions and Python powers used in the platform make sense.

Without leaving the pythonic motto aside, backtrader tries to give the users as much control as possible, whilst at the same time simplifying the usage by putting into action the hidden powers that Python offers.

The first example in this the first post of a series.

Read more ...

Strategy Selection

  • Oct 29, 2016

Houston we have a problem:

cerebro is not meant to be run several times. This is not the 1st time and rather than thinking that users are doing it wrong, it seems it is a use case.

Read more ...

Notebook - Automatic Inline Plotting

  • Sep 17, 2016

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

Some of the questions around backtrader show people using the platform inside a Notebook and supporting this and making it the default behavior should make things consistent.

Read more ...

Data Synchronization Rework

  • Sep 17, 2016

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.

With release the entire mechanism to synchronize multiple datas using datetime has been reworked (for both next and once modes).

Read more ...

Variability Weighted Return (or VWR)

  • Sep 06, 2016

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

The literature is at:

Read more ...

Optimization improvements

  • Sep 05, 2016

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

Read more ...

Target Orders

  • Sep 02, 2016

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.

What a Sizer cannot do is decide if the operation has to be a buy or a sell. And that means that a new concept is needed in which a small intelligence layer is added to make such decision.

Read more ...

Rolling over Futures

  • Aug 31, 2016

Not every provider offers a continuous future for the instruments with which one can trade. Sometimes the data offered is that of the still valid expiration dates, i.e.: those still being traded

This is not so helpful when it comes to backtesting because the data is scattered over several different instruments which additionally ... overlap in time.

Read more ...

Credit Interest

  • Aug 22, 2016

In some situations, the cash amount in real brokers may be decreased because the operation on assets includes an interest rate. Examples:

Short selling of stocks

Read more ...

Dickson Moving Average

  • Aug 17, 2016

The reddit post from below names this average the Dickson Moving Average after its own author Nathan Dickson (reddit handle)

Read more ...

Stock Screening

  • Aug 15, 2016

Looking for some other things I came across a question on one of the StackOverlow family sites: Quantitative Finance aka Quant StackExchange. The question:

Read more ...

Strategy with Signals

  • Aug 01, 2016

Operating backtrader is also possible without having to write a Strategy. Although this is the preferred way, due to the object hierarchy which makes up the machinery, using Signals is also possible.

Read more ...

MACD Settings

  • Jul 30, 2016

In the Algotrading site of Reddit a thread about optimizing MACD settings was found.

Read more ...

Pinkfish Challenge

  • Jul 29, 2016

(Sample and changes added to release

Along the way backtrader has gotten maturity, new features and of course complexity. Many of the new features have been introduced after requests, comments, questions from users. Small challenges which have proven that most of the design decisions were at least not that wrong even if some things could have been done in many other ways, sometimes probably in a better way.

Read more ...


  • Jul 26, 2016

Even if backtrader offers an already high number of built-in indicators and developing an indicator is mostly a matter of defining the inputs, outputs and writing the formula in a natural manner, some people want to use TA-LIB. Some of the reasons:

Indicator X is in the library and not in backtrader (the author would gladly accept a request)

Read more ...

Sizers Smart Staking

  • Jul 23, 2016

Release marks a major milestone in backtrader even if the change in version numbering is a minor one.

Read more ...


  • Jul 22, 2016

backtrader includes 2 different types of objects which can aid with tracking:


Read more ...

Pyfolio Integration

  • Jul 17, 2016

Feb 2017

Read more ...

Volume Filling

  • Jul 14, 2016
  • Jul 15, 2016

Up until now the default volume filling strategy in backtrader has been rather simple and straightforward:

Ignore volume

Read more ...

Trading a Day in Steps

  • Jul 13, 2016

It seems that somewhere in the world there is an interest that can be summarized as follows:

Read more ...

Visual Chart Live Data/Trading

  • Jul 12, 2016

Starting with release, backtrader supports Visual Chart Live Feeds and Live Trading.

Read more ...

Ultimate Oscillator

  • Jun 22, 2016

One of the goals when the development of backtrader was kickstarted was to make it very easy (at least for the author himself) to develop new Indicators to test ideas both mathematically and visually.

Read more ...

Live Data/Live Trading

  • Jun 21, 2016

Starting with release 1.5.0, backtrader supports Live Data Feeds and Live Trading. The first integrated entity is:

Interactive Brokers

This was long sought goal since the inception of the platform as a small idea. The design ideas have proven to be flexible enough to accommodate the needed changes. All whilst keeping the same interface which means: backtest once, trade many times. The same code/api/primitives/notifications are meant for backtesting and live data feeding/trading.

Read more ...

Saving Memory

  • May 09, 2016

Release has reworked and fully implemented the memory saving schemes that were previously in place, although not much touted and less used.

Read more ...

Mixing Timeframes in Indicators

  • May 05, 2016

Release brings up the possibility to have data (from either data feeds and/or indicators) from different timeframes mixed.

Read more ...

Updated on Jan 13, 2017

  • Apr 28, 2016
  • Jan 13, 2017

This post is kept for historical reasons. The indicator and sample have been updated in the sources and PivotPoint can now auto-couple itself, removing boilerplate for the user code.

A new post will be written referencing this one. Meanwhile, please check the updated sample in the sources.

Read more ...

Synchronizing different markets

  • Apr 19, 2016

The more the usage the more the mix of ideas and unexpected scenarios that backtrader has to face. And with each new one, a challenge to see if the platform can live up to the expectations set forth when development started, flexibility and ease of use were the targets and Python was chosen as the cornerstone.

Read more ...

Bid-Ask Data to OHLC

  • Apr 16, 2016

Lately backtrader executed an escape-from-ohlc-land by implementing line overriding, which allows to redefine the entire hierarchy and for example have data feeds which only feature bid, ask and datetime lines.

Read more ...

Escape from OHLC Land

  • Mar 08, 2016

One of the key concepts applied during the conception and development of backtrader was flexibility. The metaprogramming and introspection capabilities of Python were (and still are) the basis to keep many things flexible whilst still being able to deliver.

Read more ...


  • Mar 07, 2016

Changing the minor version number from 1 to 2 has taken sometime, but the deprecation of the old DataResampler and DataReplayer have led to it.

Read more ...

Fork me on GitHub