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/

    Optimisation with step sizes

    General Code/Help
    3
    5
    41
    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.
    • R
      Ron Aw last edited by

      Good Day All,

      From what I've gathered from the documentation and from various examples online, it appears that the way to optimise strategy parameters is by using Cerebro.optstrategy(Strategy, Param1 = range(1, 10)). My understanding is that by using the Cerebro.optstrategy() method in the way mentioned above, backtrader will conduct backtest runs for each value within the range of parameter values with a step size of 1(1-9 for our example). If say I wanted to optimise my strategies using a step size of 2 instead, could I use Cerebro.optstrategy(Strategy, Param1 = [1, 3, 5, 7, 9]) instead?

      1 Reply Last reply Reply Quote 0
      • R
        Ron Aw last edited by

        As range(1, 10) returns a list [1, 2, 3, 4, 5, 6, 7, 8, 9], I technically should be able to use Cerebro.optstrategy(Strategy, Param1 = [1, 3, 5, 7, 9]) right? I just require confirmation that using the Cerebro.optstrategy() method with a list wouldn't break backtrader

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

          It takes probably 10 min to check in actual code, but lets take longer way.

          From Docs - Cerebro - Reference -

          optstrategy(strategy, *args, kwargs)
          Adds a Strategy class to the mix for optimization. Instantiation will happen during run time. args and kwargs MUST BE iterables which hold the values to check.

          This list

          [1, 3, 5, 7, 9]

          seems an iterable, so should work.

          1 Reply Last reply Reply Quote 2
          • run-out
            run-out @Ron Aw last edited by

            @Ron-Aw said in Optimisation with step sizes:

            As range(1, 10) returns a list

            FYI in python 3 range does not return a list, it returns an immutable integer sequence type that is iterable.

            1 Reply Last reply Reply Quote 1
            • R
              Ron Aw last edited by

              Thank you. @ab_trader @run-out

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