Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Closing Price on 15min Bars

Hi,

I am trying to get the opening and closing price for 15min bars intraday, does anyone have any suggestions on how I can do this?

I found 2 solutions so far, which I am definitely not proud of and find them completely inelegant.

Solution 1

def initialize(context):  
    schedule_function(open_close, date_rules.every_day(), time_rules.market_close(minutes=15))  
    schedule_function(open_close, date_rules.every_day(), time_rules.market_close(minutes=30))  
    schedule_function(open_close, date_rules.every_day(), time_rules.market_close(minutes=45))  
    schedule_function(open_close, date_rules.every_day(), time_rules.market_close(minutes=60))  

Solution 2

def handle_data(context,data):  
 minute = get_datetime('US/Central').time().minute

 if minute == 0 or minute == 15 or minute == 30 or minute == 45:  
  open_close()  

the open_close function gets the open and closing price for the 15 min interval

if you have an easier way to do this I would really appreciate it if you could point me in the right direction.

I would also like to get some properties like SMA or RSI in the 15min bars time periods instead of 1day periods, is this possible?

Thank you!