Python Pandas || Moving Averages and Rolling Window Statistics for Stock Prices

preview_player
Показать описание
#pandas #python #rolling

Please SUBSCRIBE:

fix_yahoo_finance has been renamed yfinance.

This video was made after changes to many APIs including Yahoo and Google prevented the datareader from connecting. This problem was rectified in pandas_datareader 0.80, however. You may still find yfinance to be a useful library - particularly if for some reason you cannot upgrade pandas_datareader.

Quickly download data for any number of stocks and create a correlation matrix using Python pandas and create a scatter matrix. It may take me 10 minutes to explain, but it will only take you 3 to see the power of Python for downloading and exploring data quickly primarily utilizing NumPy and pandas.

Video tutorial demonstrating the using of the pandas rolling method to calculate moving averages and other rolling window aggregations such as standard deviation often used in determining a securities historical volatility.

You can download the notebook used here:
Рекомендации по теме
Комментарии
Автор

finally quit watching pandas rolling videos to watch pandas.rolling videos i was searching for

Arthurk
Автор

Thanks for a simple, hands-on explanation. I read all the web pages and couldn't understand a thing till I spent 10 minutes watching your examples.

HitAndMissLab
Автор

1. You got it the opposite in terms of lagging. The rolling mean by default is lagging. When you use "center=True", that actually takes away the lagging. To reiterate, when you specify centering, that takes away lagging. Not the other way around.
2. Instead of shifting the rolling mean by 1 to exclude the same row, you should use "closed=Left".

MagicmathmandarinOrg
Автор

Thanks for your tutorial.
What is the optimal number to choose for a window?

flaviobrienza
Автор

Thanks. Especially the shift() is useful for me.

strat_us
Автор

It will be also a good idea to add a moving average such as MA21 or MA50 to the volatility plot, to see what happens when the volatility crosses up or down such of an MA. Great.

kicc
Автор

Awesome tutorial - exactly what I was looking for. Thank you!

marcusklapprodt
Автор

Hello Matt,

you said in the end of the video when plotting the moving average std the following:" this would include the 21st observation, the volatility should be used the next day, otherwise it will imply that we know something we don't". What do you mean exactly by this please?
I presume that you are calculating a 21 days moving average std and that's why you did .shift() but I want to understand the logic behind your previous statement.

Thanks a lot for your patience.

Regards

mrida
Автор

nice work, I hadn't found this method in book i followed

surajpokhrel
Автор

How do you choose what value to roll for? Is it based on data fluctuations or data trend? I can’t find the answer

eeejay
Автор

Thank you, this was a nice little tutorial.

fancylad
Автор

In addition to the graph, is there a way to display the actual values. predicted and actual? I suppose just do the .head(# of rows)? Thanks

HealthyFoodBae_
Автор

Is there a method similar to this that can be used to calculate a running median?

garyxing
Автор

This is helpful. Also, can you do a small tutorial for EMA moving average in Python Pandas?

cocoon
Автор

thank you man finally got what i was looking for....( .shift() )

prasadsawant
Автор

Hey Matt, great video :) Do you have an alternative to Yahoo finance now that it's unstable? Or a workaround of some sort

andreasbrodersen
Автор

ModuleNotFoundError: No module named 'pandas_datareader'

AlvaroLefian
Автор

For some reason, my rolling average estimates get cut off when the index of my main stock data ends (so the current day). Therefore, the data in the dataframe and chart doesn't continue past the current day, meaning all graph points end at the same time spot without the moving averages extending past the current day.

Do you know why this might be happening?

bugkassela
Автор

Hi Matt!
The data in which I am working on is yearly data and I dont know how to do prediction in python. Could u suggest any method.
Please help :(

shashibisht
Автор

Hi Matt, I'm getting
ModuleNotFoundError: No module named 'pandas_datareader'
when I try to import pandas-datareader. Any solutions to this?
Thanks

taishihasegawa