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



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


  • administrators

    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++



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


  • administrators

    @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