Modify PricePlot.py so that: i) The starting date is March 1, 2020; ii) change the plot color to red.
Question:
Modify PricePlot.py so that: i) The starting date is March 1, 2020; ii) change the plot color to red.
#import needed modules
import matplotlib.pyplot as plt
from pandas_datareader import data as pdr
import matplotlib.dates as mdates
#set the start and end date
start_date = "2021-02-25"
end_date = "2021-08-25"
#choose stock ticker symbol
ticker = "TSLA"
#get stock price
stock = pdr.get_data_yahoo(ticker, start=start_date, end=end_date)
print(stock)
#obtain dates
stock['Date']=stock.index.map(mdates.date2num)
#choose figure size
fig = plt.figure(dpi=128, figsize=(10, 6))
#format date to place on the x-axis
formatter = mdates.DateFormatter('%m/%d/%Y')
plt.gca().xaxis.set_major_formatter(formatter)
# Plot data.
plt.plot(stock['Date'], stock['Adj Close'], c='blue')
# Format plot.
plt.title("The Stock Price", fontsize=16)
plt.xlabel('Date', fontsize=10)
fig.autofmt_xdate()
plt.ylabel("Price", fontsize=10)
plt.show()
Auditing The Art And Science Of Assurance Engagements
ISBN: 9780136692089
15th Canadian Edition
Authors: Alvin A. Arens, Randal J. Elder, Mark S. Beasley, Chris E. Hogan, Joanne C. Jones