diff --git a/pandas_eval.py b/pandas_eval.py index 80ffae1..d68ff7c 100644 --- a/pandas_eval.py +++ b/pandas_eval.py @@ -238,13 +238,14 @@ class Symbol(object): _macd_curr = self.data_full['macd'][len(self.data_full)-1] self._macd_data = self.data_full['macd'][len(self.data_full) - show_range_days:] - x_r = list(range(0, len(self._macd_data))) + x_r = list(range(0, len(self._macd_data)+1)) y_r = self._macd_data.to_numpy() + y_r = np.append(y_r, y_r[len(y_r)-1]) poly = np.polyfit(x_r, y_r, N_poly) poly_d = np.polyder(poly) - yf = np.polyval(poly, x_r) - yf_d = np.polyval(poly_d, x_r) + yf = np.polyval(poly, x_r[:len(x_r)-1]) + yf_d = np.polyval(poly_d, x_r[:len(x_r)-1]) self._macd_fitted = pd.DataFrame(np.transpose([yf,yf_d]), index=self._macd_data.index, columns=['macd_fitted', 'macd_fitted_d']) _macd_f_curr = self._macd_fitted['macd_fitted'][len(self._macd_fitted)-1]