Hi Everyone,

I am attempting to create a Universe Selection that coarses through momentum by checking if a current stock price is above the 50 and 200 Daily SMAs, and then taking up to the ten highest market cap of these stocks and using a random forest regression to portfolio balance them. Unfortunately I keep running into the error:

 

 Runtime Error: Update() missing 1 required positional argument: 'value'  at SelectCoarse    avg.Update(cf)   at Python.Runtime.PythonException.ThrowLastAsClrException()   at Python.Runtime.Dispatcher.TrueDispatch(Object[] args)   at Python.Runtime.Dispatcher.Dispatch(Object[] args)   at __System_Func`2\[\[System_Collections_Generic_IEnumerable`1\[\[QuantConnect_Data_UniverseSelection_CoarseFundamental\ in main.py: line 55,

 

and haven't been able to resolve this issue on my own. Does anyone know how I could edit the update code at the end of main.py to avoid this? It looks like this:

 

# region imports
from AlgorithmImports import *
from alpha import RandomForestAlphaModel
from portfolio import MeanVarianceOptimizationPortfolioConstructionModel
from Selection.FundamentalUniverseSelectionModel import FundamentalUniverseSelectionModel
# endregion

class RandomForestAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2012, 1, 1)
        self.SetCash(100000)
        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin)
        self.AddEquity("SPY", Resolution.Daily)
        self.SetBenchmark("SPY")

        self.UniverseSettings.DataNormalizationMode = DataNormalizationMode.Raw

        self.AddUniverse(self.SelectCoarse)

        self.AddAlpha(RandomForestAlphaModel(
            self,
            self.GetParameter("minutes_before_close", 5),
            self.GetParameter("n_estimators", 100),
            self.GetParameter("min_samples_split", 5),
            self.GetParameter("lookback_days", 360)
        ))

        self.SetPortfolioConstruction(MeanVarianceOptimizationPortfolioConstructionModel(self, lambda time: None, PortfolioBias.Long, period=self.GetParameter("pcm_periods", 5)))
        
        self.AddRiskManagement(NullRiskManagementModel())

        self.SetExecution(ImmediateExecutionModel())

        self.SetWarmUp(timedelta(200))

    def __init__(self,
                 universeCount = 10,
                 universeSettings = None):
        
        self.universeCount = universeCount
        # holds our coarse fundamental indicators by symbol
        self.averages = {}

    def SelectCoarse(self, coarse):
        
        filtered = []

        # We are going to use a dictionary to refer the object that will keep the moving averages
        for cf in coarse:
            if cf.Symbol not in self.averages:
                self.averages[cf.Symbol] = SymbolData(cf.Symbol)

            # Updates the SymbolData object with current EOD price
            avg = self.averages[cf.Symbol]
            avg.Update(cf)

        # Filter the values of the dict: wait for indicator to be ready
        filtered_values = filter(lambda x: (x.is_ready and x.Price.Current.Value > x.SlowSma.Current.Value), self.averages.values())
        filtered_values = filter(lambda x: (x.is_ready and x.Price.Current.Value > x.FastSma.Current.Value), self.averages.values())

        filtered = sorted(filtered, key=lambda avg: x.Market, reverse = True)

        self.filtered_coarse = [x.Symbol for x in filtered[:self.universeCount]]

        return self.filtered_coarse

class SymbolData(object):
    
    def __init__(self, symbol):
        self.Symbol = symbol
        self.Price = SimpleMovingAverage(1)
        self.SlowSma = SimpleMovingAverage(200)
        self.FastSma = SimpleMovingAverage(50)

    def Update(self, time, value):
        return self.Price.Update(time, value)
        return self.SlowSma.Update(time, value)
        return self.FastSma.Update(time, value)