Find stock ticker from Yahoo Finance
You need the instrument identifier to import data from an internet data source. They can often be found on the data source website. In this exercise, you will search Yahoo Finance for the ticker symbol for Pfizer stock.
Note that some sources may not provide data for certain symbols, even if you can see the data displayed on their website in tables and/or charts. getSymbols()
will error if the data is not available for download.
Este exercício faz parte do curso
Importing and Managing Financial Data in R
Instruções do exercício
- Create an object called
symbol
from the three-letter Yahoo Finance ticker symbol for Pfizer stock. To find the symbol, go to Yahoo Finance and search for "Pfizer". Note that there are two parts to this ticker. We only need what comes before the period (the period and suffix specify other exchanges). - Use
getSymbols()
to import the data. - Use the
head()
function to view the first few rows of the object created bygetSymbols()
.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Create an object containing the Pfizer ticker symbol
symbol <- "___"
# Use getSymbols to import the data for 'symbol'
# Look at the data in the object getSymbols created