Back

System.NullReferenceException: Object reference not set to an instance of an object

 

Hi,

I have been using keras module. At certain point my old algos started giving me this error:

 

System.NullReferenceException: Object reference not set to an instance of an object
at Python.Runtime.Dispatcher.Dispatch (System.Collections.ArrayList args) [0x00018] in <0f995c28c5b446ad8835419f76b319a3>:0 
at __System_EventHandler`1[[QuantConnect_Data_Market_TradeBar, QuantConnect_Common, Version=2_4_0_0, Culture=neutral, PublicKeyToken=null]]Dispatcher.Invoke (System.Object , QuantConnect.Data.Market.TradeBar ) [0x00018] in <404737580f4c43f09e3571fd3219f088>:0 
at QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase`2[T, TConsolidated].OnDataConsolidated (TConsolidated e) [0x0001d] in :0 
at QuantConnect.Data.Consolidators.PeriodCountConsolidatorBase`2[T, TConsolidated].Update (T data) [0x00265] in :0 
at QuantConnect.Data.Consolidators.DataConsolidator`1[TInput].Update (QuantConnect.Data.IBaseData data) [0x00046] in :0 
at QuantConnect.Lean.Engine.AlgorithmManager.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Interfaces.IAlgorithm algorithm, QuantConnect.Lean.Engine.DataFeeds.IDataFeed feed, QuantConnect.Lean.Engine.TransactionHandlers.ITransactionHandler transactions, QuantConnect.Lean.Engine.Results.IResultHandler results, QuantConnect.Lean.Engine.RealTime.IRealTimeHandler realtime, QuantConnect.Lean.Engine.Server.ILeanManager leanManager, QuantConnect.Lean.Engine.Alpha.IAlphaHandler alphas, System.Threading.CancellationToken token) [0x00f97] in Lean.Engine.Alpha.IAlphaHandler alphas, System.Threading.CancellationToken token) [0x00f97] in <2006430fa8154de385aea0ee80b63ec4>:0 

 

Does anybody know, what is going on here? If I don't use keras in the code, it works fine.

Update Backtest







The error System.NullReferenceException occurs when you are trying to use something that is NULL. This means the object was either set to NULL, or nothing was ever set. There are a few reasons why this could occur: it could be TradeBar construction, a history request, or even security symbols. For example, the simple algorithm below creates this error because a security object instead of a symbol object was passed. If an algorithm were attached, determining the specific problem would be easier.

class BasicTemplateAlgorithm(QCAlgorithm):

def Initialize(self):

self.SetStartDate(2013,10, 7)
self.SetEndDate(2013,10,11)
self.SetCash(100000)
self.security = self.AddEquity("SPY", Resolution.Daily)

def OnData(self, data):

if not self.Portfolio.Invested:
self.SetHoldings("SPY", 1)
self.Log(str(self.Securities[self.security].Price))
0

Update Backtest





0

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.


Loading...

This discussion is closed