I'm a serious newbie at this but..
I think this is the 5-day SMA in my code (which someone helped me build because I'm still in coding school):
# compute the diff vix_to_realized_vol_diff = vix_data-vol_data # average for last 5 days vix_to_realized_vol_diff_5 = sum(vix_to_realized_vol_diff[-5:])/5
I need that changed to a 5-day exponential moving average.
I have found this example function for an EMA online that uses numpy:
def ExpMovingAverage(values, window): weights = np.exp(np.linspace(-1.,0.,window)) weights /= weights.sum() a = np.convolve(values, weights) [:len(values)] a[:window]=a[window] return a
I am not certain on precisely how to place the values of my old SMA into the new example EMA. Could anyone out there give me a hand with that?
HUGELY APPRECIATED if anyone can... or IM me about it. Thanks!