Hello !

Does someone knows why this algorithm is stuck and can help to fix it.

Thank you 

from datetime import timedelta, datetime from Selection.FundamentalUniverseSelectionModel import FundamentalUniverseSelectionModel from QuantConnect.Data.UniverseSelection import * class HorizontalQuantumCompensator(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 8, 10) # Set Start Date self.SetCash(100000) self.AddUniverseSelection self.UniverseSettings.Resolution = Resolution.Daily self.UniverseSettings.DataNormalizationMode = DataNormalizationMode.Raw self.SetAlpha(MOMAlphaModel()) self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel()) self.SetExecution(ImmediateExecutionModel()) self.AddUniverseSelection(LiquidValueUniverseSelectionModel()) class LiquidValueUniverseSelectionModel(FundamentalUniverseSelectionModel): def __init__(self): super().__init__(True, None, None) def SelectCoarse(self, algorithm, coarse): sortedByDollarVolume = sorted([x for x in coarse if x.HasFundamentalData],key=lambda x: x.DollarVolume, reverse=True) return [x.Symbol for x in sortedByDollarVolume[:200]] class MOMAlphaModel(AlphaModel): def __init__(self): self.SMAS = [] self.SMAL = [] self.RSI = [] def OnSecuritiesChanged(self, algorithm, changes): for security in changes.AddedSecurities: symbol = security.Symbol self.SMAS.append({"symbol":symbol, "indicator":algorithm.SMA(symbol, 20, Resolution.Daily)}) self.SMAL.append({"symbol":symbol, "indicator":algorithm.SMA(symbol, 50, Resolution.Daily)}) self.RSI.append({"symbol":symbol, "indicator":algorithm.RSI(symbol, 14, Resolution.Daily)}) def Update(self, algorithm, data): for s in symbol: SMA20 = self.SMAS.Current.Value SMA50 = self.SMAS.Current.Value RSI = self.RSI.Current.Value if SMA20>SMA50 and RSI < 30 : return Insight.Group( [Insights.Price(self.SMA20.Symbol,timedelta(1),InsightDirection.Up)]) if SMA20<SMA50 and RSI > 70 : return Insight.Group( [Insights.Price(self.SMA20.Symbol,timedelta(1),InsightDirection.Down)])

 

Author