From 81e554a0040bb582a6fed4756b645cf7e2e65355 Mon Sep 17 00:00:00 2001 From: Kevin Johnson Date: Thu, 21 May 2020 14:47:14 -0700 Subject: [PATCH] BUG apo correctly calculated and talib correlated --- README.md | 1 + pandas_ta/momentum/apo.py | 13 ++++++------- setup.py | 2 +- tests/test_indicator_momentum.py | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d06f4ed..5788eeb 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ All the indicators return a named Series or a DataFrame in uppercase underscore - __Aberration__ (aberration) - __BRAR__ (brar) * Corrected Indicators: + - __Absolute Price Oscillator__ (apo) - __Aroon & Aroon Oscillator__ (aroon) * Fixed indicator and included oscillator in returned dataframe - __Bollinger Bands__ (bbands) diff --git a/pandas_ta/momentum/apo.py b/pandas_ta/momentum/apo.py index ed05ec3..52a7b56 100644 --- a/pandas_ta/momentum/apo.py +++ b/pandas_ta/momentum/apo.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from ..overlap.ema import ema +from ..overlap.sma import sma from ..utils import get_offset, verify_series def apo(close, fast=None, slow=None, offset=None, **kwargs): @@ -14,9 +14,8 @@ def apo(close, fast=None, slow=None, offset=None, **kwargs): offset = get_offset(offset) # Calculate Result - fastma = ema(close, length=fast, **kwargs) - slowma = ema(close, length=slow, **kwargs) - # EMAs are equivalent with talib, only their difference is minutely off + fastma = sma(close, length=fast) + slowma = sma(close, length=slow) apo = fastma - slowma # Offset @@ -45,13 +44,13 @@ momentum. It is simply the difference of two Exponential Moving Averages (EMA) of two different periods. Note: APO and MACD lines are equivalent. Sources: - https://www.investopedia.com/terms/p/ppo.asp + https://www.tradingtechnologies.com/xtrader-help/x-study/technical-indicator-definitions/absolute-price-oscillator-apo/ Calculation: Default Inputs: fast=12, slow=26 - EMA = Exponential Moving Average - APO = EMA(close, fast) - EMA(close, slow) + SMA = Simple Moving Average + APO = SMA(close, fast) - SMA(close, slow) Args: close (pd.Series): Series of 'close's diff --git a/setup.py b/setup.py index e04213b..9d1b041 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ long_description = "An easy to use Python 3 Pandas Extension with 100+ Technical setup( name ="pandas_ta", packages =['pandas_ta', 'pandas_ta.momentum', 'pandas_ta.overlap', 'pandas_ta.performance', 'pandas_ta.statistics', 'pandas_ta.trend', 'pandas_ta.volatility', 'pandas_ta.volume'], - version ="0.1.53b", + version ="0.1.54b", description =long_description, long_description =long_description, author ="Kevin Johnson", diff --git a/tests/test_indicator_momentum.py b/tests/test_indicator_momentum.py index 5e40564..d50383b 100644 --- a/tests/test_indicator_momentum.py +++ b/tests/test_indicator_momentum.py @@ -70,7 +70,7 @@ class TestMomentum(TestCase): self.assertEqual(result.name, 'APO_12_26') try: - expected = tal.APO(self.close, 12, 26) + expected = tal.APO(self.close) pdt.assert_series_equal(result, expected, check_names=False) except AssertionError as ae: try: