Wednesday, 30 October 2019

Python Programming for Finance 2

Tesla stock 2011-2019


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')
#save web data in local csv file for better performance
'''
start = dt.datetime(2011, 1, 1)
end = dt.datetime(2019, 10, 30)

df = web.DataReader('TSLA', 'yahoo', start, end)
df.to_csv('tsla_csv')
'''
df = pd.read_csv('tsla_csv', parse_dates=True, index_col=0)
#print(df.head())
df['Adj Close'].plot()
plt.show()

No comments:

Post a Comment