Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dm and dx indicators seem broken #10

Open
JavierAntoran opened this issue Jan 25, 2021 · 1 comment
Open

dm and dx indicators seem broken #10

JavierAntoran opened this issue Jan 25, 2021 · 1 comment

Comments

@JavierAntoran
Copy link

JavierAntoran commented Jan 25, 2021

When I run

btalib.dx(btc_df.high, btc_df.low, btc_df.close)

or

btalib.dm(btc_df.high, btc_df.low)

with btc_df.high, btc_df.low and btc_df.close being columns from a pandas data frame (series of floats).

I get:


TypeError Traceback (most recent call last)
in
1 # import talib
2
----> 3 btalib.dx(btc_df.high, btc_df.low, btc_df.close)

~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/indicator.py in call(cls, *args, **kwargs)
150 # Auto-call base classes
151 for b_init in reversed(list(dict.fromkeys(b.init for b in bases))):
--> 152 b_init(self, *args, **kwargs)
153
154 # delete old aliases only meant for operational purposes

~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/indicators/directionalmove.py in init(self)
95 if self._plus: # upvmoe > 0 and where upmove > downmove
96 pdm = upmove.clip(lower=0.0) * (upmove > downmove)
---> 97 self._pdm = self._smoother(pdm, **smoothargs)
98
99 if self._minus: # downmove > 0 and where downmove > upmove

~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/indicator.py in call(cls, *args, **kwargs)
150 # Auto-call base classes
151 for b_init in reversed(list(dict.fromkeys(b.init for b in bases))):
--> 152 b_init(self, *args, **kwargs)
153
154 # delete old aliases only meant for operational purposes

~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/indicators/directionalmove.py in init(self)
50 p = self.p.period
51 _ewm = self.i0._ewm(span=p, _pearly=self.p._pearly, _seed=self.p._seed)
---> 52 self.o.smacc = _ewm._lfilter(alpha=1.0, beta=(p - 1) / p)
53
54 def _talib(self, kwdict):

~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/meta/lines.py in _lfilter(self, alpha, beta)
341 return scipy.signal.lfilter([alpha], [1.0, -beta], x)
342
--> 343 return self._apply(_sp_lfilter) # trigger getattr for _apply
344
345 def _mean(self): # meant for ewm with dynamic alpha

~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/btalib/meta/lines.py in call_op(*args, **kwargs)
377 sargs.append(arg)
378
--> 379 result[self._minidx:] = r = op(*sargs, **kwargs) # run/store
380 result = result.astype(r.dtype, copy=False)
381 return self._line._clone(result, period=self._minperiod)

~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/pandas/core/window/rolling.py in _apply(self, func, name, numba_cache_key, **kwargs)
467 return result
468
--> 469 return self._apply_blockwise(homogeneous_func, name)
470
471 def aggregate(self, func, *args, **kwargs):

~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/pandas/core/window/rolling.py in _apply_blockwise(self, homogeneous_func, name)
382 """
383 if self._selected_obj.ndim == 1:
--> 384 return self._apply_series(homogeneous_func, name)
385
386 obj = self._create_data(self._selected_obj)

~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/pandas/core/window/rolling.py in _apply_series(self, homogeneous_func, name)
371 raise DataError("No numeric types to aggregate") from err
372
--> 373 result = homogeneous_func(values)
374 return obj._constructor(result, index=obj.index, name=obj.name)
375

~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/pandas/core/window/rolling.py in homogeneous_func(values)
459 result = np.apply_along_axis(calc, self.axis, values)
460 else:
--> 461 result = calc(values)
462 result = np.asarray(result)
463

~/Documents/external_projects/trading/venv/lib/python3.8/site-packages/pandas/core/window/rolling.py in calc(x)
453 closed=self.closed,
454 )
--> 455 return func(x, start, end, min_periods)
456
457 with np.errstate(all="ignore"):

TypeError: _sp_lfilter() takes 1 positional argument but 4 were given


Python version 3.8.2

Package versions:

bta-lib 1.0.0
numpy 1.19.5
pandas 1.2.1
scipy 1.6.0

@drhighliner
Copy link

drhighliner commented Jan 27, 2021

It has to do with the pandas version. You need to downgrade to pandas 1.1.5 as bta-lib hasn't been updated to the 1.2.x versions yet. (maybe we can have an update here?) This should have been added to install requirements for bta-lib anyway, but that's another topic.

Let me know, if this works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants