I'm trying to calculate a weighted moving average with this code:
# get info stock = sid(42950) # calculate weighted moving averages past9 = data.history(stock, 'close', 9, '1d') past50 = data.history(stock, 'close', 50, '1d') wma9 = np.ma.average(past9, weights=np.arange(1,9)) wma50 = np.ma.average(past50, weights=np.arange(1,50))
But I keep getting this error:
ValueError: operands could not be broadcast together with shapes (9,)
(8,) There was a runtime error on line 23.
Does anyone know what would cause this?