mementum / bta-lib

Technical Analysis library in pandas for backtesting algotrading and quantitative analysis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MAMA indicator ValueError

iamcos opened this issue · comments

Traceback (most recent call last):
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/series.py", line 1014, in setitem
self._set_with_engine(key, value)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/series.py", line 1054, in _set_with_engine
self.index._engine.set_value(values, key, value)
File "pandas/_libs/index.pyx", line 96, in pandas._libs.index.IndexEngine.set_value
File "pandas/_libs/index.pyx", line 106, in pandas._libs.index.IndexEngine.set_value
File "pandas/_libs/index.pyx", line 116, in pandas._libs.index.IndexEngine.get_loc
TypeError: 'slice(11, None, None)' is an invalid key

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/cosmos/GitHub/haasomeapitools/btalibtest.py", line 23, in
mama, fama = btalib.mama(data.High,data.Low,fastlimit=10,slowlimit=5)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/btalib/indicator.py", line 152, in call
b_init(self, *args, **kwargs)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/btalib/indicators/mama.py", line 79, in init
_mama = p0._ewm(alpha=alpha, span=1, _seed=SEED_ZERO)._mean()
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/btalib/meta/lines.py", line 357, in _mean
return self._apply(_dynalpha) # triggers getattr for _apply
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/btalib/meta/lines.py", line 379, in call_op
result[self._minidx:] = r = op(*sargs, **kwargs) # run/store
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/series.py", line 1042, in setitem
self._set_with(key, value)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/series.py", line 1064, in _set_with
return self._set_values(indexer, value)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/series.py", line 1111, in _set_values
self._data = self._data.setitem(indexer=key, value=value)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 561, in setitem
return self.apply("setitem", **kwargs)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 442, in apply
applied = getattr(b, f)(**kwargs)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/internals/blocks.py", line 877, in setitem
check_setitem_lengths(indexer, value, values)
File "/Users/cosmos/GitHub/haasomeapitools/.env/lib/python3.7/site-packages/pandas/core/indexers.py", line 124, in check_setitem_lengths
"cannot set using a slice indexer with a "

What package version are you using?

I'm currently using mama in production without issue. The only question I have is whether or not the calculations are done correctly, and unfortunately, I am having a hard time figuring that out.

Also, you're going to get a false positive almost every tick with those parameters. You may already know this, but the default for fast is 0.5. The default for slow is 0.05, and those parameters work pretty darn well.