Visualize a stock price trend
Google Finance has deprecated their API but DataReader
now makes available the data source 'iex'
. To experiment with the data outside DataCamp environment, you will need an IEX Cloud account.
The most important change to the functionality is the limitation of the data to the last five years. The DataFrame
returned by the DataReader
has the same columns
, but in lower case.
The matplotlib.pyplot
package is essential to visualizing stock price trends in Python.
In this exercise, you will import 2016 stock price data for Facebook, and then plot its closing price for the entire period! DataReader
and date
have already been imported.
Este ejercicio forma parte del curso
Importing and Managing Financial Data in Python
Instrucciones del ejercicio
- Import
matplotlib.pyplot
asplt
. - Using
date()
, set thestart
andend
dates to January 1, 2016 and December 31, 2016, respectively. - Set
ticker
to Facebook's stock ticker'FB'
anddata_source
to'iex'
. - Create a
DataReader()
object to import the stock prices and assign tostock_prices
. - Plot the
'close'
data instock_prices
, setticker
as the title, and show the result.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# Import matplotlib.pyplot
# Set start and end dates
start = ____
end = ____
# Set the ticker and data_source
ticker = ____
data_source = ____
# Import the data using DataReader
stock_prices = ____
# Plot close
____
# Show the plot
plt.show()