twopirllc / pandas-ta

Technical Analysis Indicators - Pandas TA is an easy to use Python 3 Pandas Extension with 150+ Indicators
https://twopirllc.github.io/pandas-ta/
MIT License
5.32k stars 1.04k forks source link

Indicators using moving averages variable does not pass kwargs to ma(mamode, close, length=length) #764

Open PiotrJuzwiak opened 8 months ago

PiotrJuzwiak commented 8 months ago

Which version are you running? The lastest version is on Github. Pip is for major releases.

import pandas_ta as ta
print(ta.version) 2.1.4

Do you have TA Lib also installed in your environment?

$ pip list

Yes

Have you tried the development version? Did it resolve the issue?

$ pip install -U git+https://github.com/twopirllc/pandas-ta.git@development

No

Describe the bug Many indicators e.g. Keltner Channel is using internally ma(mamode, close, length) but it should have ma(mamode, close, length, kwargs) Many moving averages e.g linreg have extra kwargs that are not passed further So for example passing kwargs to kc Class is not passing those kwargs to be used when calculating moving average.

To Reproduce Provide sample code.

    if mamode == 'linreg':
        kwargs={'degrees': True, 'slope': True, 'tsf': True}
    print(kwargs)

    kc_var = kc(close=df['close'], high=df['high'], low=df['low'], length=p_length, mamode=mamode, scalar=p_scalar, kwargs=kwargs)

Expected behavior A clear and concise description of what you expected to happen. When calling should have kwargs passed into it e.g. ma(mamode, close, length, kwargs)

Inside kc

# Calculate Result
    use_tr = kwargs.pop("tr", True)
    if use_tr:
        range_ = true_range(high, low, close)
    else:
        range_ = high_low_range(high, low)
#SHOULD BE BELOW
    basis = ma(mamode, close, length=length, kwargs)
    band = ma(mamode, range_, length=length, kwargs)

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

Thanks for using Pandas TA!

twopirllc commented 8 months ago

Hello @PiotrJuzwiak

Pandas TA is not even 1.0.0+ let alone 2.1.4.

So I assume you are on v0.3.14.

Yes, some indicators, like kc, have not had their internal ma(mamode, x, length=length) accept **kwargs yet. Should be a relatively easy PR to update all the indicators that match = ma(mamode, and append , **kwargs) to it. Currently overloaded with PRs and Issues.

Kind Regards KJ