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

What is a more efficient (i.e. uses less memory) way to accomplish the following? I am trying to find the current day's high for a list of securities within the handle_data function. This is what I have currently:

context.securities = [sid(123), sid(456), sid(789), sid(876)]  
context.curr_min = 0  #set within before_trading_start(); resets to zero each morning

def handle_data(context, data):  
    c = context; d = data  
    c.curr_min += 1  
    day_hist = d.history(c.securities,"price",c.curr_min,"1m")  
    day_high = day_hist.max()
1 response

Think I may have answered my own question looking at the help docs.

In place of the last 3 lines:

day_hist = d.history(c.securities, "high", 1,"1d")  
day_high = day_hist[-1]  

Not sure how much more efficient this is but it seems like a better answer anyway.