I imported a data series via CSV fetch, and I wish to generate a moving average out of it and then shift it backwards a couple of days.
For normal sids, I could have used something like this:
@batch_transform(refresh_period=1, window_length=9)
def get_avg(datapanel,sids,shift):
p = np.flipud(datapanel['price'].as_matrix(sids))
p_cumsum = np.cumsum(p[shift:,:],axis=0)
n = np.cumsum(np.ones(p_cumsum.shape),axis=0)
avg = np.divide(p_cumsum,n)
return avg
Could you please show me how to do the same with external data?