Hey all,
I'm having some trouble testing a model. When I try to run a backtest, I get the error “Object reference not set to an instance of an object". After some testing, I've managed to find the line in question, but failed to find a solution. My code is as follows:
class ChavoAlphaModel(AlphaModel):
def __init__(self, algorithm):
self.algorithm = algorithm
self.mom = []
self.Bs = {}
self.allowedToInsight = False
self.symbols = set()
self.d1 = 2
self.d2 = 2
return self
def OnSecuritiesChanged(self, algorithm, changes):
return
def Update(self, algorithm, data):
return
class AdaptableRedOrangeChimpanzee(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 10, 28)
self.SetEndDate(2020, 11, 28)
self.SetCash(100000)
symbols = [Symbol.Create("SPY", SecurityType.Equity, Market.USA),
Symbol.Create("BND", SecurityType.Equity, Market.USA)]
self.UniverseSettings.Resolution = Resolution.Minute
self.UniverseSettings.Leverage = 1
self.SetUniverseSelection(ManualUniverseSelectionModel(symbols))
self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
self.SetRiskManagement(MaximumDrawdownPercentPerSecurity(0.015))
self.alphaville = ChavoAlphaModel(self)
self.AddAlpha(self.alphaville)
Based on trial and error, it seems the last line causes the issue (self.AddAlpha(self.alphaville)). Does anyone know why this occurs? More specifically, what can I do to avoid this problem?
Hisam sabouni
I am having the same issue. There also seems to be issues with the universe selection models. Even the course examples (lecture 8 liquid value stocks) are broken. There seems to be an issue with an update that was pushed.Â
Can anyone shed any insights (pun intended) on what needs to be done to resolve these issues?
Arthur Asenheimer
The Portfolio Construction Model expects a list. Currently it receives a None object from your Alpha Model. If you replace AlphaModel.Update with the code snippet below it will work fine (see attached backtest).
Asher S
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!