For minutely bars, how should one interpret the difference between the current open_price and the prior close_price (assuming continuous minute-to-minute trading)?
As an example, I used this code:
def initialize(context):
context.spy = symbol('SPY')
context.prior_close = None
def handle_data(context, data):
open_price = history(1,'1m','open_price')
close_price = history(1,'1m','close_price')
if context.prior_close != None:
print float(open_price.values - context.prior_close)
context.prior_close = close_price.values
A sample of the output is:
2014-11-10 PRINT 0.0
2014-11-10 PRINT 0.00999999999999
2014-11-10 PRINT -0.00999999999999
2014-11-10 PRINT 0.01
2014-11-10 PRINT -0.01
2014-11-10 PRINT 0.01
2014-11-10 PRINT 0.00699999999998
So, there is ~ +/- 0.01 peak-to-peak variation.
Is the variation real, corresponding to actual trade data? Is the data acquisition system capturing the absolute last trade just before or at the close of the minute, and then capturing the first trade immediately after the open of the minute? Or am I looking at noise?
My thinking here is that if there is no common market clock to use for sampling the market, the variation may just be noise, since trades for SPY must be effectively continuous versus time.
How frequently is the market sampled to compute the minute bars provided by Quantopian? Or do you capture 100% of the trades within a minute to compute the OHLCV bar? And what clock is used to assign sub-minute timestamps to those trades?
In general, it would be interesting to hear from the Quantopian data vendor(s) to get insight into how they manage to capture the data and reduce it to bars (particularly on-the-fly for real-time trading).
Grant