Closed monkey0619 closed 8 months ago
Hello @monkey0619,
Thanks for sharing a potential solution for v0.3.14b
. Furthermore, as mentioned in Issue #659:
The Linear Regression indicator, like many others, is due for an update as well as be rewritten using numpy to speed it up. ... Unfortunately there are too many things outstanding for one person to do. So hopefully someone can help by checking out the development branch and submit a PR to get this resolved sooner. 😎
Kind Regards, KJ
@monkey0619,
You did not specify which library or trading platform it is incongruent with. Was it TA-Lib, TradingView, ToS, IBKR, MT4/5, Sierra, ... ?
Note: It is really hard to easily test anything but TA-Lib. TradingView requires a manual approach. Any others are even more cumbersome to compare. :sob:
Thanks
I compared the result with TA-Lib, his result is consistent with what's expected from TA-lib, see screenshot below:
When I get time, I could try to fix it, and do a PR/Contribution.
Looks like it requires tsf=True with all other parameter outputs such as "intercept", "r", etc., set to False to be compatible with TA-Lib. So TA-Lib output: m * length + b
, not m * (length - 1) + b
@xieliaing
If TA Lib is installed, by default TA Lib will run. Thus it must be disabled using talib=False
in the call.
Basic linreg with ta.linreg(close, length=8, talib=False)
with the first Series is Pandas TA, the following is TA Lib.
Kind Regards, KJ
Does this work as expected for you as well?
Thank you, KJ, it works for me.
Which version are you running? The lastest version is on Github. Pip is for major releases. 0.3.14b0
Do you have TA Lib also installed in your environment? No
Have you tried the development version? Did it resolve the issue? Not tried
Describe the bug A wrong return. I checked the linreg help and found the following calculation formula. return m * (length - 1) + b
The actual return is m * (length - 2) + b with coefficient of 10.0952380952381 and intercept of 11.1666666666667 for the first return 71.738095. In this case, length is 8 and (length - 2) equals 6.
To Reproduce
Screenshots
Additional context Add any other context about the problem here.
Thanks for using Pandas TA!