import-fred {fImport} | R Documentation |
Import Market Data from the Federal Reserve Database
Description
Imports financial time series data from research.stlouisfed.org.
Usage
fredSeries(symbols, from = NULL, to = Sys.timeDate(),
nDaysBack = 366, ...)
fredImport(query, file = "tempfile", source = NULL, frequency = "daily",
from = NULL, to = Sys.timeDate(), nDaysBack = NULL,
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 such case specify the frequency explicitely. |
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 |
sep |
a charcter value specifying the column separator. |
source |
a character string setting the URL of the source.
If |
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 fredImport
returns an S4 object of class
fWEBDATA
with the following slots:
@call |
the function call. |
@data |
the data as downloaded formatted as a data.frame. |
@param |
a character vector whose elements contain the values of selected parameters of the argument list. |
@title |
a character string with the name of the download. This can be overwritten specifying a user defined input argument. |
@description |
a character string with an optional user defined description. By default just the current date when the test was applied will be returned. |
The function fredSeries
returns an S4 object of
class timeSeries
or alternatively an object specified by
the function argument returnClass
.
Note
Internet Download Functions:
IMPORTANT NOTE: If the service provider changes the data file format it may become necessary to modify and update the functions.
Feel free to inspect the code of the functions and to create your own download function from other Internet web sites and Portals.
Author(s)
Diethelm Wuertz for the Rmetrics R-port.
References
Diethelm Wuertz, Yohan Chalabi, and Andrew Ellis, (2010); Financial Market Data for R/Rmetrics, Rmetrics eBook, Rmetrics Association and Finance Online, Zurich, www.rmetrics.org.
Examples
a = fredImport("DEXSZUS")
head(a@data) # a@data is a data frame
b = fredSeries("DEXSZUS")
head(b) # timeSeries object