Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Execution Timeout when calling data.history() in rebalance()

Hello there

In my rebalance function I have a list of stocks which I'd like to add a new filter to existing logic.

The new filter just requires that for longs, the current price is greater than last nights close.

Rebalance runs 15mins before the market close.

The following is my proposed code wiuth causes the "Execution Timeout ".

   stock = next(context.MyLongsCandidate)  
   close_prices = data.history(stock,  'close', 2, '1d')  
   YestPrice = close_prices.iloc[-2]  
   CurrPrice = close_prices.iloc[-1]  

Followed by the new filter:

if (CurrPrice <YestPrice):  
    pass  
else:  
#place order to buy stock  

The algo was functioning before I added this new filter.

Would it be more efficient to pass the previous closing price from pipeline, and to use data.current to get the current price? I'll try that now.

Any guidance much appreciated! :-)

1 response

Passing the previous days close from Pipeline, and using data.current() for the most recent price worked :-)