Hello, this seems like it will be fairly straightforward so sorry in advance if this is trivial. I want to get the X-day Simple Moving Average of yesterday, the day before, etc. How do I do this?
Thanks in advance!
Hello, this seems like it will be fairly straightforward so sorry in advance if this is trivial. I want to get the X-day Simple Moving Average of yesterday, the day before, etc. How do I do this?
Thanks in advance!
When I'm faced with a problem like this, I get a big chunk of history, and take segments of it. Then manipulate that segment however I need.
hist = history(11, '1d', 'price')
yesterdays_ten_day_avgs = hist[:-1].mean()
todays_ten_day_avgs = hist[1:].mean()
The brackets get segments of data, or slices, then we take the mean of that data. Hope this helps.
Calvin
Another option is the rolling_mean function in Pandas.