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

Macd bug #3

Open
AiAzez opened this issue May 14, 2024 · 2 comments
Open

Macd bug #3

AiAzez opened this issue May 14, 2024 · 2 comments

Comments

@AiAzez
Copy link

AiAzez commented May 14, 2024

I keep getting error from macd:
def compute_macd(close):
macd = pandas_ta.macd(close=close, length=20).iloc[:,0]
return macd.sub(macd.mean()).div(macd.std())

df['macd'] = df.groupby(level=1, group_keys=False)['adj close'].apply(compute_macd)


TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

result = self._python_apply_general(f, self._selected_obj)
values, mutated = self._grouper.apply_groupwise(f, data, self.axis)
res = f(group)
return op(a, b)

what is the solution

@AiAzez
Copy link
Author

AiAzez commented May 15, 2024

I find the problem, because of 2 stocks joined SP500 since 1 week 'GEV' & 'SOLV', how i can extract them from the data?

@seriousammy
Copy link

@AiAzez Hey if thats a problem, for learning purposes i would try to just omit the stocks that joined the S&P500

symbols_list = sp500['Symbol'].unique().tolist()

# ['GEV', 'SOLV', 'VLTO']: YFChartError(....)

stocks_to_remove = ['GEV', 'SOLV', 'VLTO']

symbols_list = [stock for stock in symbols_list if stock not in stocks_to_remove]

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