def compute(self, today, assets, out, close, fast_period, slow_period, signal_period): slow_EWMA = self._ewma(rolling_window(close, slow_period), slow_period) fast_EWMA = self._ewma( rolling_window(close, fast_period)[-signal_period:], fast_period) macd = fast_EWMA - slow_EWMA out[:] = self._ewma(macd.T, signal_period)
def compute(self, today, assets, out, close, fast_period, slow_period, signal_period): ### today slow_EWMA_today = self._ewma( rolling_window(close[1:], slow_period), slow_period ) fast_EWMA_today = self._ewma( rolling_window(close[1:], fast_period)[-signal_period:], fast_period ) macd_today = fast_EWMA_today - slow_EWMA_today out.macd_today[:] = macd_today[-1] out.trigger_today[:] = self._ewma(macd_today.T, signal_period) ### yesterday slow_EWMA_yesterday = self._ewma( rolling_window(close[:-1], slow_period), slow_period ) fast_EWMA_yesterday = self._ewma( rolling_window(close[:-1], fast_period)[-signal_period:], fast_period ) macd_yesterday = fast_EWMA_yesterday - slow_EWMA_yesterday out.macd_yesterday[:] = macd_yesterday[-1] out.trigger_yesterday[:] = self._ewma(macd_yesterday.T, signal_period)
def compute(self, today, assets, out, close, fast_period, slow_period, signal_period): slow_EWMA = self._ewma( rolling_window(close, slow_period), slow_period ) fast_EWMA = self._ewma( rolling_window(close, fast_period)[-signal_period:], fast_period ) macd = fast_EWMA - slow_EWMA out[:] = self._ewma(macd.T, signal_period)