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

Linreg does not return Slope, Forecast, Angle, or R coefficient #659

Open
sdk451 opened this issue Feb 11, 2023 · 2 comments
Open

Linreg does not return Slope, Forecast, Angle, or R coefficient #659

sdk451 opened this issue Feb 11, 2023 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@sdk451
Copy link

sdk451 commented Feb 11, 2023

Which version are you running? 0.3.14b0
Do you have TA Lib also installed in your environment? No

The LINREG indicator returns the linreg indicator value but does not return other useful indicator values mentioned in the documentation - e.g. Slope, Forecast, Angle, or R coefficient which are calculated in the indicator code.

Sample code to reproduce:

import pandas as pd
import pandas_ta as ta
import yfinance as yf

print(f"PANDAS TA version = {ta.version}")
# Get symbol OHLC data
data = yf.download("CL=F")

# pandas_ta linreg doesn't appear to be returning all the values yet...

# this works
data['LINREG'] = data.ta.linreg(length=20, slope=True, degrees=True, r=True, tsf = True )

# this (below) doesn't work as dictionary key values are missing
# linreg = data.ta.linreg(length=20, slope=True, degrees=True, r=True, tsf = True ) 
# data['LINREG'] =  linreg['LR_20']
# data['LINREG_SLOPE'] = linreg['LRm_20']
# data['LINREG_FORECAST'] = linreg['LR_20']
# data['LINREG_ANGLE'] = linreg['LRa_20']
# data['LINREG_R'] = linreg['LRr_20']

Expected: indicator values described in the documentation (and calculated in the indicator code) should be available

@twopirllc twopirllc added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Feb 13, 2023
@twopirllc
Copy link
Owner

Hello @sdk451,

This library intends to provide similar functionality as TA Lib. As such, individual calls are currently required to return each Series. For more detail, here is PTAs development source.

import pandas as pd
import pandas_ta as ta
import yfinance as yf

print(f"PANDAS TA version = {ta.version}")
# Get symbol OHLC data
data = yf.download("CL=F")

# this works
n = 20
data.ta.linreg(length=n, append=True)
data.ta.linreg(length=n, slope=True, append=True)
# Angle in radians
data.ta.linreg(length=n, angle=True, append=True)
# Angle in degrees
data.ta.linreg(length=n, angle=True, degrees=True, append=True)
data.ta.linreg(length=n, r=True, append=True)
data.ta.linreg(length=n, intercept=True, append=True)

# Only works if TA Lib is installed as it calls TA Lib's TSF()
data.ta.linreg(length=n, tsf=True, append=True)

The Linear Regression indicator, like many others, is due for an update as well as be rewritten using numpy to speed it up. So an all like parameter to return each in one call will take a bit more time. 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

@sdk451
Copy link
Author

sdk451 commented Feb 21, 2023

Thanks KJ!

I'll grab the values separately through repeat calls as suggested above. If I get bandwidth I'll look into making a PR/contribution to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants