getSymbols             package:quantmod             R Documentation

_L_o_a_d _a_n_d _M_a_n_a_g_e _D_a_t_a _f_r_o_m _M_u_l_t_i_p_l_e _S_o_u_r_c_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     Functions to load and 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.

     Data is loaded silently _without_ user assignment by default.

_U_s_a_g_e:

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

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

_A_r_g_u_m_e_n_t_s:

 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) 

auto.assign: should results be loaded to the environment 

file.path: character string of file location 

     ...: additional parameters 

_D_e_t_a_i_l_s:

     'getSymbols' is a wrapper to load data from different sources - be
     them local or remote. Data is fetched through one of the available
     'getSymbols' methods and saved in the 'env' specified - the
     .GlobalEnv by default. Data is loaded in much the same way that
     'load' behaves. By default, it is assigned automatically to a
     variable in the specified environment, _without_ the user
     explicitly assigning the returned data to a variable.

     The previous sentence's point warrants repeating - getSymbols is
     called for its side effects, and _does not_ return the data object
     loaded. The data is loaded silently by the function into the
     user's environment - or an environment specified. This behavior
     can be overridden by setting auto.assign to FALSE, though it is
     not advised.

     By default the variable chosen is an R-legal name derived from the
     symbol being loaded. It is possible, using 'setSymbolLookup' to
     specify an alternate name if the default is not desired, see that
     function for details. 

     The result of a call to 'getSymbols' when auto.assign is set to
     TRUE (the default) is a new object or objects in the user's
     specified environment - with the loaded symbol(s) names returned
     upon exit. If auto.assign is set to FALSE the data will be
     returned from the call, and will require the user to assign the
     results himself.

     Most, if not all, documentation and functionality in 'quantmod'
     assumes that auto.assign remains set to TRUE.

     Upon completion a list of loaded symbols is stored in the global
     environment under the name '.getSymbols'.

     Objects loaded by 'getSymbols' with auto.assign=TRUE can be viewed
     with 'showSymbols' and removed by a call to 'removeSymbols'. 
     Additional data loading methods can be created simply by
     following the S3-like naming convention where getSymbols.NAME is
     used for your function NAME. See 'getSymbols' source code.

     'setDefaults(getSymbols)' can be used to specify defaults for
     'getSymbols' arguments. 'setDefaults(getSymbols.MySQL)' may be
     used 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).

_V_a_l_u_e:

     A call to getSymbols will load into the specified environment one
     object for each 'Symbol' specified, with class defined by
     'return.class'. Presently this may be 'ts', 'its', 'zoo',
     'quantmod.OHLC', or 'timeSeries'.

     If 'auto.assign' is set to FALSE an object of type 'return.class'
     will be returned.

_N_o_t_e:

     While it is possible to load symbols as classes other than 'zoo',
     'quantmod' requires most, if not all, data to be of class 'zoo' or
     inherited from 'zoo' - e.g. 'quantmod.OHLC'. The additional
     methods are meant mainly to be of use for those using the
     functionality outside of the 'quantmod' workflow.

_A_u_t_h_o_r(_s):

     Jeffrey A. Ryan

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_s:

     ## Not run: 
     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 

     ## End(Not run)

