Skip to content

Commit

Permalink
Add warning to first getSymbols.yahoo call
Browse files Browse the repository at this point in the history
Similar to the first call to getSymbols, the first call to
getSymbols.yahoo should throw a warning alerting users to the changes
in the Yahoo Finance data. Include more details in ?getSymbols.yahoo.

Also update the message printed after the first call to getSymbols().

See #157.
  • Loading branch information
joshuaulrich committed May 26, 2017
1 parent 5cb5b8f commit aa19272
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
25 changes: 16 additions & 9 deletions R/getSymbols.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ function(Symbols=NULL,
...) {
if(getOption("getSymbols.warning4.0",TRUE)) {
# transition message for 0.4-0 to 0.5-0
message(paste(
' As of 0.4-0,',sQuote('getSymbols'),'uses env=parent.frame() and\n',
'auto.assign=TRUE by default.\n\n',

'This behavior will be phased out in 0.5-0 when the call will\n',
'default to use auto.assign=FALSE. getOption("getSymbols.env") and \n',
'getOptions("getSymbols.auto.assign") are now checked for alternate defaults\n\n',
message(sQuote('getSymbols'), ' currently uses auto.assign=TRUE by default, but will\n',
'use auto.assign=FALSE in 0.5-0. You will still be able to use\n',
sQuote('loadSymbols'), ' to automatically load data. getOption("getSymbols.env")\n',
'and getOption("getSymbols.auto.assign") will still be checked for\n',
'alternate defaults.\n\n',
'This message is shown once per session and may be disabled by setting \n',
'options("getSymbols.warning4.0"=FALSE). See ?getSymbols for more details.'))
options("getSymbols.warning4.0"=FALSE)
'options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.')
options("getSymbols.warning4.0"=FALSE)
}
importDefaults("getSymbols")
# to enable as-it-was behavior, set this:
Expand Down Expand Up @@ -276,6 +274,15 @@ function(Symbols,env,return.class='xts',index.class="Date",
to=Sys.Date(),
...)
{
if(getOption("getSymbols.yahoo.warning",TRUE)) {
# Warn about Yahoo Finance quality and stability
message("\nWARNING: There have been significant changes to Yahoo Finance data.",
"\nPlease see the Warning section of ", sQuote("?getSymbols.yahoo"), " for details.\n",
"\nThis message is shown once per session and may be disabled by setting\n",
"options(\"getSymbols.yahoo.warning\"=FALSE).")
options("getSymbols.yahoo.warning"=FALSE)
}

importDefaults("getSymbols.yahoo")
this.env <- environment()
for(var in names(list(...))) {
Expand Down
11 changes: 11 additions & 0 deletions man/getSymbols.yahoo.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ data for use with \pkg{quantmod}. Essentially a
simple wrapper to the underlying Yahoo! finance site's
historical data download.
}
\section{Warning}{
As of quantmod 0.4-9, \code{getSymbols.yahoo} has been patched to
work with changes to Yahoo Finance, which also included the following
changes to the raw data:
\itemize{
\item The adjusted close column appears to no longer include dividend adjustments
\item The close column appears to be adjusted for splits twice
\item The open, high, and low columns are adjusted for splits, and
\item The raw data may contain missing values.
}
}
\value{
A call to getSymbols.yahoo will load into the specified
environment one object for each
Expand Down

0 comments on commit aa19272

Please sign in to comment.