I've some {open|high|low|close}
market data. I want to compute a Simple Moving Average from the close
value of each row.
I've had a look around and couldn't find a simple way to do this. I've computed it via the below method. I want to know if there is a better way:
data = get_data_period_symbol('1h', 'EURUSD')
empty_list = np.zeros(len(data))
data['SMA10'] = empty_list
ma = 10
for i in range(ma-1, len(data)):
vals = data['<CLOSE>'][i-(ma-1):i+1].tolist()
mean = np.average(vals)
index = data.index[i]
data.set_value(index, 'SMA10', mean)