Hi everyone,
I'm quite new to Quantopian, and python aswell for that matter and i get an error for which i do not understand the cause. The error is as follows:
Exception: inputs are all NaN There was a runtime error on line 17.
The part of the code that generates the error is the following:
line 17 is the line: sma = prices.apply(talib.SMA, timeperiod=20).iloc[-1]
import talib
import math
import random
def initialize(context):
set_universe(universe.DollarVolumeUniverse(floor_percentile=97.5, ceiling_percentile=99.5))
#context.stock = symbols('GOOG')
set_commission(commission.PerShare(cost=0.004, min_trade_cost=1))
context.sell_price = {'stock' : 'value'}
context.want_price = {'stock' : 'value'}
context.times = {'stock' : 'times'}
context.last_price = {'stock' : 'times'}
context.bought = {'stock' : 'bought'}
def handle_data(context, data):
prices = history(25, '1m', 'price')
sma = prices.apply(talib.SMA, timeperiod=20).iloc[-1]
smapref = prices.apply(talib.SMA, timeperiod=20).iloc[-2]
for stock in data:
cash = context.portfolio.cash
test = context.times.get(stock.symbol)
The code runs for a long time in minute data but it seems to be unable to run over the months januarie in the years 2013, 2014 and 2015. Is this some bug in the historical data not giving values that carrie over the year, or is there something else wrong which i do not see?
Hope anyone can help me.
Kind regards,
Dennis