Open bshuler opened 3 years ago
This is for the ADX feature. Encountered the same issue, here are the logs
# /Users/XXX/miniconda3/envs/XX/lib/python3.9/site-packages/ta/trend.py:768: RuntimeWarning: invalid value encountered in double_scalars
# dip[i] = 100 * (self._dip[i] / self._trs[i])
# /Users/XXX/miniconda3/envs/XX/lib/python3.9/site-packages/ta/trend.py:772: RuntimeWarning: invalid value encountered in double_scalars
# din[i] = 100 * (self._din[i] / self._trs[I])
Seems like the last index (the value of self._trs[-1]
) is always 0, hence the division error. Not sure if the result produced is still correct, but seems like the ADX results are all proper numeric values.
same error when running code from documentation example at https://technical-analysis-library-in-python.readthedocs.io/en/latest/
code:
import pandas as pd
from ta import add_all_ta_features
from ta.utils import dropna
import json
with open("minuteDataFormatted/ABB-EQ.json") as f:
data = json.load(f)
df = pd.DataFrame.from_dict(data["history"])
df = dropna(df)
df = add_all_ta_features(df, "open", "high", "low",
"close", "volume", fillna=True)
error:
RuntimeWarning: invalid value encountered in double_scalars
dip[i] = 100 * (self._dip[i] / self._trs[i])
C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\ta\trend.py:772: RuntimeWarning: invalid value encountered in double_scalars
din[i] = 100 * (self._din[i] / self._trs[i])
trend.py:643
I have revised this to:
but I am not sure this is what you expect or intend.
We should not divide by zero