Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Creating 15 minute bars with .resample - what am I doing wrong?

Hey everybody,

I'm fairly new to Python, Quantopian, and algorithmic trading in general, so I'll try my best not to aggravate with countless silly questions.

The issue I'm having relates to trying to chunk close data for a single security into 15 minute (or whatever length) bins via the .resample method. Any time I call the .resample method on data.history, handle_data keeps returning the one minute closes rather than the 15 minute closes. In fact, I can change the time interval length to something other than 15 minutes, or remove the .resample method entirely and it has no effect on the data that is printed to the console.

Does anyone know what's going on with my code? I've searched the forums and read the pandas .resample documentation, but I'm stumped.

Thanks!

2 responses

This should work

prices_15m = data.history(context.security, 'close', 300, '1m').resample('15T').last()  

Works as expected now. Thanks Vladimir!