def test_ema(): close_prices = [ 204.23, 205.01, 196.9, 197.33, 198.7, 199.86, 202.23, 200.3, 212.3, 210.82603059, 220.84, 218.99, 212.71, 211.01, 213.19, 212.99724894, 212.67760477, 209.85, 187.2, 184.15, 176.99, 175.9, 178.99, 150.96, 133.85, 138.18, 126.32, 125.23, 114.79, 118.73, 110.74409879, 111.72, 124.04, 118.52, 113.64, 119.65, 117.11129288, 109.23, 110.77, 102.65, 91.99 ] candles = fake_range_candle_from_range_prices(close_prices) single = ta.ema(candles, 8) seq = ta.ema(candles, 8, sequential=True) assert round(single, 3) == 108.546 assert len(seq) == len(candles) assert seq[-1] == single assert np.isnan(ta.ema(candles, 400))
def ema_high(self): return ta.ema(self.candles, period=7, source_type="high")
def slow_ema(self): return ta.ema(self.candles, period=55, source_type="close")
def ema_low(self): return ta.ema(self.candles, period=5, source_type="low")
def fast_ema(self): return ta.ema(self.candles, period=34, source_type="close")