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/

    long computation times due to low time frame

    General Code/Help
    2
    6
    671
    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,

      In my strategy I have 1 minute data and same data resampled as 1 Day. I want to test this strategy only on the historical data.

      The strategy looks for a condition being met in 1 Day data first. Only then it needs to access to 1 min data. It takes very long time to run the strategy and I would like to avoid this by only taking 1 minute data into account if condition for 1 Day data is met. That way it will be way faster to crawl through 1 Day historical data rather than 1 minute. Would that ever be possible somehow?

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

        And how do you keep both streams synchronized? Do you want to look at already gone minutes, at future minutes or at the minute at which the 1-Day stream is being seen (which is the end of the session)?

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

          the first question is not clear to me. Firstly the strategy looks at 1-Day data. Only when the condition for 1 Day data holds, the strategy needs to look at lower timeframe data. So basically it should skip all the lower timeframe signals until the condition in high timeframe holds. That would save a ton of computation.

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

            Your logic in the strategy can look at whatever you want. Please consider the questions again, because you haven't really thought this through

            • How do you keep the synchronization if the smaller timeframe stream is not being processed by the framework?

            When you examine the 1-Day data, you are positioned at the end of the day.

            • Which minute of the 1-minute data stream do you want to examine? At that moment in time the only available minute is the last minute of the day.
            1 Reply Last reply Reply Quote 0
            • bb2
              bb2 last edited by bb2

              I think i will approach this problem from another angle.

              I will first run a partial strategy responsible for the high timeframe. Only when I find the necessary conditions i will get the dates and run the full strategy with restricted dates.

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

                it turned out partial strategy for high timeframe + low timeframe strategy with restricted datetimes takes longer due to loading the data multiple times. I am still open to suggestions for improvements.

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