mirror of
https://github.com/wassname/pandas-ta.git
synced 2026-07-24 13:10:26 +08:00
BUG #39 ATR fix
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user