Learn R Programming

quantmod (version 0.2-5)

getSymbols: Manage Data from Multiple Sources

Description

Functions to manage Symbols in specified environment. Used by specifyModel to retrieve symbols specified in first step of modelling procedure. Not a true S3 method, but methods for different data sources follow an S3-like naming convention. Additional methods can be added by simply adhering to the convention.

Current src methods available are: yahoo, google, MySQL, FRED, csv, RData, and Oanda.

Usage

getSymbols(Symbols = NULL, 
           env = .GlobalEnv,
           reload.Symbols = FALSE,
           verbose = FALSE,
           warnings = TRUE,
           src = "yahoo",
           symbol.lookup = TRUE,
           ...)

showSymbols(env=.GlobalEnv) removeSymbols(Symbols=NULL,env=.GlobalEnv) saveSymbols(Symbols = NULL, file.path=stop("must specify 'file.path'"), env = .GlobalEnv)

Arguments

Symbols
a character vector specifying the names of each symbol to be loaded
env
where to create objects. (.GlobalEnv)
reload.Symbols
boolean to reload current symbols in specified environment. (FALSE)
verbose
boolean to turn on status of retrieval. (FALSE)
warnings
boolean to turn on warnings. (TRUE)
src
character string specifying sourcing method. (yahoo)
symbol.lookup
retrieve symbol's sourcing method from external lookup (TRUE)
file.path
character string of file location
...
additional parameters

Value

  • A call to getSymbols will load into the specified environment one object for each Symbol specified, with class defined by return.class.

Details

getSymbols first looks to the local environment for matching symbols. If found, the next symbol in Symbols is attempted, if not found, it is skipped and a warning will be displayed. Upon completion a list of loaded symbols is stored in the global environment under the name .getSymbols.

Objects loaded by getSymbols can be viewed with showSymbols and removed by a call to removeSymbols. Additional retrieval methods can be created simply following the S3-like naming convention where getSymbols.NAME is used for your function NAME. See getSymbols.skeleton.

setDefaults(getSymbols) can be used to specify defaults for all passed getSymbols arguments. setDefaults(getSymbols.MySQL) for arguments specific to getSymbols.MySQL, etc.

The sourcing of data is managed internally through a complex lookup procedure. If symbol.lookup is TRUE (the default), a check is made if any symbol has had its source specified by setSymbolLookup.

If not set, the process continues by checking to see if src has been specified by the user in the function call. If not, any src defined with setDefaults(getSymbols,src=) is used.

Finally, if none of the other source rules apply the default getSymbols src method is used (yahoo).

See Also

getModelData,specifyModel, setSymbolLookup, getSymbols.csv, getSymbols.RData, getSymbols.oanda, getSymbols.yahoo, getSymbols.google, getSymbols.FRED,

Examples

Run this code
setSymbolLookup(QQQQ='yahoo',SPY='MySQL')

getSymbols(c('QQQQ','SPY'))                
# loads QQQQ from yahoo (set with setSymbolLookup)
# loads SPY from MySQL (set with setSymbolLookup)

getSymbols('F')       
# loads Ford market data from yahoo (the formal default)

setDefaults(getSymbols,verbose=TRUE,src='MySQL')
getSymbols('DIA')                 
# loads symbol from MySQL database (set with setDefaults)

getSymbols('F',src='yahoo',return.class='ts') 
# loads Ford as time series class ts

Run the code above in your browser using DataLab