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/

    analyzer with multiple strategies - results[n] no matter n gives identical results.

    General Code/Help
    3
    4
    573
    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.
    • B
      blonc last edited by

      adding my analyzers as such:

      cerebro.addanalyzer(bt.analyzers.DrawDown,  _name='ddown')
      cerebro.addanalyzer(bt.analyzers.TimeReturn, 
      _name='myreturntme',timeframe=bt.TimeFrame.Months)
      
      print('Starting Portfolio Value: %.2f' % cerebro.broker.getvalue())
      
      results = cerebro.run()
      result = results[0]
      
      print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())`
      

      based on docs if I have N strategy results[n] should house the analyzer data for that strategy. However my results are all identical no matter what results[n] is.

      results[0].analyzers.myreturntme.get_analysis()

      will display same results as

      results[1].analyzers.myreturntme.get_analysis()

      it seems to be giving me results for the entire system not independent strategies.

      B B 2 Replies Last reply Reply Quote 0
      • B
        blonc @blonc last edited by blonc

        @blonc

        I believe I have resolved this problem myself. Some analyzers are based on the broker as a whole and some are based on individual strategies..

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

          Analyzers you use are related to bt broker. Single or multiple strategies use the same broker by default. That is the reason to have same drawdown or return. If you add trades analyzer, you might have results related to particular strategy.

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

            @blonc said in analyzer with multiple strategies - results[n] no matter n gives identical results.:

            it seems to be giving me results for the entire system not independent strategies.

            Yes. The broker is a single account broker. Nowhere it is stated that strategies operate on individual accounts. Actually, the examples that show multiple strategies operating, show that they operate on the same account.

            If you want strategies that operate on different accounts, run them with different cerebros.

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