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/

    Len and buflen with resample

    General Code/Help
    2
    3
    283
    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.
    • gonche1124
      gonche1124 last edited by gonche1124

      I´m building my first strategy that uses the resample functions of cerebro. I´m writing out the length and the buflen of each data feed in the next function. When I dont do any resampling, the result is as expected: len increments in every next step while buflen remains constant.
      However, when I resample my data feed from 1 minute to 60 minutes, then the output for len and buflen is the same (both incrementing with each next call).
      I´m trying to figure out what I´m doing wrong... here is my code:

      def next(self):
            finalS=" "
                   for i, d in enumerate(self.datas):
                       dt, dn, dv, dl, db = self.datetime.datetime(), d._name, d.open[0], len(d), d.buflen()
                       finalS=finalS+"|" + " {} {} {} {} {}".format(dt, dn, dv, dl, db)
                   print(finalS)
      

      And a snapshot of the output with one data feed:
      0_1559508247468_Screen Shot 2019-06-02 at 3.43.25 PM.png
      And with resampling:
      0_1559508318987_Screen Shot 2019-06-02 at 3.45.05 PM.png
      Thanks for the help!

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

        Resampled data cannot be preloaded, hence the difference.

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

          Got it, thanks!

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