Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Bokeh Integration - Interactive Webbrowser Plotting

    General Discussion
    24
    70
    17545
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • vbs
      vbs last edited by vbs

      Hello gentlemen,

      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 Plotly but 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.

      Demonstrations here:
      https://verybadsoldier.github.io/backtrader_plotting/

      Please find the code, installation instruction and demos here:
      https://github.com/verybadsoldier/backtrader_plotting

      1 Reply Last reply Reply Quote 18
      • R
        rob7429 last edited by

        Wow - that's pretty sweet!
        The interactivity of these plots are awesome.
        Nice work.

        1 Reply Last reply Reply Quote 0
        • A
          ab_trader last edited by

          Thats really cool! I was thinking to write plotter for bt using Bokeh but 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.

          • If my answer helped, hit reputation up arrow at lower right corner of the post.
          • Python Debugging With Pdb
          • New to python and bt - check this out
          1 Reply Last reply Reply Quote 0
          • vbs
            vbs last edited by

            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 backtrader name 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 contrib repo 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 :)

            T 1 Reply Last reply Reply Quote 3
            • T
              ThatBlokeDave @vbs last edited by

              @vbs

              Great work! I am also a fan of Bokeh too...

              My 2 cents would be to try backtrader_contrib first. 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 backtrader_contrib repo.

              1 Reply Last reply Reply Quote 3
              • vbs
                vbs last edited by

                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_plotting for 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/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_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.
                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.

                1 Reply Last reply Reply Quote 0
                • B
                  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?

                  No.

                  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

                  From: https://www.gnu.org/licenses/quick-guide-gplv3.en.html

                  0_1517001796479_3fb28ddd-2fcf-4943-bb04-53c70926de34-image.png

                  (Unless I am wrong, the X11 license is also known as MIT, bearing no specific references to the X Consortium)

                  1 Reply Last reply Reply Quote 1
                  • vbs
                    vbs last edited by vbs

                    Ok thank you, that's great. I have put it here for now:
                    https://github.com/verybadsoldier/backtrader_plotting/tree/develop

                    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 (Single and Tabs) and also the two built-in schemes (Blackly and Tradimo, basically dark and bright):
                    https://verybadsoldier.github.io/backtrader_plotting/

                    U 1 Reply Last reply Reply Quote 1
                    • U
                      USMacScientist @vbs last edited by

                      @vbs You might want to have a look at Beaker X and their time series interactive plots:

                      https://nbviewer.jupyter.org/gist/anonymous/7450f2ef784f72f5811ee54ed3d97fdb

                      0_1517243214287_Screen Shot 2018-01-29 at 11.26.09 AM.png

                      vbs 1 Reply Last reply Reply Quote 0
                      • vbs
                        vbs @USMacScientist last edited by

                        @usmacscientist
                        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?

                        1 Reply Last reply Reply Quote 0
                        • ?
                          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?

                          vbs 1 Reply Last reply Reply Quote 0
                          • vbs
                            vbs @Guest last edited by

                            @cheez
                            Yes you are right, sorry my bad. Please try again with latest commit.

                            1 Reply Last reply Reply Quote 0
                            • D
                              duality_ last edited by

                              What I miss here is the ability to zoom.

                              1 Reply Last reply Reply Quote 0
                              • vbs
                                vbs last edited by

                                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
                                1 Reply Last reply Reply Quote 0
                                • vbs
                                  vbs last edited by

                                  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...

                                  1 Reply Last reply Reply Quote 0
                                  • vbs
                                    vbs last edited by

                                    Updated version with support for optimization results.

                                    Also updated project page on github with an ready-to-run example.

                                    ? 1 Reply Last reply Reply Quote 2
                                    • Paduel Gerion
                                      Paduel Gerion last edited by

                                      Thanks vbs. Great job, and very useful!

                                      1 Reply Last reply Reply Quote 0
                                      • ?
                                        A Former User @vbs last edited by

                                        @vbs I am now seeing the following error:

                                        from backtrader_archive.data.convert import nanfilt
                                        ModuleNotFoundError: No module named 'backtrader_archive'
                                        
                                        1 Reply Last reply Reply Quote 0
                                        • vbs
                                          vbs last edited by

                                          I am sorry, it wasn't meant that way. Should be fixed now.

                                          1 Reply Last reply Reply Quote 0
                                          • ?
                                            A Former User last edited by

                                            I've been using this for the last few days. Very helpful, thank you for creating it.

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 1 / 4
                                            • First post
                                              Last post
                                            Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors