Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

getSymbols.yahoo

Download OHLC Data From Yahoo Finance


Description

Downloads Symbols to specified env from ‘finance.yahoo.com’. This method is not to be called directly, instead a call to getSymbols(Symbols,src='yahoo') will in turn call this method. It is documented for the sole purpose of highlighting the arguments accepted, and to serve as a guide to creating additional getSymbols ‘methods’.

Usage

getSymbols.yahoo(Symbols,
                 env,
                 return.class = 'xts',
                 index.class  = 'Date',
                 from = "2007-01-01",
                 to = Sys.Date(),
                 ...,
                 periodicity = "daily",
                 curl.options = list())

Arguments

Symbols

a character vector specifying the names of each symbol to be loaded

env

where to create objects. (.GlobalEnv)

return.class

class of returned object

index.class

class of returned object index (xts only)

from

Retrieve data no earlier than this date. (2007-01-01)

to

Retrieve data through this date (Sys.Date())

...

additional parameters

periodicity

periodicity of data to query and return. Must be one of "daily", "weekly", "monthly". ("daily")

curl.options

options passed to curl::handle_setopt

Details

Meant to be called internally by getSymbols (see also).

One of a few currently defined methods for loading data for use with quantmod. Essentially a simple wrapper to the underlying Yahoo! finance site's historical data download.

Value

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

In the case of xts objects, the indexing will be by Date. This can be altered with the index.class argument. See indexClass for more information on changing index classes.

Warning

As of quantmod 0.4-9, getSymbols.yahoo has been patched to work with changes to Yahoo Finance, which also included the following changes to the raw data:

  • The adjusted close column appears to no longer include dividend adjustments

  • The close column appears to be adjusted for splits twice

  • The open, high, and low columns are adjusted for splits, and

  • The raw data may contain missing values.

Author(s)

Jeffrey A. Ryan

References

Yahoo Finance: https://finance.yahoo.com

See Also

Examples

## Not run: 
# All 3 getSymbols calls return the same
# MSFT to the global environment
# The last example is what NOT to do!

## Method #1
getSymbols('MSFT',src='yahoo')


## Method #2
setDefaults(getSymbols,src='yahoo')
  # OR
setSymbolLookup(MSFT='yahoo')

getSymbols('MSFT')

#########################################
##  NOT RECOMMENDED!!!
#########################################
## Method #3
getSymbols.yahoo('MSFT',env=globalenv())

## End(Not run)

quantmod

Quantitative Financial Modelling Framework

v0.4.18
GPL-3
Authors
Jeffrey A. Ryan [aut, cph], Joshua M. Ulrich [cre, aut], Wouter Thielen [ctb], Paul Teetor [ctb], Steve Bronder [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.