Could anyone help me to figure out why data.current(index,'open') returns nan values from time to time? I thought the function would return the last open price (I schedule the main trading function 45 minutes after market open).
The following is the code and a slice of output.
schedule_function(allocate,date_rules.every_day(),time_rules.market_open(hours=0,minutes=45))
schedule_function(record_vars,date_rules.every_day(),time_rules.market_open(hours=0,minutes=45))
log.info(('context.bull_trade_amt=%s')%(context.bull_trade_amt))
log.info(('context.bull_open_price={price}').format(price=data.current(context.bull,'open')))
log.info('context.bull_last_minute_price={price}'.format(price=data.history(context.bull,'price',1,'1m')[0]))
log.info(('context.bear_trade_amt=%s')%(context.bear_trade_amt))
log.info(('context.bear_open_price={price}').format(price=data.current(context.bear,'open')))
log.info('context.bear_last_minute_price={price}'.format(price=data.history(context.bear,'price',1,'1m')[0]))
2010-12-09 09:15 allocate:45 INFO context.bull_trade_amt=-128.766417718
2010-12-09 09:15 allocate:46 INFO context.bull_open_price=nan
2010-12-09 09:15 allocate:48 INFO context.bull_last_minute_price=38.83
2010-12-09 09:15 allocate:49 INFO context.bear_trade_amt=-121.802679659
2010-12-09 09:15 allocate:50 INFO context.bear_open_price=nan
2010-12-09 09:15 allocate:52 INFO context.bear_last_minute_price=41.05
Thanks.