def test_macd(): candles = np.array(mama_candles) single = ta.macd(candles, fast_period=12, slow_period=26, signal_period=9) seq = ta.macd(candles, fast_period=12, slow_period=26, signal_period=9, sequential=True) assert type(single).__name__ == 'MACD' assert round(single.macd, 2) == -15.32 assert round(single.signal, 2) == -4.10 assert round(single.hist, 2) == -11.22 assert seq.macd[-1] == single.macd assert len(seq.macd) == len(candles) assert len(seq.signal) == len(candles) assert len(seq.hist) == len(candles)
def current_macd(self): return ta.macd(self.candles)
def previous_macd(self): return ta.macd(self.candles[:-1])