I kept getting this error: Runtime Error: Object reference not set to an instance of an object.
So I deleted all the code that didn't give me that error until I only had this left:
class FatSkyBlueDog(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2021, 4, 19)
self.SetEndDate(2021, 6, 19)
self.SetCash(100000)
self.AddEquity("SPY")
self.CustomUniverse = Universe(self)
self.UniverseSettings.Resolution = Resolution.Daily
self.AddUniverse(self.CustomUniverse.SelectCoarse)
self.AddAlpha(Alpha())
def OnData(self, data):
pass
class Universe():
def __init__(self, algorithm):
self.algorithm = algorithm
def SelectCoarse(self, coarse):
symbol = self.algorithm.Symbol("SPY")
return [symbol]
class Alpha():
def __init__(self):
pass
def Update(self, algorithm, data):
pass
def OnSecuritiesChanged(self, algorithm, changes):
pass
Without the alpha model or the universe model there are no errors. It only breaks when both are there. I don't know what I did. If anyone can tell me how to fix this it would be greatly appreciated.
Varad Kabade
Hi Simon Koeman,
In the above code snippet the creation of Universe Selection model is not correct. Refer to the following doc regarding implementing the Universe Selection model. If we are using static universe, we recommend using the ManualUniverseSelectionModel, refer to the following code snippet.
Â
Please attach the backtest highlighting the error or the complete code snippet for further assistance if the problem persists.
Best,
Varad Kabade
Simon Koeman
I followed the documentation as close as I could with the universe model I was actually using. I'm not sure what I'm doing wrong because my code was working at one point.
Adam W
The Alpha Model needs to return an empty list if there are no insights, so just change it to:
Simon Koeman
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!