Currently running into this issue:
ValueError: cannot convert float NaN to integer
USER ALGORITHM:86, in handle_data
How can I handle this? Thanks in advance.
Currently running into this issue:
ValueError: cannot convert float NaN to integer
USER ALGORITHM:86, in handle_data
How can I handle this? Thanks in advance.
At this point in time the close for SPY is nan - there is no close price. Now it depends how you would like your algorithm to handle this.
One way would be to use 'price' instead of 'close' because 'price' is always forward filled
num_shares = math.floor(context.max_notional / data.current(context.stock, 'price'))
This means your algorithm acts on the last known price.
Alternatively you could tell it to do nothing if there's no recent close, like so
if np.isnan(data.current(context.stock, 'close')):
return