PacktPublishing / Learn-Algorithmic-Trading

Learn Algorithmic Trading, Published by Packt
MIT License
802 stars 302 forks source link

Chapter 2 - Seasonality code not working #6

Closed Seriosso closed 3 years ago

Seriosso commented 3 years ago

The code of Seasonality does not work properly. when we copy paste the code an error occurs. I am using the 3.9 version python. I believe the problem is in this section:

goog_monthly_return = goog_data['Adj Close'].pct_change().groupby( [goog_data['Adj Close'].index.year, goog_data['Adj Close'].index.month]).mean()

goog_montly_return_list=[] for i in range(len(goog_monthly_return)): goog_montly_return_list.append\ ({'month':goog_monthly_return.index[i][1], 'monthly_return': goog_monthly_return[i]})

Seriosso commented 3 years ago

Solved: the code should be as follow: goog_montly_return_list=[] for i in range(len(goog_monthly_return)): goog_montly_return_list.append\ ({'month':goog_monthly_return.index[i][1], 'monthly_return': goog_monthly_return.iloc[i]})

Seriosso commented 3 years ago

Check my solution above.

gaurav-packt commented 3 years ago

Hello, Thank you for the resolution. With this I'm closing the issue. In case the issue persists please reopen it.