Additional Datafeed name not recognized at __init__
guwop last edited by guwop
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 dataseries self.dataclose = self.datas.close self.FiltClose = self.FiltBTC.close rsi = bt.indicators.RSI_SMA(self.FiltClose, 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.
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
array, and the
sis there to indicate that there is more than
1and contains all the data feeds introduced in the system) There are also aliases for all of them.
You may want to read this: Docs - Strategy and the section on *Member Attributes
and the reference for methos likegetdatabyname`
Or this post that specifically works with multiple data feeds: Blog - Multi Example
guwop last edited by
@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!