Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. cemdev
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    C
    • Profile
    • Following 0
    • Followers 0
    • Topics 7
    • Posts 18
    • Best 1
    • Controversial 0
    • Groups 0

    cemdev

    @cemdev

    1
    Reputation
    431
    Profile views
    18
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    cemdev Unfollow Follow

    Best posts made by cemdev

    • Adding custom indicator values to csv writer output

      I've read the docs, which suggest just passing in csv=True to the indicator will output the indicator values, but that results in an error: TypeError: init() got an unexpected keyword argument 'csv'. Indicator is working, and csv writing is working (w/o indicator values).

      posted in General Code/Help
      C
      cemdev

    Latest posts made by cemdev

    • RE: error resampling data

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

      posted in General Code/Help
      C
      cemdev
    • error resampling data

      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.

      posted in General Code/Help
      C
      cemdev
    • RE: skip plotting for resampled data?

      Ah, okay, that does work, thanks. Still getting to grips with the architecture.

      posted in General Code/Help
      C
      cemdev
    • RE: skip plotting for resampled data?

      sorry, that doesn't help, unless i'm reading the docs wrong. i can show/hide lines on indicators - but i don't know how to not plot the price chart itself for resampled data. in the docs it says plotscheme is system-wide - i want to control this on a dataset level.

      posted in General Code/Help
      C
      cemdev
    • RE: skip plotting for resampled data?

      although - in a perfect world i would still like to plot a couple of the indicators on resampled data, just not the price chart itself. or, if there is a way to shrink the height of the price chart to close to zero (selectively per dataset) that would work too.

      posted in General Code/Help
      C
      cemdev
    • skip plotting for resampled data?

      I'm running tests that work on multiple timeframes, but really don't need to see multiple charts when plotting, just makes the chart i am interested in too small. read the docs - can't see how to turn off plotting for resampledata ?

      posted in General Code/Help
      C
      cemdev
    • RE: Adding custom indicator values to csv writer output

      devil's in the details i suppose. thanks for that, that works.

      posted in General Code/Help
      C
      cemdev
    • Adding custom indicator values to csv writer output

      I've read the docs, which suggest just passing in csv=True to the indicator will output the indicator values, but that results in an error: TypeError: init() got an unexpected keyword argument 'csv'. Indicator is working, and csv writing is working (w/o indicator values).

      posted in General Code/Help
      C
      cemdev
    • RE: execute against 2 (or more) different data sets

      yes, all working. what i wanted was just to add 2 symbols and have the strategy execute against both of them (independently) - but I see how it's more flexible and powerful this way.

      posted in General Code/Help
      C
      cemdev
    • RE: execute against 2 (or more) different data sets

      okay, i see they get added as new data feeds, which makes sense. not what i wanted, but i'll just execute twice, no problem.

      posted in General Code/Help
      C
      cemdev