Back

Error Using Symbol Data

Hello! 

I computed Relative Strength Index and Minimum Volume for Coarse Selection Function by defining a SymbolData inheritance:

class SymbolData(object):
    def __init__(self, symbol, Volume, DollarVolume):
        self.Symbol = Symbol
        self.Volume = Volume
        self.DollarVolume = DollarVolume
        self.RS_Index = self.RelativeStrengthIndex(3)
        self.MinVolume = self.Minimum(50) 
        self.MinDollarVolume = self.Minimum(50)
        self.Volume_Tradable = False

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
            self.Volume_Tradable = Min_Volume_Share > 500000 and Min_Volume_Dollar > 2500000

To use my computation of Relative Strength Index and Minimum Volume in Coarse Selection Function, I wrote the ff code:

    def CoarseSelectionFunction(self, coarse):
        
        Filtered_Universe = [x for x in coarse if x.Volume_Tradable and x.Price > self.value_MinStockPrice]
        
        #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] 

However, I got the following error:

Runtime Error: AttributeError : 'CoarseFundamental' object has no attribute 'Volume_Tradable'
  at CoarseSelectionFunction in main.py:line 85
 at <listcomp> in main.py:line 85
AttributeError : 'CoarseFundamental' object has no attribute 'Volume_Tradable'     (Open Stacktrace)

So, can I fix this by inheriting the class CoarseFundamental for SymbolData? 

Thanks a lot! 

Update Backtest







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