I am using the example to get averages. In this setup, get_averages() should return an array right? But when I look at log.info the log shows "2008-01-04handle_data:24INFO". If I try to access averages as an array, for example averages[1], I get "Runtime exception: TypeError: 'NoneType' object has no attribute '__getitem__'". How do I access the averages array?
def initialize(context):
set_universe(universe.DollarVolumeUniverse(99.9, 100.0))
@batch_transform(window_length=10)
def get_averages(datapanel):
# get the dataframe of prices
prices = datapanel['price']
# return a dataframe with one row showing the averages for each stock.
return prices.mean()
def handle_data(context, data):
averages = get_averages(data)
# add a newline to the beginning of the log line so that the column header of the
# is properly indented.
log.info('\n%s' % averages)