Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Resampling question

Could an experienced resampler lend a hand?

I am confused as to the operation of the resampling function in Quantopian.
The API notes reference the Pandas resampler which appears to be straightforward, but the result is not as I'd expect.

The following code is executed at start of trading on 6/29/2007 for eq = SPY

        price_hist = data.history(eq, 'price', 21*lookback, '1d')  
        price = price_hist[-1]  
        prices = price_hist.resample('M', how='last', closed='left', label='left')

I would expect price_hist[-1], price, and prices[-1] to be equal to to closing price of 6/28/2007.

Result
price = prices[-1] = 150.89
The 150.89 value does not equal the 150.40 close of 6/28 contained in price_hist

log.info(price)  

2007-06-29 resample_check:22 INFO 150.89

log.info(prices[-1])  

2007-06-29 resample_check:23 INFO 150.89

log.info(price_hist[-25:-1])  

2007-06-29 resample_check:24 INFO
2007-05-25 00:00:00+00:00 151.208
2007-05-29 00:00:00+00:00 151.427
2007-05-30 00:00:00+00:00 152.712
2007-05-31 00:00:00+00:00 152.692
2007-06-01 00:00:00+00:00 153.299
2007-06-04 00:00:00+00:00 153.578
2007-06-05 00:00:00+00:00 152.786
2007-06-06 00:00:00+00:00 151.447
2007-06-07 00:00:00+00:00 148.719
2007-06-08 00:00:00+00:00 150.402
2007-06-11 00:00:00+00:00 150.650
2007-06-12 00:00:00+00:00 149.027
2007-06-13 00:00:00+00:00 151.298
2007-06-14 00:00:00+00:00 152.054
2007-06-15 00:00:00+00:00 153.040
2007-06-18 00:00:00+00:00 152.900
2007-06-19 00:00:00+00:00 153.200
2007-06-20 00:00:00+00:00 151.000
2007-06-21 00:00:00+00:00 151.980
2007-06-22 00:00:00+00:00 150.240
2007-06-25 00:00:00+00:00 149.610
2007-06-26 00:00:00+00:00 149.060
2007-06-27 00:00:00+00:00 150.550
2007-06-28 00:00:00+00:00 150.400
Freq: C, Name: Equity(8554 [SPY]), dtype: float64
End of logs.