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



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



  • 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
    


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


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.