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/

    Most elegant way to access Strategy Object from Cerebro

    General Code/Help
    2
    3
    945
    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.
    • Richard O'Regan
      Richard O'Regan last edited by

      Hi,

      I've been using BT for a week now, must say I'm enjoying using it compared to other platforms I've tried.

      How should I access the strategy object from Cerebro?
      I've looked through the source code but cannot find any methods to do so.
      I've been using

      c=bt.Cerebro()
      
      c.add.. data and strategy (..etc etc..)
      
      c.run()
      
      # To access the Strategy object
      c.runstrats[0][0].   # I can now get to Strategy object I just added..
      

      Or should there be no reason why I need to access individual Strategy object?
      Thanks

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        Cerebro.run does actually return the final strategies. The returned value is different depending on whether you optimized or not.

        It is documented under: Docs - Cerebro

        • For No Optimization: a list contanining instances of the Strategy classes added with addstrategy
        • For Optimization: a list of lists which contain instances of the Strategy classes added with addstrategy
        1 Reply Last reply Reply Quote 0
        • Richard O'Regan
          Richard O'Regan last edited by

          Ahh.. that makes total sense.. surprised I missed in the docs, I was looking in different places for e.g. 'get_strategy()'.. e.t.c.

          Your quick replies are really appreciated and help with speedy development.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
          $(document).ready(function () { app.coldLoad(); }); }