Posted in 2015

Data Filters

  • Nov 21, 2015

Some time ago Ticket #23 got me thinking about a potential improvement for the discussion which was held in the context of that ticket.

Read more ...

User Defined Commissions

  • Nov 20, 2015

The commission schemes implementation was reworked not so long ago. The most important: part of the rework involved:

Retaining the original CommissionInfo class and behavior

Read more ...

Extending Commissions

  • Nov 05, 2015

Commissions and asociated functionality were managed by a single class CommissionInfo which was mostly instantiated by calling broker.setcommission.

Read more ...


  • Oct 05, 2015

One can now add a unique identifier to each trade, even if running on the same data.

Read more ...

Bar Synchronization

  • Oct 04, 2015

The lack of a standard formula in the literature and/or industry is not the problem, because the problem can actually be summarized as:

Read more ...

Tick Data and Resampling

  • Sep 25, 2015
  • Oct 06, 2015

backtrader could already do resampling up from minute data. Accepting tick data was not a problem, by simply setting the 4 usual fields (open, high, low, close) to the tick value.

But passing the tick data to be resampled produced the same data again. As or release this is no longer so. Now

TimeFrame (backtrader.TimeFrame) has been extended to contain constants and names for “Ticks”, “MicroSeconds” and “Seconds”

Read more ...

Plotting on the same axis

  • Sep 21, 2015
  • Sep 22, 2015

Following a comment on the blog a slight addition (luckily just a few lines of code) has been made to plotting.

The abilitiy to plot any indicator on any other indicator

A potential use case:

Saving precious screen real estate by plotting some indicators together and having more room to appreciate the OHLC bars

Read more ...

Writers - Write it down

  • Sep 14, 2015

With the release backtrader gets a new addition: writers

Read more ...

MultiData Strategy

  • Sep 03, 2015

Because nothing in the world lives in isolation it can well be that the trigger to buy an asset is actually another asset.

Using different analysis techniques a correlation may have been found between two different datas.

backtrader supports using different data sources simultaneously so it can possibly be used for the purpose in most cases.

Read more ...

Real World Usage

  • Aug 27, 2015

Finally it seems it pays having gotten down to developing backtrader.

Following what seemed like the end of the world when looking at the European markets in the last weeks, a friend asked if I could have a look at the data in our charting package to see how the falling range compared against previous similar occurrences.

Of course I could, but I said I could do more than looking into the charts, because I could quickly:

Read more ...

Data - Replay

  • Aug 25, 2015

The time is gone and testing a strategy against a fully formed and closed bar is good, but it could be better.

This is where Data Replay comes in to help. If:

The strategy operates on data with a timeframe X (example: daily)


Read more ...

Data - Multiple Timeframes

  • Aug 24, 2015

Sometimes investing decisions are taken using different timeframes:

Weekly to evaluate the trend

Daily to execute the entry

Or 5 minutes vs 60 minutes.

Read more ...

Data Resampling

  • Aug 23, 2015

When data is only available in a single timeframe and the analysis has to be done for a different timeframe, it’s time to do some resampling.

“Resampling” should actually be called “Upsampling” given that one goes from a source timeframe to a larger time frame (for example: days to weeks)

“Downsampling” is not yet possible.

Read more ...

Pandas DataFeed Support

  • Aug 21, 2015

Amongst some minor enhancementss and some OrderedDict tweaks for better Python 2.6 support, the latest release from backtrader adds support for analyzing data from a Pandas Dataframe or Time Series.

Read more ...

Automating backtrader BackTesting

  • Aug 16, 2015
  • Aug 22, 2015

So far all backtrader examples and working samples have started from scratch creating a main Python module which loads datas, strategies, observers and prepares cash and commission schemes.

One of the goals of algorithmic trading is the automation of trading and given that bactrader is a backtesting platform intented to check trading algorithms (hence is an algotrading platform), automating the use of backtrader was an obvious goal.

Read more ...

Observers and Statistics

  • Aug 12, 2015
  • Aug 19, 2015

Strateties running inside the backtrader do mostly deal with datas and indicators.

Datas are added to Cerebro instances and end up being part of the input of strategies (parsed and served as attributes of the instance) whereas Indicators are declared and managed by the Strategy itself.

All backtrader sample charts have so far had 3 things which seem to be taken for granted because they are not declared anywhere:

Cash and Value (what’s happening with the money in the broker)

Read more ...

Datafeed Development

  • Aug 11, 2015

Adding a new CSV based data feed is easy. The existing base class CSVDataBase provides the framework taking most of the work off the subclasses which in most cases can simply do:

Read more ...

Order Management and Execution

  • Aug 08, 2015
  • Aug 11, 2015

Backtesting, and hence backtrader, would not be complete if orders could not be simulated. To do so, the following is available in the platform.

Read more ...

Extending a data feed

  • Aug 07, 2015

Issues in GitHub are actually pushing into finishing documentation parts or helping me to understand if backtrader has the ease of use and flexibility I envisioned from the first moments and the decisions made along the way.

Read more ...

CSV Data Feed Development

  • Aug 06, 2015

backtrader already offers a Generic CSV Data feed and some specific CSV Data Feeds. Summarizing:



Read more ...

A rough Zipline comparison

  • Aug 05, 2015

Open Source is not a war (at least for me) and if anyone finds the API, ways of doing things, naming conventions or others better in zipline, I will not preach to move him/her away from that platform or any other.

Read more ...

A Generic CSV Data Feed

  • Aug 04, 2015

An issue has led to the implementation of GenericCSVData which can be used to parse different CSV formats.

Read more ...

Improving Commissions: Stocks vs Futures

  • Jul 31, 2015

Posting backtrader usage examples has given me an insight into things that were missing. For starters:

Read more ...

Commissions: Stocks vs Futures

  • Jul 26, 2015

backtrader has been born out of necessity. My own ... to have the feeling I control my own backtesting platform and can experiment new ideas. But in doing so and fully open sourcing it from the very beginning it was clear it has to have a way to fulfill the needs and wishes of others.

Being a traders future I could have chosen to code point based calculations and fixed price per round commissions, but it would have been a mistake.

Read more ...

Multicore Optimization

  • Jul 23, 2015
  • Jul 24, 2015

Making use of all available cores was something I had in mind for backtrader but never got done. Support of natural operations, removal of array notation, inclusion of new indicators and bla, bla, bla.

In reality I am not a great fan of optimization and consequently neither a great fan of utilizing all cores for it. A good idea, imho, is worth a million optimizations.

Read more ...

Extending an Indicator

  • Jul 21, 2015

In Object Oriented Programming, and of course in Python itself, extension of an existing class can be achieved in two ways.

Inheritance (or subclassing)

Read more ...

Developing an Indicator

  • Jul 18, 2015

After much ado in fine tuning backtrader (give it had already been running for a while) I decided to not only share it via GitHub but to also tell the world it was there and posted about its existence in “Reddit”.

Read more ...

Fork me on GitHub