from Selection.QC500UniverseSelectionModel import QC500UniverseSelectionModel
class SmoothGreenDolphin(QCAlgorithm):
def Initialize(self):
self.UniverseSettings.Resolution = Resolution.Second
self.SetStartDate(2022, 3, 28)
self.SetEndDate(2022, 4, 28)
self.SetWarmUp(timedelta(days = 1))
self.SetUniverseSelection(QC500UniverseSelectionModel())
self.SetCash(100000)
self.SetTimeZone("America/New_York")
self.securityData = {}
for x in self.ActiveSecurities:
symbol = self.AddEquity(x, Resolution.Second).Symbol
self.securitylData[symbol] = securityData(self, symbol)
eachDay = self.DateRules.EveryDay(symbol)
self.Schedule.On(everyday, self.TimeRules.BeforeMarketClose(symbol, 10), self.Liquidate)
symbol is supposedly referenced before assignment in the schedule event? I am trying to use the stocks from QC 500 in a separate class with indicators. I am not sure why that should be? Am I not implementing the QC500 universe? My understanding is ActiveSecurities should be populated with those stocks?
Adam W
You don't need to manually subscribe to asset data if you are using Universe Selection, and the error is because `ActiveSecurities` is empty when the algorithm is being initialized so that for loop isn't being called.
Take a look at this backtest's logs:
Jack Bueller
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!