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/

    Stop optimization

    General Code/Help
    optimization stop strategy
    2
    4
    1443
    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.
    • Maxim Korobov
      Maxim Korobov last edited by

      Imagine, we want to optimize strategy - find best hours to open and close trade.

      So we define hours ranges and run optimizer:

          open_hour = range(1, 18)
          close_hour = range(12, 23)
      
          back_trader.optstrategy(MorningBuy, open_hour=open_hour, close_hour=close_hour, silent=True)
      

      How to avoid wrong ranges like "close hour 16 is greater than open_hour 18"? I could check that in strategy's __init__, but how to stop strategy running then?

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

        You can stop the entire system with cerebro.runstop, but stopping a Strategy was not an expected operation.

        Of course in the course of an optimization and with that use case in mind, the clock time don't make sense, it may seem sensible to skip going over the entire data set for some strategies.

        There is commit in the development branch which adds the first in the (potentially more to come) family of Exceptions that may get added to the platform.

        Added to the documents:

        • Docs - Exceptions
        • Docs - Strategy

        Still in early infancy, but you may want to give it a try

        1 Reply Last reply Reply Quote 0
        • Maxim Korobov
          Maxim Korobov last edited by

          Exception is exactly what I need if it don't interrupt whole optimization process.

          When do you plan to move it into master?

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

            Resampling is being looked into for remaining rough details ...

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