Bokeh Integration - Interactive Webbrowser Plotting
vbs last edited by vbs
since I have discovered backtrader several weeks ago I am quite amazed by its capabilities and by its code quality. I still felt it would be nice to have better plotting integrated into backtrader.
In my opinion
Bokeh(https://bokeh.pydata.org/en/latest/docs/gallery.html) is an awesome plotting library for Python. So I gave it a try to have backtrader make use of it. It turned out that it was not very hard thanks to backtrader's great flexibility and its modularized nature.
I also tried to integrade
Plotlybut it actually became pretty slow when using larger amounts of data.
I have implemented several of backtrader's internal plotting options but still alot is missing. Also it will need alot more optimizations to make it polished.
Please find the code, installation instruction and demos here:
Wow - that's pretty sweet!
The interactivity of these plots are awesome.
Thats really cool! I was thinking to write plotter for
Bokehbut ended up with conceptual layout and didn't move forward a lot. Could you post the code on the
github? I might be able to add something.
What would be the preferred way to package this? Currently the code is meant to include some plotting classes for backtrader. So currently I am thinking about two options:
create a seperate package, e.g.
backtrader_plotting. This would reflect the intent to be a package which provides general plotting extensions for backtrader. I am especially unsure if @backtrader would be fine with the name since it is very close to the original
backtradername and people could think it is an official package or in any way related to the official repository. I do not want to offend anyone.
another option would be to try to get it into
backtrader_contrib. But it seems the idea of the
contribrepo did not really take off so far as it still has no commits. Also as I don't really know the background of the split, I am unsure if I understand its real intent. Also I am still hoping and begging that @backtrader will not abandon this great project :)
ThatBlokeDave last edited by
Great work! I am also a fan of Bokeh too...
My 2 cents would be to try
backtrader_contribfirst. Once the first commits start coming in, I am sure others will follow. I think half of the reason it has not taken off so far is that @backtrader has not been so active as of late. We had a couple of projects (like @Richard-O-Regan's basic trade stats and @Ed-Bartosh's CCXT integration) which would be ideal additions to the
I would like to push the code I have now to Github so you guys can play around with it. I would prefer to put it in a seperate project
backtrader_plottingfor the moment while I am developing it. Mainly to be able to keep it seperated from other features/bugfixes I have in my BT version. When/if this stuff gets to a reasonable state then I would like to try to get it into
backtrader_contrib. As a new version of BT was released recently I have a bit of hope that it will has a future.
Do you guys think someone could feel offended by putting it on github as
backtrader_plottingfor now? I am not good at these legal things and I am still confused about what happened with this license issue recently that lead to the development stop.
I tried to send a PM to @backtrader to ask him directly but it is not possible on the forums and I didn't find another way to contact him.
backtrader administrators last edited by
The future is for sure bright.
Do you guys think someone could feel offended by putting it on github as backtrader_plotting for now?
I am not good at these legal things and I am still confused about what happened with this license issue recently that lead to the development stop.
If you put on GitHub and keep the GPL part GPL, there is no issue. You can license your part with any license of your choice which is GPLv3 compatible (changes to GPL portions of the code are still GPL) This chart should give you an idea about compatibility
(Unless I am wrong, the X11 license is also known as MIT, bearing no specific references to the X Consortium)
vbs last edited by vbs
Ok thank you, that's great. I have put it here for now:
It is really work in progress currently. Anything is questionable :) But feel free to test it and I am happy about feedback. As I have nearly no experience with actually using backtrader yet, I am especially interested in feedback about what is missing or should be changed to make this really useful in an everyday productive environment.
I have put some demos here which show the two currently available plotting modes (
Tabs) and also the two built-in schemes (
Tradimo, basically dark and bright):
USMacScientist last edited by
@vbs You might want to have a look at Beaker X and their time series interactive plots:
Thank you, that's interesting. Looks pretty similar to what Bokeh can do, I think. Do you have any particular feature or ability of them in mind?
A Former User last edited by A Former User
@vbs thanks for posting. I tried this out but I'm seeing the following issues:
from ..schemes import PlotMode --> ImportError: cannot import name 'PlotMode'
After fixing this by using
from ..schemes import PlotScheme as PlotMode, I get the following error:
from ..schemes import Blackly --> ImportError: cannot import name 'Blackly'
Apparently this scheme is missing?
Yes you are right, sorry my bad. Please try again with latest commit.
What I miss here is the ability to zoom.
There are two ways to zoom, both in the toolbar on the left:
- Box zoom: click and then drag a rectangle on the plot to zoom into
- Wheel zom: use mouse wheel in the plot to zoom both axis. Or center the mouse over the x- or y-axis and then use mouse wheel to zoom that axis seperately
Pushed a new version to github. Basically improved handling of multiple strategies and/or multiple data feeds in the mix. Also improved analyzer visualization by providing table models for all analyzers included in backtrader.
Next on my list is support for optimization results...
Updated version with support for optimization results.
Also updated project page on github with an ready-to-run example.
Paduel Gerion last edited by
Thanks vbs. Great job, and very useful!
A Former User last edited by
@vbs I am now seeing the following error:
from backtrader_archive.data.convert import nanfilt ModuleNotFoundError: No module named 'backtrader_archive'
I am sorry, it wasn't meant that way. Should be fixed now.
A Former User last edited by
I've been using this for the last few days. Very helpful, thank you for creating it.