The attached backtest runs successfully.

But if I change the start and end dates from:

self.SetStartDate(2010, 1, 1) self.SetEndDate(2010, 3, 31)

to:

self.SetStartDate(2010, 1, 1) self.SetEndDate(2010, 12, 31)

Then the backtest will throw the following runtime error:

Runtime Error: IndexError : list index out of range IndexError : list index out of range

This is the stack trace:

System.Exception: IndexError : list index out of range ---> Python.Runtime.PythonException: IndexError : list index out of range at Python.Runtime.PyObject.Invoke (Python.Runtime.PyTuple args, Python.Runtime.PyDict kw) [0x00033] in :0 at Python.Runtime.PyObject.InvokeMethod (System.String name, Python.Runtime.PyTuple args, Python.Runtime.PyDict kw) [0x00007] in :0 at Python.Runtime.PyObject.TryInvokeMember (System.Dynamic.InvokeMemberBinder binder, System.Object[] args, System.Object& result) [0x0003e] in :0 at (wrapper dynamic-method) System.Object.CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, object, QuantConnect.Data.UniverseSelection.SecurityChanges) at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.OnFrameworkSecuritiesChanged (QuantConnect.Data.UniverseSelection.SecurityChanges changes) [0x0004f] in <60f7e514d9f742459223002854eb0074>: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) [0x008a6] in Lean.Engine.Alpha.IAlphaHandler alphas, System.Threading.CancellationToken token) [0x008a6] in <07c77997a4904cb4925edfc7c062ccfe>:0 --- End of inner exception stack trace ---

 

I couldn't figure out what went wrong because I don't know which file and line in my code that is throwing this exception.

Please help.

Author