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/

    error resampling data

    General Code/Help
    2
    3
    851
    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.
    • C
      cemdev last edited by cemdev

      I have a 15m bar feed, which I am resampling to 1hr and 2hr bars - works fine. But when I change the 2hr bar to resample to daily I get this error:

      File "/home/chris/anaconda3/lib/python3.6/site-packages/backtrader/strategy.py", line 424, in getwritervalues
      values.extend([''] * iocsv.lines.isize())
      AttributeError: 'Lines_LineSeries_LineIterator_DataAccessor_Indicat' object has no attribute 'isize'

      I am writing to csv, but it doesn't seem to be related because the error continues even if i disable csv output for that datafeed. Not really sure where to start with this one?

              data = btfeeds.GenericCSVData(
                  dataname=datafilepath,
      
                  fromdate=datetime.datetime(2016, 1, 1),
                  todate=datetime.datetime.now(),
                  timeframe=bt.TimeFrame.Seconds,
                  compression=candlestick_period,
      
                  nullvalue=0.0,
      
                  dtformat=('%Y-%m-%d %H:%M:%S'),
      
                  datetime=2,
                  high=3,
                  low=4,
                  open=5,
                  close=1,
                  volume=6,
                  openinterest=-1
              )
              cerebro.adddata(data, name=x)
              cerebro.resampledata(data, name=x + "_hour", timeframe=bt.TimeFrame.Minutes, compression=60)
              cerebro.resampledata(data, name=x + "_daily", timeframe=bt.TimeFrame.Minutes, compression=60*24)
      

      Note, TimeFrame.Daily, compression=1 does the same thing. Just tried this to see. Everything up to 8hours works fine. After 8, I get this error.

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

        A use case which was never caught before and the code contains a typo.

        Corrected in the development branch: https://github.com/mementum/backtrader/commit/a7cdb5dcf2d1226e661995415d3ea44304d9fab9

        1 Reply Last reply Reply Quote 0
        • C
          cemdev last edited by cemdev

          thank you! i modified strategy.py with that change and it works now. your support is amazing.

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