CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Importing and Managing Financial Data in R

Afficher le cours

Instructions

  • 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 by getSymbols().

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# 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
Modifier et exécuter le code