Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
History close price with 1d frequency in minute mode

Hi, I have a really simple question.

So when I try to obtain the open price and close price of a stock in a specific day while I'm running in minute backtest, for some reason the close price I get changes every minute.

I read the open price of the day in each minute and it's a constant for each trading day. But the close price of the day seems to be the close price of the minute. Can someone take a look at the code?

Thanks!
Robin

3 responses

Hi Robin,

Someone with more experienced than me can confirm but I think this is stop look-ahead bias (there is nothing wrong with your code). If you knew in advance the closing-price of a stock, you'd be well ahead of the big hedge funds :) So querying for the close price gets you the most up-to-date close price it can give you.

James,

That makes sense. Thank you so much!

Robin

Robin,

Have a look at https://www.quantopian.com/help#ide-history. Specifically, see if this explains the behavior you are seeing:

Returned Data

The returned data for daily history, for each day, is:

open_price: the open of the first minute bar of the given day.  
high: the maximum of the minute highs for the given day.  
low: the minimum of the minute bar lows for the given day.  
close_price: the close of the last minute bar in the specified period. This value is not forward-filled. If there is no price in the bar, the returned price is NaN.  
price: the close of the last minute bar as of the specified period. This value is forward-filled. If there is no price in the bar, the returned price is the previous price, until there is new trade data available.  
volume: the sum of all minute volumes. For the current day, the sum of volume thus far.

Make sense?

Grant