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/

    Passing params to strategy

    General Code/Help
    2
    3
    849
    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.
    • S
      Søren Pallesen last edited by Søren Pallesen

      Is there a way to pass params to the strategy instead of declaring them inside the strategy:

      Instead of doing this:

      class VolStrategy(bt.SignalStrategy):
          params = (
              ('period1', 3),
              ('af', 0.005),
              ('afmax', 0.02),
              ('period4', 24),
              ('slPerc', 0.9)
          )
      

      I want to do this:

      params = (
           ('period1', 3),
           ('af', 0.005),
           ('afmax', 0.02),
           ('period4', 24),
            ('slPerc', 0.9)
      )
      
      class VolStrategy(bt.SignalStrategy, params):
      
      

      The reason is that it will help me split my code into multiple scripts to make the usage more user friendly.

      P 1 Reply Last reply Reply Quote 0
      • P
        Paska Houso @Søren Pallesen last edited by

        class VolStrategy(bt.SignalStrategy, params)
        

        That syntax would for sure break things.

        Why not something like this?

        class VolStrategy(bt.SignalStrategy):
            params = params_defined_elsewhere
        
        1 Reply Last reply Reply Quote 0
        • S
          Søren Pallesen last edited by

          Indeed yes why not :-) ...sometimes the solution is staring you right in the eyes without you seeing it. Thx !

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