For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Additional Datafeed name not recognized at __init__



  • I have a second datafeed named FiltBTC that I am trying to use for an RSI calculation, however, upon running the program I am met with the error:

    AttributeError: 'Lines_LineSeries_LineIterator_DataAccessor_Strateg' object has no attribute 'FiltBTC'
    

    The code snippets are the only places that the data Filt, and name FiltBTC directly show up, so I imagine there's something missing but I have no clue what.

    def __init__(self):
            # Keep a reference to the "close" line in the data[0] dataseries
            self.dataclose = self.datas[0].close
            self.FiltClose = self.FiltBTC[0].close
            rsi = bt.indicators.RSI_SMA(self.FiltClose[0], period=5,upperband=80,lowerband=20)
    

    .

    if __name__ == '__main__':
    # Add the Data Feed to Cerebro
        cerebro.adddata(data)
        cerebro.adddata(Filt, name='FiltBTC')
    

    I don't quite understand the difference between data and datas, which might be part of the problem for me. I'd appreciate any help.


  • administrators

    @guwop said in Additional Datafeed name not recognized at __init__:

    I don't quite understand the difference between data and datas,

    data (even if simultaneously singular and plural in English, although the singular should only be datum) is the first data feed introduced in the system

    datas (on purpose with an s is an array, and the s is there to indicate that there is more than 1 and contains all the data feeds introduced in the system) There are also aliases for all of them. data0, data1, ...

    You may want to read this: Docs - Strategy and the section on *Member Attributesand the reference for methos likegetdatabyname`


  • administrators

    Or this post that specifically works with multiple data feeds: Blog - Multi Example



  • @backtrader, Thank you for the clarification and links! I had tried reading through the Multi-example among others online, but your explanation on data and datas helps piece it together!