This code appears to hang when run on minute data. What am I doing wrong?
from pytz import timezone
# globals for get_data batch transform decorator
R_P = 0 # refresh period in days
W_L = 15 # window length in days
def initialize(context):
set_universe(universe.DollarVolumeUniverse(floor_percentile=99.5, ceiling_percentile=100.0))
def handle_data(context, data):
# get data
d = get_data(data)
if d == None:
return
if not intradingwindow_check(context):
return
context.stocks = [sid for sid in data]
print len(context.stocks)
@batch_transform(refresh_period=R_P, window_length=W_L, clean_nans=False) # set globals R_P & W_L above
def get_data(datapanel):
p = datapanel['price']
v = datapanel['volume']
return [p,v]
def intradingwindow_check(context):
# Converts all time-zones into US EST to avoid confusion
loc_dt = get_datetime().astimezone(timezone('US/Eastern'))
# if loc_dt.hour > 10 and loc_dt.hour < 15:
if loc_dt.hour == 10 and loc_dt.minute == 0:
return True
else:
return False