I am setting up an algorithm that mimics bar data to eventually deploy various technical trading strategies. In order to do this I am using the history function. For instance, I mimic daily bar data as shown in the code below and then store the bar data from the respective time period into their own variables. I am wondering if anyone can help me think of the best way to extract that data into something hashable that I could then use to drive trade logic? My Python capabilities seem to turn off on Friday evenings so any suggestions would be appreciated.
def handle_data(context, data):
# Use history function to get bar level data
high_history = history(bar_count=2, frequency='1d', field='high')
low_history = history(bar_count=2, frequency='1d', field='low')
open_history = history(bar_count=2, frequency='1d', field='open_price')
close_history = history(bar_count=2, frequency='1d', field='close_price')
# Store prior and current data into variables
prior_high = high_history.iloc[-2]
current_high = high_history.iloc[-1]
prior_low = float(low_history.iloc[-2])
current_low = float(low_history.iloc[-1])
prior_open = float(open_history.iloc[-2])
current_open = float(open_history.iloc[-1])
prior_close = float(close_history.iloc[-2])
current_close = float(close_history.iloc[-1])