Learn R Programming

fImport (version 2110.79)

Yahoo: Import Market Data from Yahoo

Description

Imports financial time series data from chart.yahoo.com.

Usage

yahooSeries(symbols, from = NULL, to = Sys.timeDate(), 
    nDaysBack = 366, ...) 
    
yahooImport(query, file = "tempfile", source = NULL,
    frequency = c("daily", "weekly", "monthly"), 
    from = NULL, to = Sys.timeDate(), nDaysBack = 366, 
    save = FALSE, sep = ";", try = TRUE)

Arguments

file
a character string with filename, usually having extension ".csv", where to save the downloaded data.
frequency
a character string, one of "auto", "quarterly", "monthly", or "daily", defining the frequency of the data records. Note, the import function tries autodetect the frequency of the time series to be dowwnloaded. This may fail, in
from
the date from when to extract the time series.
nDaysBack
the number of days back.
query
a character string, denoting the location of the data at the web site.
save
a logical value, if set to TRUE the downloaded data file will be stored under the path and file name specified by the string file. By default FALSE.
sep
a charcter value specifying the column separator.
source
a character string setting the URL of the source. If NULL, then the URL will be set automatically to its default value.
symbols
a character string with the symbols to be downloaded.
to
the end date of the data download, by default the current date.
try
a logical value, if set to TRUE the Internet access will be checked.
...
optional arguments to be passed.

Value

  • The function yahooImport returns an S4 object of class fWEBDATA with the following slots:
  • @callthe function call.
  • @datathe data as downloaded formatted as a data.frame.
  • @parama character vector whose elements contain the values of selected parameters of the argument list.
  • @titlea character string with the name of the download. This can be overwritten specifying a user defined input argument.
  • @descriptiona character string with an optional user defined description. By default just the current date when the test was applied will be returned.
  • The function yahooSeries returns an S4 object of class timeSeries or alternatively an object specified by the function argument returnClass. The function keystatsImport returns a data frame with key statistics downloaded from yahoo's web site.

Details

Import data from chart.yahoo.com: The query string is given as s=SYMBOL&a=DD&b=MM&c=CCYY&g=d&q=q&z=SYMBOL&x=.csv where SYMBOL has to replaced by the symbol name of the instrument, and DD, MM, and CCYY by the day, month-1 and century/year when the time series should start.

Here are some examples of symbols:

ll{ [query] Description: ^DJI Dow Jones 30 Industrial Averages ^NYA New York Stock Exchange Composite ^NDX Nasdaq 100 Index ^IXIC Nasdaq Composite Index ^TYX US 30Y Treasury Bond Index IBM BM DJIA Stock KO Coca-Cola DJIA Stock }

The meaning of the tokens in the query string are the following:

ll{ Token Description s Selected Ticker-Symbol a First Quote starts with Month (mm) b First Quote starts with Day (dd) c First Quote starts with Year (ccyy) d Last Quote ends with Month (mm) e Last Quote ends with Day (dd) f Last Quote ends with Year (ccyy) z Selected Ticker-Symbol }

Examples

Run this code
## yahooImport -
   yahooSeries("IBM")

Run the code above in your browser using DataLab