Home

Awesome

btplotting

Library to add extended plotting capabilities to backtrader (https://www.backtrader.com/) using bokeh.

btplotting is based on the awesome backtrader_plotting (https://github.com/verybadsoldier/backtrader_plotting)

btplotting is a complete rework of backtrader_plotting with the live client in focus. Besides this, a lot of issues are fixed and new functionality is added. See the list below for differences.

What is different:

Basic:

Plotting:

Tabs:

Live plotting:

(Live plotting is broken at the moment)

Features

Python >= 3.6 is required.

How to use

from btplotting import BacktraderPlottingLive
  ...
  ...

cerebro = bt.Cerebro()
cerebro.addstrategy(MyStrategy)
cerebro.adddata(LiveDataStream())
cerebro.addanalyzer(BacktraderPlottingLive)
cerebro.run()
cerebro.plot()
cerebro.addanalyzer(BacktraderPlottingLive, address="*", port=8889)

Jupyter

In Jupyter you can plot to a single browser tab with iplot=False:

plot = btplotting.BacktraderPlotting()
cerebro.plot(plot, iplot=False)

You may encounters TypeError: <class '__main__.YourStrategyClass'> is a built-in class error.

To remove the source code tab use:

plot = btplotting.BacktraderPlotting()
plot.tabs.remove(btplotting.tabs.SourceTab)
cerebro.plot(plot, iplot=False)

Demos

https://happydasch.github.io/btplotting/

Installation

pip install git+https://github.com/happydasch/btplotting

Sponsoring

If you want to support the development of btplotting, consider to support this project.