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.

Clone Algorithm
0
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 57544d9c3765d30f975533f9
There was a runtime error.