While creating PortoflioTargets using PortfolioTarget.Percent, I get this error.  However, I do not gett it in backtest--only in paper or live trading:

The order quantity for SSO cannot be calculated: the price of the security is zero.

 

I belive this then leads to uncaught exceptions further down the line:

Runtime Error: Object reference not set to an instance of an object Stack Trace: System.NullReferenceException: Object reference not set to an instance of an object at QuantConnect.Algorithm.QCAlgorithm.ProcessInsights (QuantConnect.Algorithm.Framework.Alphas.Insight[] insights) [0x0003d] in <2de485accd7544f5980cafdf65806aed>:0 at QuantConnect.Algorithm.QCAlgorithm.OnFrameworkData (QuantConnect.Data.Slice slice) [0x001a4] in <2de485accd7544f5980cafdf65806aed>:0 at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnFrameworkData (QuantConnect.Data.Slice slice) [0x00000] in <65d87ad6b5074b758360f25b819835f2>:0 at QuantConnect.Lean.Engine.AlgorithmManager.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Interfaces.IAlgorithm algorithm, QuantConnect.Lean.Engine.DataFeeds.ISynchronizer synchronizer, 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) [0x0160a] in <f378596eae5c4b1ba30b5fd3bee83316>:0  I am creating my porfolio targets in a custom portfolio construction model in the CreateTargets method. Is there something I should be doing differently? This code works exactly as I want it to in backtest.

Author