#!/usr/bin/env python # coding: utf-8 # ## Part 0: Import packages # In[26]: import yfinance as yf import matplotlib.pyplot as plt get_ipython().run_line_magic('matplotlib', 'inline') # ## Part 1: Download stock data from Yahoo Finance # In[27]: stock = yf.download("GOOG", "2019-09-15", "2019-09-25") stock.head() # ## Part 2: Save the data as csv file # In[21]: stock.to_csv("stock.csv") # ## Part 3: Visualize the trend of the stock # In[23]: fig = plt.figure(figsize = (10, 5)) plt.plot(stock["Open"], color = "red") plt.title("Google open price") plt.show(); # In[25]: fig = plt.figure(figsize = (10, 5)) plt.plot(stock["Open"], color = "red") plt.plot(stock["Close"], color = "green") plt.title("Google open price") plt.legend() plt.show(); # In[ ]: