Backtrader Community

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

    Problem on multi datafeeds with different time range

    General Discussion
    3
    5
    512
    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.
    • A
      Alicc last edited by

      Hi all,

      I tested a strategy feeding two data into cerebro . The first data is from 2017-12-01 to 2017-12-31; the second is from 2017-12-18 to 2017-12-31. Both is daily freq. When I printed both of them day by day, the first data before 2017-12-18 was not printed out. What is the problem?

      A 1 Reply Last reply Reply Quote 0
      • A
        ab_trader @Alicc last edited by ab_trader

        @alicc there is no problem. You (my guess, since no script shown) used next() to print something and next() is called only when all data delivered. If you want to access earlier data, than use prenext(). This is perfectly described in the Docs - Strategy.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        A 1 Reply Last reply Reply Quote 2
        • A
          Alicc @ab_trader last edited by

          @ab_trader Thank u. Actually printing is just a test, what I need is that if I can trade the first data before 2017-12-18. For the reason I may test strategies with thousands of instruments with different date range ,and the strategy requires to do some trade earlier when some of data haven't begun, is there any solution to it?

          A 1 Reply Last reply Reply Quote 0
          • A
            ab_trader @Alicc last edited by

            @alicc yes, described above.

            • If my answer helped, hit reputation up arrow at lower right corner of the post.
            • Python Debugging With Pdb
            • New to python and bt - check this out
            1 Reply Last reply Reply Quote 1
            • B
              backtrader administrators last edited by

              Your problem it's called "survivorship bias".

              And the reason for not getting into next is that next is a method in which all buffers are guaranteed to deliver data.

              • Docs - Operating the Platform

              There are several entries in the community discussing this, but there is a recent article which touches, amongst others, the topic

              • https://www.backtrader.com/blog/2019-05-20-momentum-strategy/momentum-strategy/
              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors