Last active
October 9, 2018 13:57
-
-
Save vlad-bezden/19d58ef001989123e98e0167fe1758f6 to your computer and use it in GitHub Desktop.
Example of how to get financial data from yahoo finance and plot it using matplotlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime as dt | |
import matplotlib.pyplot as plt | |
from matplotlib import style | |
import pandas as pd | |
import pandas_datareader.data as web | |
style.use('ggplot') | |
start = dt.datetime(2000, 1, 1) | |
end = dt.date.today() | |
df = web.DataReader('AAPL', 'yahoo', start) | |
df['100ma'] = df['Adj Close'].rolling(window=100, min_periods=0).mean() | |
print(df[['Open', 'Close', 'Adj Close', '100ma']].tail()) | |
df[['Adj Close', '100ma']].plot() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Perfect coding