Lean
Lean copied to clipboard
Adds NaN check in StandardDeviationExecutionModel [py]
Expected Behavior
Lean modules should not raise unhandled exceptions.
Actual Behavior
The python version of StandardDeviationExecutionModel raised the following exception:
Runtime Error: Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the 'float'>) method. Please checkout the API documentation.
at __init__
self.SMA.Update(time in StandardDeviationExecutionModel.py: line 124
(Open Stacktrace)
which means that in this code block:
# warmup our indicators by pushing history through the indicators
history = algorithm.History(symbol, period, resolution)
if 'close' in history:
history = history.close.unstack(0).squeeze()
for time, value in history.iteritems():
self.SMA.Update(time, value)
self.STD.Update(time, value)
value was not-a-number is a row.
Potential Solution
Drop the NaN:
history = history.close.unstack(0).squeeze().dropna()
Reproducing the Problem
N/A
Checklist
- [x] I have completely filled out this template
- [x] I have confirmed that this issue exists on the current
masterbranch - [x] I have confirmed that this is not a duplicate issue by searching issues
- [x] I have provided detailed steps to reproduce the issue