def get_array_ma(ts, periods):
ma = np.empty(shape = len(ts))
ma.fill(np.NAN)
for i in xrange(len(ts)):
j = i - periods + 1
if j < 0:
j = 0
ma[i] = np.nanmean(ts[j:i+1], 0)
return ma
# 0 for add, 1 for multiply
评论列表
文章目录