Hi there. I'm having trouble getting bta-lib's adx() to work. Would greatly appreciate any help I can get from this group.
Here's a small piece of code that demonstrates the problem, and below the code is the output I get from running it.
C O D E:
https://gist.github.com/randie/5cac0dbf845b8b323a311ed32abea2c7
import pandas as pd
import btalib as bta
df = pd.read_csv("data/tickers/AMD.csv", parse_dates=True, index_col='Date')
df['rsi'] = bta.rsi(df).df # works
df['adx'] = bta.adx(df).df # does not work
print(df.tail())
O U T P U T:
#
# Output with adx() line commented out => works
#
(sandbox) 10:38 • screener • master • d5822cb ✗
❯ /opt/anaconda3/envs/sandbox/bin/python /Users/randie/projects/screener/bta-adx.py
Open High Low Close Adj Close Volume rsi
Date
2021-03-19 78.489998 79.339996 77.589996 79.059998 79.059998 42247100 42.284132
2021-03-22 79.989998 81.269997 79.220001 80.300003 80.300003 39648600 44.939105
2021-03-23 80.129997 80.339996 77.949997 78.379997 78.379997 40466600 41.737588
2021-03-24 77.550003 78.800003 76.400002 76.480003 76.480003 43753600 38.792404
2021-03-25 75.849998 76.949997 74.959999 76.220001 76.220001 44663000 38.393151
#
# Output with adx() line back in => does not work!
#
(sandbox) 10:38 • screener • master • d5822cb ✗
❯ /opt/anaconda3/envs/sandbox/bin/python /Users/randie/projects/screener/bta-adx.py
Traceback (most recent call last):
File "/Users/randie/projects/sandbox/python/screener/adx.py", line 8, in <module>
df['adx'] = bta.adx(df).df # does not work
File "/opt/anaconda3/envs/sandbox/lib/python3.8/site-packages/btalib/indicator.py", line 152, in __call__
b_init(self, *args, **kwargs)
File "/opt/anaconda3/envs/sandbox/lib/python3.8/site-packages/btalib/indicators/directionalmove.py", line 97, in __init__
self._pdm = self._smoother(pdm, **smoothargs)
File "/opt/anaconda3/envs/sandbox/lib/python3.8/site-packages/btalib/indicator.py", line 152, in __call__
b_init(self, *args, **kwargs)
File "/opt/anaconda3/envs/sandbox/lib/python3.8/site-packages/btalib/indicators/directionalmove.py", line 52, in __init__
self.o.smacc = _ewm._lfilter(alpha=1.0, beta=(p - 1) / p)
File "/opt/anaconda3/envs/sandbox/lib/python3.8/site-packages/btalib/meta/lines.py", line 343, in _lfilter
return self._apply(_sp_lfilter) # trigger __getattr__ for _apply
File "/opt/anaconda3/envs/sandbox/lib/python3.8/site-packages/btalib/meta/lines.py", line 379, in call_op
result[self._minidx:] = r = op(*sargs, **kwargs) # run/store
File "/opt/anaconda3/envs/sandbox/lib/python3.8/site-packages/pandas/core/window/rolling.py", line 469, in _apply
return self._apply_blockwise(homogeneous_func, name)
File "/opt/anaconda3/envs/sandbox/lib/python3.8/site-packages/pandas/core/window/rolling.py", line 384, in _apply_blockwise
return self._apply_series(homogeneous_func, name)
File "/opt/anaconda3/envs/sandbox/lib/python3.8/site-packages/pandas/core/window/rolling.py", line 373, in _apply_series
result = homogeneous_func(values)
File "/opt/anaconda3/envs/sandbox/lib/python3.8/site-packages/pandas/core/window/rolling.py", line 461, in homogeneous_func
result = calc(values)
File "/opt/anaconda3/envs/sandbox/lib/python3.8/site-packages/pandas/core/window/rolling.py", line 455, in calc
return func(x, start, end, min_periods)
TypeError: _sp_lfilter() takes 1 positional argument but 4 were given