Hi Leigham,
I cloned your algorithm and changed the following parameters:
self.SetStartDate(2006,01,01)
self.SetEndDate(2018,01,01)
self.SetCash(10000)
I get below error when I backtest the algorithm:
Runtime Error: Python.Runtime.PythonException: ValueError : zero-size array to reduction operation maximum which has no identity
at Python.Runtime.PyObject.Invoke (Python.Runtime.PyTuple args, Python.Runtime.PyDict kw) [0x00033] in <59c711440fed482b8e57b026917e4706>:0
at Python.Runtime.PyObject.InvokeMethod (System.String name, Python.Runtime.PyTuple args, Python.Runtime.PyDict kw) [0x00007] in <59c711440fed482b8e57b026917e4706>:0
at Python.Runtime.PyObject.TryInvokeMember (System.Dynamic.InvokeMemberBinder binder, System.Object[] args, System.Object& result) [0x0003e] in <59c711440fed482b8e57b026917e4706>: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.OnSecuritiesChanged (QuantConnect.Data.UniverseSelection.SecurityChanges changes) [0x0004f] in <7ab68f0d8e294fb99b0d6c17956078e8>: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) [0x00a96] in <34f68d5d9ef54d4e95213133d16a078b>:0
And this is the stacktrace:
[' File "../cache/main.py", line 106, in OnSecuritiesChanged
', ' File "../cache/main.py", line 137, in gapper
', ' File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 2272, in amax
out=out, **kwargs)
', ' File "/usr/local/lib/python2.7/dist-packages/numpy/core/_methods.py", line 26, in _amax
return umr_maximum(a, axis, None, out, keepdims)
']
The runtime error occurs on May 4, 2006 so you don't have to wait very long when you start the backtest.
Any ideas?
Thanks,
Jon