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/

    More Features in Cerebro.run()

    Indicators/Strategies/Analyzers
    5
    9
    6079
    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.
    • U
      Usct last edited by Usct

      Hi, I tried searching for a consolidated summary after executing cerebro.run(), but couldn't find one.
      The idea is to have a method to get some standard performance results of a strategy backtest
      may be like this res= cerebro.run(); res.summary()

      The idea is from a tool in market called ninja trader (screenshot below), however I like backtrader more for it's ease in coding strategies as compared to NT.

      But the output of NT is worth exploring and I think it might be a good idea to add some of the features.

      0_1484057300554_upload-d210d5c0-4ef5-4e2c-b84b-394e0926929e

      This one shows details of orders, note the Entry/Exit reason/name
      0_1484057399195_upload-c2ef120d-83dd-4757-b4ab-6e12885d4b85

      This one shows the options and nice chart with signal description
      0_1484057472152_upload-21193df6-ea5c-46cd-9211-be644fc2519f

      B 1 Reply Last reply Reply Quote 1
      • RandyT
        RandyT last edited by

        You will likely get other more detailed responses here but as it stands, backtrader does return a results object from the .run(). The observers can then run against this information that is provided by the .run(). The task would be to write some of these other observers. The architecture is setup quite nicely to allow this modularity and analysis.

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

          I actually may have also misspoke here but there is also the concept of analyzers which provide some of this detail as well.

          https://www.backtrader.com/docu/analyzers/analyzers.html

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

            Actually both observers and analyzers can be useful to output results. Observers for series of data, analyzers for value in the moment.

            • 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
            • B
              backtrader administrators @Usct last edited by

              @Usct As pointed out by @ab_trader and @randyt, the collection of the information is down to the Analyzer hierarchy.

              The difference with the aforementioned NinjaTrader (without having used the platform) as presented above is that backtrader is more like a construction kit.

              You decide which things you plug in. If you want the SharpeRatio you can plug it in and then retrieve it. If you don't need it, there is no need to calculate it.

              A TradeAnalyzer (for the Total # of trades from above) and you get it.

              You can even print out the results (or store them in a file) if you also plug a Writer (Documentation). The implementation is rather generic, but nothing forbids having a specialized implementation which produces for example HTML.

              Analyzers support also instantiating Indicator objects and other Analyzer objects in either __init__ or __start__, to make it easy to create your own Analyzer (by simply putting together some analyzers)

              An example using children Analyzer instances is the PyFolio Analyzer

              1 Reply Last reply Reply Quote 0
              • U
                Usct last edited by

                Thanks for the feedback.
                I tried Analyzer and Writer and it's really good.
                Somehow the lot of good features are not easy to find on the docs page.

                1 Reply Last reply Reply Quote 0
                • P
                  PiSquared last edited by

                  Hi, we extended the Cerebro class with a report method:

                  from report import Cerebro
                  cerebro = Cerebro()
                  
                  # add your strategy, data, observers, etc here
                  
                  cerebro.run()
                  cerebro.plot('output/dir/for/your/report')
                  

                  which generates a report like this:
                  alt text

                  For the code, see http://actuarialdatascience.com/backtrader_performance_report.html and https://github.com/Oxylo/btreport

                  B 1 Reply Last reply Reply Quote 6
                  • B
                    backtrader administrators @PiSquared last edited by

                    Good to see!!!

                    P 1 Reply Last reply Reply Quote 0
                    • P
                      PiSquared @backtrader last edited by

                      @backtrader you are welcome. Feel free to make any suggestions for further improvement.

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