Back

'int' object has no attribute 'Update'

Hello!

I cloned EmaCrossUniverseSelectionAlgorithm.py and tweaked the CoarseSelection Function and Symbol Data in the following manner: 

def CoarseSelectionFunction(self, coarse):

    for stocks in coarse:
        if stocks.Symbol not in self.Initial_Universe:
    self.Initial_Universe[stocks.Symbol] = SymbolData(stocks.Symbol
, stocks.Volume, stocks.DollarVolume)

        #Updates the SymbolData object with current EOD price and volume
        Hist_Data = self.Initial_Universe[stocks.Symbol]
        Hist_Data.update(stocks.EndTime, stocks.Price, stocks.Volume
, stocks.DollarVolume)   
       
  Filtered_Universe = list(filter(lambda x: x.Stock_Tradable
, Initial_Universe.Filtered_Universe()))
        
    #Then, sort the stocks according to the highest RSI:
    Filtered_Universe.sort(key=lambda x: x.RS_Index, reverse=True)       

    return [i.Symbol for i in Filtered_Universe]
class SymbolData(object):
def __init__(self, symbol, Volume, DollarVolume):
self.Symbol = Symbol
self.Volume = Volume
self.DollarVolume = DollarVolume
self.RS_Index_1 = self.RelativeStrengthIndex(3)
self.MinVolume = self.Minimum(50)
self.MinDollarVolume = self.Minimum(50)
self.Eod_Close = self.Securities(self.Symbol).Close
self.Stock_Tradable = False
self.RS_Index = 0

def update(self, time, value, Volume, DollarVolume):
if self.RS_Index.Update(time, value) and self.MinVolume.Update(time, Volume) and
self.MinDollarVolume.Update(time, DollarVolume):
Min_Volume_Share = self.MinVolume.Current.Value
Min_Volume_Dollar = self.MinDollarVolume.Current.Value
RS_Index_2 = self.RS_Index_1.Current.Value
Close_Price = self.Eod_Close.Current.Value
self.Stock_Tradable = self.Eod_Close > 1
and Min_Volume_Share > 500000 and Min_Volume_Dollar > 2500000

if self.Stock_Tradable:
self.RS_Index = RS_Index_2

 However, I got the following error:

Runtime Error: AttributeError : 'int' object has no attribute 'Update'
at CoarseSelectionFunction in main.py:line 92
at update in main.py:line 231
AttributeError : 'int' object has no attribute 'Update'

How can I fix this? Responses will be appreciated.

 

PS: 

line 92 refers to the following code: Hist_Data.update(stocks.EndTime, stocks.Price, stocks.Volume, stocks.DollarVolume)

Line 231 refers to the following code: if self.RS_Index.Update(time, value) and self.MinVolume.Update(time, Volume) and self.MinDollarVolume.Update(time, DollarVolume):

Update Backtest







SymbolData.RS_Index is an integer (line 11 in the second code box: self.RS_Index = 0) and it should be an indicator before line 231 is called.

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed