Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
30-minutes bars trading strategy

Hello, i would like use 30-minutes bars in my strategy. For my strategy I need to know close and open prices of 30-minute bars (actual bars and historical bars). How can I use it? Or i can use only 1-minute bars?

1 response

Ivan,

You need re-sample 1m bar data to 30m bar like this:

    stk = symbol('SPY')  
    bars = 5  
    Closes_1m = data.history(stk, 'price', bars*30, '1m')  
    Closes_30m = Closes_1m.resample('30T', closed='left')

    Opens_1m = data.history(stk, 'open', bars*30, '1m')  
    Opens_30m = Opens_1m.resample('30T', closed='left')