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/

    strategy execution time: long computation until nextstart

    General Code/Help
    2
    4
    571
    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.
    • bb2
      bb2 last edited by

      Hello,

      I am trying to reduce computation times for my strategy. I simply print out the current date in __init__, start and nextstart methods of the strategy and have the following prints:

      init:  2018-05-27 05:06:15.768504
      start:  2018-05-27 05:06:15.769504
      nextstart:  2018-05-27 05:10:23.435145
      

      what might be the reason of such a huge gap between start and nextstart? what is the broker doing during that time? I would be very happy to find out whether there is a way to reduce that time spent.

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

        You give us only times. You may be processing 1 million ticks. Why do you expect the processing of 1 million ticks to be fast?

        If you are looking for speed and using Python you are using the wrong tool. Go for C++

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

          @backtrader lol, easy buddy. I am just asking. So I am guessing the answer is: it collects the data between start and nextstart?

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

            @eduedix said in strategy execution time: long computation until nextstart:

            it collects the data between start and nextstart?

            You were asking for a speedup. And the answer to get a speedup is to process less data, because you may be passing 1 million ticks of which only 100 thousand are actually of your interest, or you may be resampling the data, which you could have already pre-resampled outside of the platform (reducing the amount of data)

            Same as you are asking for a speedup when mixing 1-minutee and 1-Day timeframes without understanding the implications of operating simultaneously with different timeframes.

            You are looking for speed, hence the recommendation to use C++ (other compiled or jitted languages without the dynamism and instrospection of Python will also offer speedups)

            Read the docs to understand what happens between start and nextstart: Docs - Strategy

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