BUG #39 ATR fix

This commit is contained in:
Kevin Johnson
2020-05-03 09:13:55 -07:00
parent 1866016b7b
commit f87b3dc555
8 changed files with 11 additions and 10 deletions
+4 -1
View File
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
# from ..overlap.ema import ema
from ..overlap.rma import rma
from .true_range import true_range
from ..utils import get_drift, get_offset, verify_series
@@ -17,7 +19,8 @@ def atr(high, low, close, length=None, mamode=None, drift=None, offset=None, **k
# Calculate Result
tr = true_range(high=high, low=low, close=close, drift=drift)
if mamode == 'ema':
atr = tr.ewm(span=length, min_periods=min_periods).mean()
alpha = (1.0 / length) if length > 0 else 0.5
atr = tr.ewm(alpha=alpha, min_periods=min_periods).mean()
else:
atr = tr.rolling(length, min_periods=min_periods).mean()
+1 -1
View File
@@ -2,7 +2,7 @@ from .config import error_analysis, sample_data, CORRELATION, CORRELATION_THRESH
from .context import pandas_ta
from unittest import TestCase, skip
import pandas.util.testing as pdt
import pandas.testing as pdt
from pandas import DataFrame, Series
import talib as tal
+1 -1
View File
@@ -2,7 +2,7 @@ from .config import CORRELATION, CORRELATION_THRESHOLD, error_analysis, sample_d
from .context import pandas_ta
from unittest import TestCase
import pandas.util.testing as pdt
import pandas.testing as pdt
from pandas import DataFrame, Series
import pandas as pd
+1 -3
View File
@@ -2,9 +2,7 @@ from .config import sample_data
from .context import pandas_ta
from unittest import TestCase
# import numpy.testing as npt
# import pandas.util.testing as pdt
from pandas import DataFrame#, Series
from pandas import DataFrame
+1 -1
View File
@@ -2,7 +2,7 @@ from .config import error_analysis, sample_data, CORRELATION, CORRELATION_THRESH
from .context import pandas_ta
from unittest import TestCase, skip
import pandas.util.testing as pdt
import pandas.testing as pdt
from pandas import DataFrame, Series
import talib as tal
+1 -1
View File
@@ -2,7 +2,7 @@ from .config import error_analysis, sample_data, CORRELATION, CORRELATION_THRESH
from .context import pandas_ta
from unittest import TestCase, skip
import pandas.util.testing as pdt
import pandas.testing as pdt
from pandas import DataFrame, Series
import talib as tal
+1 -1
View File
@@ -2,7 +2,7 @@ from .config import error_analysis, sample_data, CORRELATION, CORRELATION_THRESH
from .context import pandas_ta
from unittest import TestCase, skip
import pandas.util.testing as pdt
import pandas.testing as pdt
from pandas import DataFrame, Series
import talib as tal
+1 -1
View File
@@ -2,7 +2,7 @@ from .config import error_analysis, sample_data, CORRELATION, CORRELATION_THRESH
from .context import pandas_ta
from unittest import TestCase, skip
import pandas.util.testing as pdt
import pandas.testing as pdt
from pandas import DataFrame, Series
import talib as tal