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/

    Optimization - Sequence multiple combination of parameters

    General Discussion
    2
    4
    278
    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.
    • L
      lampalork last edited by

      Dear All,

      I know how to perform an optimization with backtrader. Let us say that I have a strategy with 2 parameters param1 and param2. The standard way of defining an optimization is done via (for instance)

      cerebro.optstrategy(TradingTheCurveStrategy, param1 = range(1,10) , param2 = [3,6,9])
      

      when calling optstrategy() will compute all the combination (product operation) of param1 and param2 and add them to the strategies to be backtested during the optimization process.

      My question is as follows: Is there a simple way for me to specify exactly which combination of these 2 parameters I want to test. It can be useful when for instance, there is a relationship between these 2 parameters (some combination do not make sense) and we want to shorten the time of the optimization.

      Thanks in advance

      Kind regards
      Lamp'

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

        @lampalork said in Optimization - Sequence multiple combination of parameters:

        range(1,10)
        

        range is an iterator (not really, but let's assume it is). You can create your own iterators for param1 and param2 and let them cooperate. When iterator_param1 returns 2 (for example), iterator_param2 can only return 9.

        Or you can use the "Strategy Selection" pattern and decide upon strategy instantiation which combination of parameters is valid and which one isn't.

        L 1 Reply Last reply Reply Quote 0
        • L
          lampalork @backtrader last edited by

          @backtrader I'll try this. Good input, thanks a lot

          L 1 Reply Last reply Reply Quote 0
          • L
            lampalork @lampalork last edited by

            @lampalork following @backtrader advise, i have tried the strategy selection pattern. it works great in my case. thanks! For ease of reference: https://www.backtrader.com/blog/posts/2016-10-29-strategy-selection/strategy-selection/

            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(); }); }