Skip to content

Instantly share code, notes, and snippets.

@vlad-bezden
Last active October 9, 2018 13:57
Show Gist options
  • Save vlad-bezden/19d58ef001989123e98e0167fe1758f6 to your computer and use it in GitHub Desktop.
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
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()
@RPRAVIN84
Copy link

Perfect coding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment