y_fde = apply_ema_filter(prices, Neff) h_ema = ema(Neff, Nwindow) candidate = np.convolve(prices - prices[0], h_ema) + prices[0] y_convolution = candidate[:len(prices)] axarr[1, 0].set_title("Ema") axarr[1, 0].plot(y_fde) axarr[1, 0].plot(y_convolution, 'o', markerfacecolor='none') # d) Ema poly1 Neff = 32 lag = 2 y_fde = apply_ema_poly1_filter(prices, Neff) h_ema_poly1 = ema_poly1(Neff, Nwindow) candidate = np.convolve(prices - prices[0], h_ema_poly1) + prices[0] y_convolution = candidate[:len(prices)] axarr[1, 1].set_title("Ema poly1") axarr[1, 1].plot(y_fde) axarr[1, 1].plot(y_convolution, 'o', markerfacecolor='none') # e) Integrated Macd-Poly Neff = 32 lag = 3 y_fde = apply_integrated_macd_poly_filter(prices, Neff) h_int_macd_poly = int_macd_poly(Neff, Nwindow)
impulse_response_fde = candidate[lag:] impulse_response_direct = ema(Neff, Nwindow) axarr[1, 0].set_title("Ema") axarr[1, 0].plot(impulse_response_fde) axarr[1, 0].plot(impulse_response_direct, 'o', markerfacecolor='none') # d) Ema poly1 Neff = 32 lag = 2 impulse = np.zeros(Nwindow) impulse[lag] = 1 candidate = apply_ema_poly1_filter(impulse, Neff) impulse_response_fde = candidate[lag:] impulse_response_direct = ema_poly1(Neff, Nwindow) axarr[1, 1].set_title("Ema poly1") axarr[1, 1].plot(impulse_response_fde) axarr[1, 1].plot(impulse_response_direct, 'o', markerfacecolor='none') # e) Integrated Macd-Poly Neff = 32 Neff_modified = 32 lag = 3 impulse = np.zeros(Nwindow) impulse[lag] = 1