joshuaulrich / quantmod Goto Github PK
View Code? Open in Web Editor NEWQuantitative Financial Modelling Framework
Home Page: http://www.quantmod.com/
License: GNU General Public License v3.0
Quantitative Financial Modelling Framework
Home Page: http://www.quantmod.com/
License: GNU General Public License v3.0
Submitted by: Garrett See
Assigned to: Joshua Ulrich
R-Forge link
Since the Defaults package has been removed from CRAN, it would be useful to be able to set global options() that getSymbols() and getSymbols.*() methods use if provided.
I'd like to change the argument list for getSymbols to this:
function(Symbols=NULL,
env=getOption(getSymbols.env, parent.frame()),
reload.Symbols=getOption(getSymbols.reload.Symbol, FALSE),
verbose=getOption(getSymbols.verbose, FALSE),
warnings=getOption(getSymbols.warnings, TRUE),
src=getOption(getSymbols.src, 'yahoo'),
symbol.lookup=getOption(getSymbols.symbol.lookup, TRUE),
auto.assign=getOption('getSymbols.auto.assign', TRUE), ...)
And change the args for getSymbols.yahoo() to this:
function(Symbols,
env=getOption(getSymbols.yahoo.env),
return.class=getOption(getSymbols.yahoo.return.class, 'xts'),
index.class=getOption(getSymbols.yahoo.index.class, 'Date'),
from=getOption(getSymbols.yahoo.from, '2007-01-01'),
to=getOption(getSymbols.yahoo.to, Sys.Date()), ...)
That way I can have my own function like this in my Rprofile
useYahoo <- function() {
options(getSymbols.src='yahoo')
options(getSymbols.yahoo.from='2014-01-01')
}
and others for other sets of 'default' parameters, so that I can easily switch between data sources.
Followups:
Date: 2014-12-07 21:26
Sender: Joshua Ulrich
As of r617, all the Defaults functionality that quantmod used has been moved directly into quantmod, so you should be able to use quantmod and any setDefaults calls as you had before. Closing this as 'fixed'.
Date: 2014-10-11 19:38
Sender: Garrett See
oops, there need to be quotes in there, e.g. getOption('getSymbols.src', 'yahoo')
Submitted by: John Smith
Assigned to: Joshua Ulrich
R-Forge link
There's no AdAd function, I can't see any reason why there shouldn't be one (with a ref in the docs that it will only work for datasources that provide adusted prices, such as yahoo)
Followups:
Date: 2014-12-07 22:00
Sender: Joshua Ulrich
I'm not going to incorporate this patch because it is an old request for a non-essential function that hasn't been requested by anyone other that the person submitting this feature request.
Submitted by: ivan popivanov
Assigned to: Joshua Ulrich
R-Forge link
ge = getSymbols('ge', src='yahoo', from='1900-01-01', auto.assign=F, adjust=T)
Error in sprintf('%.2d', to.d) :
invalid format '%.2d'; use format %f, %e, %g or %a for numeric objects
The problem occurs when the call to getDividends is made, because it passes the default to.d which is Sys.Date() instead of string.
ge = getSymbols('ge', src='yahoo', from='1900-01-01', to='2050-01-01', auto.assign=F, adjust=T)
The above works fine, which confirms the type problem. Now:
head(ge)
GE.Open GE.High GE.Low GE.Close GE.Volume GE.Adjusted
1962-01-02 0.5538378 0.5630685 0.5482994 0.5519917 2925044 0.18
1962-01-03 0.5491856 0.5491856 0.5446072 0.5464533 2004197 0.18
1962-01-04 0.5464533 0.5510317 0.5353766 0.5399550 2491704 0.18
1962-01-05 0.5399550 0.5409149 0.5169153 0.5261459 3696931 0.17
1962-01-08 0.5261459 0.5261459 0.5095308 0.5251859 4197980 0.17
1962-01-09 0.5251859 0.5325705 0.5214937 0.5279921 3155256 0.17
Hmm, looks like the adjustment is bad. Why do you have to use the splits and the dividends to adjust when the Adjusted column is available? Just take the ratio between Adjusted and Close and use this ratio to adjust Open, High, Low and Close. Is this wrong for some reason?!
Followups:
Date: 2014-12-07 20:04
Sender: Joshua Ulrich
The first issue seems to have been fixed awhile ago. The second issue is fixed in r618. getSymbols.yahoo now uses adjustOHLC if adjust=TRUE. I think the differences were because the previous getSymbols.yahoo adjustment did not un-adjust dividends for splits (Yahoo already adjusts dividends for splits) before calculating the adjustment ratios.
Submitted by: A T
Assigned to: Joshua Ulrich
R-Forge link
Here are some issues I've noticed about getSplits().
A major inconsistency issue, in most cases getSplits() will be used in conjunction with getDividends(). getSplits() will return an xts object with index POSIXct whereas getDividends() and getSymbols() both return an xts object with index Date. This will actually cause a misalignment in the data for cases where something has only split but not paid a dividend in the context of adjustOHLC() - in fact no adjustment will occur in that case.
It appears the getSplits() was copy and pasted, I say this because for when auto.assign is set to TRUE, this statement will execute:
xtsAttributes(Symbol) <- list(dividends = spl)
Followups:
Date: 2013-05-29 22:30
Sender: Joshua Ulrich
Date: 2013-05-29 22:13
Sender: A T
I'm running rev 606, the problem still persists. As an example if I use the adjustOHLC function on ticker symbol ERY. Absolutely no split adjustment occurs and after further investigation, the split occurrences are dropped due to inconsistent indexes.
From getDividends():
xtsAttributes(Symbol) <- list(dividends = fr)
From getSplits():
xtsAttributes(Symbol) <- list(dividends = spl)
You're writing to xtsAttributes, but naming both attributes dividends thus overwriting each other. Also clearly splits are not dividends.
Date: 2013-05-29 21:43
Sender: Joshua Ulrich
Submitted by: Stewart Wright
Assigned to: Nobody
R-Forge link
getDividends
and getSplits
should be able to update Symbol
not in the parent environment, but they actually don't.
The 'svn diff' below fixes this by creating a temporary variable which gets updated and then reinserted into the appropriate environment.
I have to use the tmp.symbol
variable as xtsAttributes
only updates variables in the parent.frame
.
Index: getDividends.R
===================================================================
--- getDividends.R (revision 609)
+++ getDividends.R (working copy)
@@ -2,8 +2,14 @@
function(Symbol,from='1970-01-01',to=Sys.Date(),env=parent.frame(),src='yahoo',
auto.assign=FALSE,auto.update=FALSE,verbose=FALSE,...) {
- if(missing(env))
+ tmp.symbol <- Symbol
+ if(missing(env)) {
env <- parent.frame(1)
+ } else {
+ if(exists(Symbol, envir = env)) {
+ tmp.symbol <- get(Symbol, envir = env)
+ }
+ }
if(is.null(env))
auto.assign <- FALSE
Symbol.name <- ifelse(!is.character(Symbol),
@@ -27,10 +33,11 @@
fr <- read.csv(tmp)
unlink(tmp)
fr <- xts(fr[,2],as.Date(fr[,1]))
- if(is.xts(Symbol)) {
+
+ if(is.xts(tmp.symbol)) {
if(auto.update) {
- xtsAttributes(Symbol) <- list(dividends=fr)
- assign(Symbol.name,Symbol,envir=env)
+ xtsAttributes(tmp.symbol) <- list(dividends=fr)
+ assign(Symbol.name,tmp.symbol,envir=env)
}
} else if(auto.assign) {
assign(paste(Symbol.name,'div',sep='.'),fr,envir=env)
Index: getSplits.R
===================================================================
--- getSplits.R (revision 609)
+++ getSplits.R (working copy)
@@ -4,8 +4,13 @@
# Function written by Joshua Ulrich, using
# getSymbols.yahoo as a guide.
- if(missing(env))
+ if(missing(env)) {
env <- parent.frame(1)
+ } else {
+ if(exists(Symbol, envir = env)) {
+ tmp.symbol <- get(Symbol, envir = env)
+ }
+ }
if(is.null(env))
auto.assign <- FALSE
Symbol.name <- ifelse(!is.character(Symbol),
@@ -39,10 +44,10 @@
colnames(fr) <- paste(Symbol.name,'spl',sep='.')
}
- if(is.xts(Symbol)) {
+ if(is.xts(tmp.symbol)) {
if(auto.update) {
- xtsAttributes(Symbol) <- list(splits=fr)
- assign(Symbol.name,Symbol,envir=env)
+ xtsAttributes(tmp.symbol) <- list(splits=fr)
+ assign(Symbol.name,tmp.symbol,envir=env)
}
} else if(auto.assign) {
assign(paste(Symbol.name,'spl',sep='.'),fr,envir=env)
Followups:
Date: 2013-09-26 05:26
Sender: Stewart Wright
Updated the patch.
Previous version did not handle case of just calling functions with a Symbol (i.e. 'F'): getDividends('F')
. So now behavior is consistent.
Note: The code above reflects Stewart's updated patch.
Several functions call tempfile
but do not call unlink
at all, or do not call unlink
in the case of an error. This is especially problematic in several getSymbols
functions where tempfile
is called inside the loop over symbols. This can cause too many open file handles if download.file
fails.
Submitted by: Gabor Liptak
Assigned to: Joshua Ulrich
R-Forge link
Correct Yahoo download location
Followups:
Date: 2014-12-07 21:17
Sender: Joshua Ulrich
Fixed in r610.
Submitted by: Garrett See
Assigned to: Nobody
R-Forge link
If setDefaults
is used on a function with dots, it cannot be used normally inside another function. Instead the call must be constructed with do.call
.
setDefaults(getSymbols, src='yahoo')
g <- function(x, ...) { getSymbols(x, ...) }
g('SPY')
Error in match.call(definition = eval(parse(text = calling.fun)), call = as.call(sys.call(-1))) :
... used in a situation where it doesn't exist
This patch simply works around the problem for the attachSymbols
function by using do.call
.
Index: attachSymbols.R
===================================================================
--- attachSymbols.R (revision 582)
+++ attachSymbols.R (working copy)
@@ -58,7 +58,7 @@
if(mem.cache) {
envir <- as.environment(envir)
delayedAssign(lsym(s), {
- assign(lsym(s),getSymbols(rsym(s),auto.assign=FALSE, src=gsrc, ...), env=envir)
+ assign(lsym(s), do.call(getSymbols, rsym(s), auto.assign=FALSE, src=gsrc, ...), env=envir)
get(lsym(s), env=envir) },
assign.env=envir)
} else { # no cache
Submitted by: Edward Choh
Assigned to: Nobody
R-Forge link
getSymbols.MySQL
creates and closes a new DBI connection for each call. With heavy traffic, this will cause DBI to reach the connection limits (16) with sustained querying.
getSymbols.MySQL
should accept a conn
argument that reuses the DBI connection, instead of creating a new one each time.
Tested by fetching 1400+ symbols from MySQL back to back, throughput was greatly increased because of connection reuse.
Index: man/getSymbols.MySQL.Rd
===================================================================
--- man/getSymbols.MySQL.Rd (revision 582)
+++ man/getSymbols.MySQL.Rd (working copy)
@@ -21,6 +21,7 @@
dbname = NULL,
host = "localhost",
port = 3306,
+ conn = NULL,
...)
}
%- maybe also 'usage' for other objects documented here.
@@ -39,6 +40,7 @@
\item{dbname}{ database name }
\item{host}{ database host }
\item{port}{ database port }
+ \item{conn}{ DBI connection }
\item{\dots}{ currently not used }
}
\details{
@@ -53,6 +55,8 @@
The purpose of this abstraction is to make transparent the
\sQuote{source} of the data, allowing instead the user to
concentrate on the data itself.
+
+If conn is supplied, the other database values are unneccessary.
}
\value{
A call to getSymbols.MySQL will load into the specified
@@ -83,7 +87,7 @@
\code{\link{setSymbolLookup}} }
\examples{
\dontrun{
-# All 3 getSymbols calls return the same
+# All 4 getSymbols calls return the same
# MSFT to the global environment
# The last example is what NOT to do!
@@ -101,10 +105,15 @@
getSymbols('MSFT')
+## Method #3
+# Uses DBI connection
+conn = dbConnect('MySQL',dbname='test')
+getSymbols('MSFT',conn=conn)
+
#########################################
## NOT RECOMMENDED!!!
#########################################
-## Method #3
+## Method #4
getSymbols.MySQL('MSFT',env=globalenv())
}
}
Index: R/getSymbols.R
===================================================================
--- R/getSymbols.R (revision 582)
+++ R/getSymbols.R (working copy)
@@ -418,7 +418,7 @@
"getSymbols.MySQL" <- function(Symbols,env,return.class='xts',
db.fields=c('date','o','h','l','c','v','a'),
field.names = NULL,
- user=NULL,password=NULL,dbname=NULL,host='localhost',port=3306,
+ user=NULL,password=NULL,dbname=NULL,host='localhost',port=3306,conn=NULL,
...) {
importDefaults("getSymbols.MySQL")
this.env <- environment()
@@ -434,13 +434,18 @@
} else {
stop(paste("package:",dQuote('DBI'),"cannot be loaded."))
}
- if(is.null(user) || is.null(password) || is.null(dbname)) {
+ if(!is.null(conn)) {
+ # reusing connection
+ } else if(is.null(user) || is.null(password) || is.null(dbname)) {
stop(paste(
'At least one connection argument (',sQuote('user'),
sQuote('password'),sQuote('dbname'),
") is not set"))
}
- con <- dbConnect(MySQL(),user=user,password=password,dbname=dbname,host=host,port=port)
+ if(is.null(conn))
+ con <- dbConnect(MySQL(),user=user,password=password,dbname=dbname,host=host,port=port)
+ else
+ con <- conn
db.Symbols <- dbListTables(con)
if(length(Symbols) != sum(Symbols %in% db.Symbols)) {
missing.db.symbol <- Symbols[!Symbols %in% db.Symbols]
@@ -466,7 +471,8 @@
assign(Symbols[[i]],fr,env)
if(verbose) cat('done\n')
}
- dbDisconnect(con)
+ if(is.null(conn))
+ dbDisconnect(con)
if(auto.assign)
return(Symbols)
return(fr)
The intention of addEMA
(and all the other add*MA
functions) was to use the Close column if the data are OHLC and with.col
is not specified. The current (incorrect) behavior is to use the first column (the Open). For example:
require(quantmod)
data(sample_matrix)
x <- as.xts(sample_matrix)
m <- EMA(Cl(x))
chartSeries(x, TA=NULL)
addEMA(10)
addTA(m, on=-1, col='red')
The fix appears to be as simple as changing:
if (!is.OHLC(x) || missing(with.col))
with.col <- 1
to
if (!is.OHLC(x) && missing(with.col))
with.col <- 1
Thanks to Olivier Martin for the report, and to Jeff for confirming the original intent of the functions.
Submitted by: jim green
Assigned to: Joshua Ulrich
R-Forge link
ts<-getSplits('VGAVX',from='1990-01-01',src='yahoo',auto.assign=FALSE)
Error in[.data.frame
(fr, fr$V1 == 'SPLIT', c('V2', 'V3')) :
undefined columns selected
so the in code
before
fr <- fr[fr$V1=='SPLIT',c('V2','V3')]
Browse[2]> fr
V1 V2
1 STARTDATE 20130514
2 ENDDATE 20130717
3 TOTALSIZE 0
4 STATUS 0
there is no column V3 thus generating the error. I think we should test if fr has column V3 before running fr <- fr[fr$V1=='SPLIT',c('V2','V3')]
Followups:
Date: 2013-07-20 13:47
Sender: Joshua Ulrich
Fixed in r608.
Submitted by: Joe xx
Assigned to: Nobody
R-Forge link
Downloading files from the internet takes takes a lot of time. adjustOHLC() downloads 2 files - one for dividends and another one for splits, though getSplits() already gets a file that has both splits and dividends. It would be great if you could rewrite adjustOHLC() to download only one file.
Followups:
Date: 2014-08-21 13:24
Sender: Joshua Ulrich
While you're correct, I'm not particularly interested in spending several hours of my time to code and test your idea in order to save a few seconds of computing time for each function call. A patch with tests would be most appreciated.
Date: 2014-08-21 13:24
Sender: Joshua Ulrich
Moved from Bugs to Feature Requests
Delt
calculates arithmetic returns by default, but the "Details" section of ?Delt
says log returns are the default. Both the code and the "Arguments" section of ?Delt
indicate that arithmetic should be the default, so "Details" section of ?Delt
just needs to be corrected.
getSymbols.rda
and getSymbols.rds
both have formal col.names
arguments. This allows the user to specify the column names if they differ from the quasi-standard "OHLCVA". getSymbols.csv
should also have this argument, so users can easily import CSV data with a different number of columns.
getSymbols
strips the leading caret ("^"
) from index ticker symbols in order to return an object with a valid R name. This StackOverflow question illustrates another case that needs to be handled.
Submitted by: ivan popivanov
Assigned to: Joshua Ulrich
R-Forge link
Something simple to reproduce the problem which mimics the code in getSymbols(src='RData'):
require(quantmod)
ee = new.env()
getSymbols('SPY', env=ee, auto.assign=TRUE)
saveSymbols('SPY', '~/spy.bin', env=ee)
ll = load('spy.bin')
ll
'SPY' 'ee'
Something is messed up - we have more than one object in the saved files. The reason seems to be following call in saveSymbols:
save(list=each.symbol,
file=paste(file.path,'/',each.symbol,'.RData',sep=''),
env=env)
The last line should be:
envir=env
Followups:
Date: 2014-12-07 20:23
Sender: Joshua Ulrich
Fixed in r619.
Submitted by: Garrett See
Assigned to: Nobody
R-Forge link
If we define
thm <- chart_theme()
thm$col$bg does not seem to do anything
getSymbols('SPY', src='yahoo', from='2012-01-01', to='2012-11-01')
thm$col$bg <- 'black'
chart_Series(SPY, theme=thm) # shouldn't this have a black background?
The Exegetic Analytics blog recently wrote about Downloading Option Chain Data from Google Finance in R. For reference, I've included the function from the blog post below.
It would be nice to include something like this in quantmod, but I'm unsure about relying on the "unavailable" Google Finance API. That said, scraping the HTML also tends to be fairly unreliable, as it's prone to change.
getOptionQuotes = function(symbol) {
library(RCurl)
library(jsonlite)
library(plyr)
fixJSON = function(json){
gsub('([^,{:]+):', '"\\1":', json)
}
URL1 = 'http://www.google.com/finance/option_chain?q=%s&output=json'
URL2 = paste0(URL1, '&expy=%d&expm=%d&expd=%d')
url = sprintf(URL1, symbol)
chain = fromJSON(fixJSON(getURL(url)))
options = mlply(chain$expirations, function(y, m, d) {
url = sprintf(URL2, symbol, y, m, d)
expiry = fromJSON(fixJSON(getURL(url)))
expiry$calls$type = "Call"
expiry$puts$type = "Put"
prices = rbind(expiry$calls, expiry$puts)
prices$expiry = sprintf("%4d-%02d-%02d", y, m, d)
prices$underlying.price = expiry$underlying_price
prices$retrieved = Sys.time()
prices
})
options = options[sapply(options, class) == "data.frame"]
options = cbind(data.frame(symbol), rbind.fill(options))
options = rename(options, c(p="premium", b="bid", a="ask", oi="open.interest"))
for (col in c("strike", "premium", "bid", "ask"))
options[, col] = suppressWarnings(as.numeric(options[, col]))
options[, "open.interest"] = suppressWarnings(as.integer(options[, "open.interest"]))
col.order = c("symbol", "type", "expiry", "strike", "premium",
"bid", "ask", "open.interest", "retrieved")
options[, col.order]
}
Submitted by: Nicolas Chapados
Assigned to: Nobody
R-Forge link
The options.expiry function does not properly give expiration dates when the market happens to be closed on the 3rd Friday of a month. Consider::
getSymbols('QQQQ', src='yahoo')
QQQQ[options.expiry(QQQQ), ]
QQQQ.Open QQQQ.High QQQQ.Low QQQQ.Close QQQQ.Volume QQQQ.Adjusted
[snip]
2008-01-18 45.64 46.14 44.98 45.35 273063300 45.06
2008-02-15 43.73 43.98 43.45 43.82 100053300 43.54
2008-04-18 46.47 46.93 46.22 46.71 133022500 46.44
2008-05-16 50.07 50.11 49.45 50.01 146563200 49.73
2008-06-20 48.33 48.35 47.21 47.42 197434200 47.18
[snip]
Note that the expiration for March 2008 is missing: on that year, the third Friday of the month happened to fall on Good Friday, and the US market was closed. Hence, OpEx fell on the Thursday for that month, and the options.expiry() function SHOULD HAVE indicated 2008-03-20 as the expiration date.
Best regards,
Submitted by: Andreas Voellenklee
Assigned to: Jeff Ryan
R-Forge link
Hi, I recently installed quantmod using the command install.packages(quantmod)
The version I got installed is '0.3-17'. However, on the help page ?quantmod it claims to be version 0.3-8 from 2007-11-20.
Followups:
Date: 2014-11-01 15:48
Sender: Joshua Ulrich
Fixed in r594.
Submitted by: Hasan Diwan
Assigned to: Nobody
R-Forge link
The attached patch adds support for JDBC and a weak dependency on RJDBC, similar to the one on RMySQL, which is what the new method is based on. The RJDBC code has been independently tested and works, albeit a tad slowly, which I'm going to assume is due to RJDBC slowness, which seems to be well-known[1].
Index: pkg/R/getSymbols.R
===================================================================
--- pkg/R/getSymbols.R (revision 559)
+++ pkg/R/getSymbols.R (working copy)
@@ -315,6 +317,64 @@
}
"getSymbols.sqlite" <- getSymbols.SQLite
# }}}
+# getSymbols.JDBC {{{
+getSymbols.JDBC <- function (Symbols, env, return.class = "zoo", db.fields = c("startdate", "name", "value"), driver = 'org.postgresql.Driver', classPath='~/.m2/repository/postgresql/postgresql/9.0-801.jdbc4/postgresql-9.0.jdbc4.jar', url = 'jdbc:postgresql://localhost/erm', field.names = NULL, user = NULL, password = NULL, dbname = NULL, ...)
+{
+ this.env <- environment()
+ for (var in names(list(...))) {
+ assign(var, list(...)[[var]], this.env)
+ }
+ if (missing(verbose))
+ verbose <- FALSE
+ if (missing(auto.assign))
+ auto.assign <- TRUE
+ if ("package:DBI" %in% search() || require("DBI", quietly = TRUE)) {
+ if ("package:RJDBC" %in% search() || require("RJDBC", quietly = TRUE)) {
+ }
+ else {
+ warning(paste("package:", dQuote("RJDBC"), "cannot be loaded"))
+ }
+ }
+ else {
+ stop(paste("package:", dQuote("DBI"), "cannot be loaded."))
+ }
+ if (is.null(user) || is.null(password) || is.null(dbname)) {
+ stop(paste("At least one connection argument (", sQuote("user"),
+ sQuote("password"), sQuote("dbname"), ") is not set"))
+ }
+ drv <- JDBC(driver=driver, classPath = classPath)
+ con <- dbConnect(drv, url, user=user, password=password)
+ db.Symbols <- dbListTables(con)
+ if (length(Symbols) != sum(Symbols %in% db.Symbols)) {
+ missing.db.symbol <- Symbols[!Symbols %in% db.Symbols]
+ warning(paste("could not load symbol(s): ", paste(missing.db.symbol,
+ collapse = ", ")))
+ Symbols <- Symbols[Symbols %in% db.Symbols]
+ }
+ for (i in 1:length(Symbols)) {
+ if (verbose) {
+ cat(paste("Loading ", Symbols[[i]], paste(rep(".",
+ 10 - nchar(Symbols[[i]])), collapse = ""), sep = ""))
+ }
+ query <- paste("SELECT ", paste(db.fields, collapse = ","),
+ " FROM profiles, dists where profileid = p.id ORDER BY startdate")
+ rs <- dbSendQuery(con, query)
+ fr <- fetch(rs, n = -1)
+ fr <- xts(as.matrix(fr[, -1]), order.by = as.Date(fr[,
+ 1], origin = "1970-01-01"), src = dbname, updated = Sys.time())
+ colnames(fr) <- paste(Symbols[[i]], "Close", sep = ".")
+ fr <- convert.time.series(fr = fr, return.class = return.class)
+ if (auto.assign)
+ assign(Symbols[[i]], fr, env)
+ if (verbose)
+ cat("done\n")
+ }
+ dbDisconnect(con)
+ if (auto.assign)
+ return(Symbols)
+ return(fr)
+}
+# }}}
# getSymbols.MySQL {{{
"getSymbols.MySQL" <- function(Symbols,env,return.class='xts',
Submitted by: Mark Breman
Assigned to: Joshua Ulrich
R-Forge link
If I try to download index data from google with getSymbols() I get an error:
getSymbols('INDEXAMEX:USDUPX.X', src='google')
Error in download.file(paste(google.URL, 'q=', Symbols.name, '&startdate=', :
cannot open URL 'http://finance.google.com/finance/historical?q=INDEXAMEX:USDUPX.X&startdate=Jan+01,+2007&enddate=Aug+21,+2009&output=csv'
In addition: Warning message:
In download.file(paste(google.URL, 'q=', Symbols.name, '&startdate=', :
cannot open: HTTP status was '404 Not Found'
It looks like the url which is assembled in the function is not correct. If I try the url without the last parameter(&output=csv) in a browser, I do get a valid data series.
I'm using quantmod_0.3-10.
Regards,
-Mark-
Followups:
Date: 2014-12-07 19:39
Sender: Joshua Ulrich
I know this is an old report, but to close the loop: this is not a bug in quantmod. Note that there is no 'Download to spreadsheet' link under the chart on the right-hand side of the page. That means Google Finance does not provide a download CSV. There's nothing quantmod can do about this.
Submitted by: Paolo Cavatore
Assigned to: Nobody
R-Forge link
I just wanted to point out a likely bug in the below code when downloading prices for Lowe's Companies Inc (ticker LOW)
getSymbols('LOW', src='yahoo')
LOW.uA <- adjustOHLC(LOW, use.Adjusted=TRUE)
Error message:
Error in `-.default`(Lo(x), Cl(x)) : array incompatibili
Sounds like related to the ticker being equal to the name Low intended for the Low price.
Followups:
Date: 2013-07-18 01:49
Sender: jim green
`Lo` <-
function(x)
{
if(has.Lo(x))
return(x[,grep('Low',colnames(x),ignore.case=TRUE)])
stop('subscript out of bounds: no column name containing 'Low'')
}
the issue is here in the grep
, change 'Low' to '.Low' and it will work.
Date: 2013-07-18 02:06
Sender: Joshua Ulrich
JimGreen: Changing the pattern from 'Low' to '.Low' will cause this to break: data(sample_matrix); Lo(sample_matrix)
Date: 2013-07-21 00:52
Sender: jim green
maybe this?
`Lo` <-
function(x)
{
if(has.Lo(x)) {
#prevent LOW.Low
if(length(grep('\.',colnames(x)[[1]]))){
return(x[,grep('.Low',colnames(x),ignore.case=TRUE)])
} else {
return(x[,grep('Low',colnames(x),ignore.case=TRUE)])
}
}
stop('subscript out of bounds: no column name containing 'Low'')
}
Date: 2013-07-26 16:35
Sender: Joshua Ulrich
I think the best solution is to take advantage of the fact that the has.*()
functions first look for an attribute that matches * (e.g. has.Lo()
looks for attr(x,'Lo')
). This would require that Lo
use x[,has.Lo(x,which=TRUE)]
instead of grep()
and that getSymbols
set those column attributes. Thoughts?
Summary of a Q/A on stackoverflow: Quantmod: Error loading symbols from MySQL DB.
library(quantmod)
setDefaults(getSymbols.MySQL,user="****", password="****", dbname="quantmoddb")
getSymbols("myspy",src="MySQL")
#Error in (function (classes, fdef, mtable) :
#unable to find an inherited method for function ‘dbConnect’ for signature ‘"character"’
The db is set up correctly as the following code runs fine and returns the data set as expected.
con <- dbConnect(RMySQL::MySQL(), user="****", password="****",
dbname="quantmoddb", host="localhost", port=3306)
db.Symbols <- DBI::dbListTables(con)
query <- paste("SELECT * from myspy ORDER BY date")
rs <- DBI::dbSendQuery(con, query)
fr <- DBI::fetch(rs, n=-1)
This error is caused by the removal of the "character"
method for dbConnect
in the 0.10 release of RMySQL. Though it was not clear from the commit message nor explicitly mentioned in the release notes, it was intentional.
I do not have a MySQL database available for testing, so I would really appreciate some help from those who use this functionality. Hadley suggests the fix should be simple: switch from dbConnect("MySQL", ...)
to dbConnect(RMySQL::MySQL(), ...)
on line 614 of getSymbols.R.
Submitted by: Garrett See
Assigned to: Nobody
R-Forge link
getSymbols(c('SPY', 'DIA'), src='yahoo')
chart_Series(Cl(SPY))
thm <- chart_theme()
thm$col$line.col <- 'lightblue'
add_Series(Cl(DIA), theme=thm, on=1)
add_TA(Cl(DIA), col='green', on=1)
Submitted by: Radek Maciaszek
Assigned to: Joshua Ulrich
R-Forge link
Currently when running addOBV() (unless user will pass the closing and volume) it produces the following errors:
Error in as.xts.double(x, ..., .RECLASS = TRUE) : order.by must be either 'names()' or otherwise specified
The attached (one line) patch solves this issue.
Followups:
Date: 2013-01-20 17:21
Sender: Joshua Ulrich
Patched in r603.
The documentation says that field.names
are the "names to assign to returned columns", but that does not actually happen. It's simple enough to use the field.names
(if non-NULL) when setting the column names. Thanks to Cedrick Johnson for the suggestion/patch.
Also consider renaming field.names
to col.names
to be consistent with getSymbols.csv/rda/rds
.
Submitted by: Gang Liang
Assigned to: Joshua Ulrich
R-Forge link
Just in today, likely due to the new year's resolution of some yahoo guys, their csv file download URL is changed from 'chart.yahoo.com' to 'chart.finance.yahoo.com'. Thus, the current getSymbols function will fail.
Thanks!
Followups:
Date: 2014-01-03 02:27
Sender: Joshua Ulrich
This was already fixed in r610.
getSymbols.csv/.rda/.rds
have a col.names
argument, but they do not check if it has been specified via setSymbolLookup
. They should check for and honor values found by getSymbolLookup
.
Thanks to Daniele Signori for the suggestion.
Submitted by: Denis Kolodin
Assigned to: Nobody
R-Forge link
When I call getSymbols('MSFT',src='MySQL', db.fields = c('timestamp', 'open', 'high', 'low', 'close', 'volume', 'adjust')) it make query:
SELECT timestamp, open, high, low, close, volume, adjust FROM my_table ORDER BY (!)date(!);
I change code that generates query to:
query <- paste('SELECT ', paste(db.fields, collapse = ','),
' FROM ', Symbols[[i]], ' ORDER BY ', db.fields[1])
Maybe fix it in library?!
Submitted by: Garrett See
Assigned to: Joshua Ulrich
R-Forge link
'time.format' should be 'timeFormat'
Patch attached.
Followups:
Date: 2014-12-07 21:29
Sender: Joshua Ulrich
Merged in r621.
Submitted by: Daniele Signori
Assigned to: Nobody
R-Forge link
This patch adds lookup handling of the arument col.names
for getSymbols.rds
and getSymbols.rda
. Moreover, if col.names = NA
is passed, then the column names as saved in the rda/rds/rdata files are used. See diff below.
Index: pkg/R/getSymbols.R
===================================================================
--- pkg/R/getSymbols.R (revision 611)
+++ pkg/R/getSymbols.R (working copy)
@@ -687,6 +687,7 @@
default.return.class <- return.class
default.dir <- dir
default.extension <- extension
+ default.col.names <- col.names
if(missing(verbose)) verbose <- FALSE
if(missing(auto.assign)) auto.assign <- TRUE
@@ -701,6 +702,10 @@
extension <- getSymbolLookup()[[Symbols[[i]]]]$extension
extension <- ifelse(is.null(extension),default.extension,
extension)
+
+ col.names <- getSymbolLookup()[[Symbols[[i]]]]$col.names
+ col.names <- if(is.null(col.names)) default.col.names else col.names
+
if(verbose) cat("loading ",Symbols[[i]],".....")
if(dir=="") {
sym.file <- paste(Symbols[[i]],extension,sep=".")
@@ -717,6 +722,7 @@
if(verbose)
cat("done.\n")
if(!is.xts(fr)) fr <- xts(fr[,-1],as.Date(fr[,1],origin='1970-01-01'),src='rda',updated=Sys.time())
+ if(is.na(col.names)) col.names <- colnames(fr) # if NA, use original colnames
colnames(fr) <- paste(toupper(gsub('\\^','',Symbols[[i]])),col.names,sep='.')
fr <- convert.time.series(fr=fr,return.class=return.class)
Symbols[[i]] <-toupper(gsub('\\^','',Symbols[[i]]))
@@ -746,7 +752,8 @@
default.return.class <- return.class
default.dir <- dir
default.extension <- extension
-
+ default.col.names <- col.names
+
if(missing(verbose)) verbose <- FALSE
if(missing(auto.assign)) auto.assign <- TRUE
@@ -760,6 +767,10 @@
extension <- getSymbolLookup()[[Symbols[[i]]]]$extension
extension <- ifelse(is.null(extension),default.extension,
extension)
+
+ col.names <- getSymbolLookup()[[Symbols[[i]]]]$col.names
+ col.names <- if(is.null(col.names)) default.col.names else col.names
+
if(verbose) cat("loading ",Symbols[[i]],".....")
if(dir=="") {
sym.file <- paste(Symbols[[i]],extension,sep=".")
@@ -777,7 +788,8 @@
if(verbose)
cat("done.\n")
if(!is.xts(fr)) fr <- xts(fr[,-1],as.Date(fr[,1],origin='1970-01-01'),src='rda',updated=Sys.time())
- colnames(fr) <- paste(toupper(gsub('\\^','',Symbols[[i]])),col.names,sep='.')
+ if(is.na(col.names)) col.names <- colnames(fr) # if NA, use original colnames
+ colnames(fr) <- paste(toupper(gsub('\\^','',Symbols[[i]])), col.names, sep='.')
fr <- convert.time.series(fr=fr,return.class=return.class)
Symbols[[i]] <-toupper(gsub('\\^','',Symbols[[i]]))
if(auto.assign)
Submitted by: Garrett See
Assigned to: Nobody
R-Forge link
If you have a vector named 'col' and you try to call add_TA() with one of the
values in your 'col' vector other than the first one, the TA will not be
plotted.
x <- .xts(cbind(Bid=1:5, Ask=2:6), 1:5)
Bid <- x[, 1]
Ask <- x[, 2]
Mid <- (x[, 1] + x[, 2]) / 2
col <- c('blue', 'red')
chart_Series(Mid)
add_TA(Bid, on=1, col=col[1]) # this works fine
add_TA(Ask, on=1, col=col[2]) # does not draw the line
a <- c('blue', 'red')
chart_Series(Mid)
add_TA(Bid, on=1, col=a[1])
add_TA(Ask, on=1, col=a[2]) # works; draws a red line
?getSymbols
should include an example of the "canonical" way to work with multiple symbols returned by getSymbols
. This will become more important in version 0.5.0, when the auto.assign
default will change from TRUE
to FALSE
.
A good starting point would be Jeff's answer on StackOverflow, but it would be nice to have one or two examples that are a bit more complicated.
Submitted by: Wouter Thielen
Assigned to: Joshua Ulrich
R-Forge link
There is a different R package called RFinanceYJ:
https://code.google.com/p/rfinanceyj/
It does not work. There are some issues. I checked its source code, and have thought about improving it, and adding it to your more global quantmod package.
For reference, my current stock information download code, which is in PHP, is on github:
https://github.com/wthielen/YJStocks/blob/master/download-stocks
I'd like to see a getSymbols.YahooJ function in quantmod. Let me know if I can help.
Followups:
Date: 2014-12-13 10:30
Sender: Wouter Thielen
OK cool! Looking forward to that release then. Thanks for adding my code!
Date: 2014-12-13 01:05
Sender: Joshua Ulrich
I made a few minor adjustments and committed your changes in r624. I'm not going to include this in the package I send to CRAN in a couple days, because of a couple items:
I expect to make another CRAN submission in 2-3 months, once I'm able to fully fix the getOptionChain.yahoo function. I will include these changes at that time.
With the addition of your code, I'm closing this request. Thanks for your contribution!
Date: 2014-12-12 15:12
Sender: Wouter Thielen
Please see the YahooJ.zip attachment. I have included:
If you examine the .diff file, you'll also see that there is an addition of XML to pkg/DESCRIPTION's 'Suggests:' line, so please do not forget this one.
Some ticker symbols you can use to test:
I haven't tested with currency symbols (USDJPY=X) and other funny stuff (^GSPC, ^IXIC) yet. I believe most people would use the US Yahoo for that anyway.
Date: 2014-12-11 14:28
Sender: Wouter Thielen
Just updated the Rd file, and noticed that I need to change some stuff a bit. Yahoo Japan tickers start with a number, and I actually store them in the environment by pasting 'YJ' in front of it. However, getSymbolLookup and setSymbolLookup don't work well with these, so I have to update the code a bit, and actually have people add 'YJ' in front of their Japanese tickers, so that getSymbols can do a proper lookup.
This will be explained in the Rd file as well.
If you have a better idea, please let me know.
Date: 2014-12-10 15:07
Sender: Joshua Ulrich
Thanks for the update. That timing works great. I aiming to push quantmod to CRAN early next week, and it would be nice to include this. I'd also appreciate any testing you could do on the revision you just checked out.
Date: 2014-12-10 15:05
Sender: Wouter Thielen
Update: I actually did a svn checkout, and the visible global definition stuff disappeared indeed on the others. I'll check out the MySQL one, edit the Rd file, and send you a svn diff/patch tomorrow or something (past midnight here now). Does that work for you?
Date: 2014-12-10 15:01
Sender: Joshua Ulrich
Don't worry about the newlines. They appear in the emails I receive.
There should not longer be any 'no visible global definition for ' notes in the latest revision. Look at getSymbols.MySQL for an example of how to require(XML) and avoid the notes. XML will need to be added to the Suggests list, so running with R_CHECK_FORCE_SUGGESTS=0 might not be the best idea... but I will do that, so don't worry about it if it's a large hassle for you.
Copying and editing man/getSymbols.yahoo.Rd should be fine. You can simply attach the files to this ticket.
Thanks!
Date: 2014-12-10 14:55
Sender: Wouter Thielen
Cripes! Does this site not do a nl2br()?! Hope you can read the comment without newlines...
Date: 2014-12-10 14:54
Sender: Wouter Thielen
Fixed this one at least.
I see notes though, about 'no visible global definition for htmlParse' for example. I see these notes in other getSymbols.* functions as well such as functions definitions for dbSendQuery etc.
Couple of questions:
Date: 2014-12-10 08:51
Sender: Wouter Thielen
Cool. Just looked up on .Rd files and the CMD check, and will do these this week, and fix any issues that may arise.
Date: 2014-12-07 22:53
Sender: Joshua Ulrich
I think this could be included in quantmod, but it will need a .Rd file and I'm not sure that the Japanese characters in the function on your GitHub account will pass R CMD check. Can you create a .Rd file and see if your function passes check?
Submitted by: Marc Sherry
Assigned to: Joshua Ulrich
R-Forge link
Presumably due to the symbol's name and the grep used to find columns to adjust, adjustOHLC chokes on the symbol 'LOW'.
getSymbols('LOW')
[1] 'LOW'
adjustOHLC(LOW, use.Adjusted = T)
Error in-.default
(Lo(x), Cl(x)) : non-conformable arrays
Followups:
Date: 2014-06-29 17:14
Sender: Joshua Ulrich
Yes, so I'm going to close this one in order to keep comments about this issue from being distributed across multiple bug reports.
Date: 2014-06-29 17:11
Sender: Marc Sherry
I see that this is a duplicate of #2165, from back in 2012.
None of the Oanda data feeds appear to be working.
On the other hand, Yahoo has FX data now, so that could be incorporated.
A demonstration project that accumulates EOD data, Dividends, and Financials would be of great interest to most investors, particularly if it had automated data updates. It would save reinventing that particular wheel.
Rant:
The database connection is not well documented. One should be able to set up the database connection. Similarly pointers to the return types of the data elements would be helpful to someone not familiar with the basis for the package. When documentation requires searching the source code to figure out what to do it is not really documentation. It is just a polite but inadequate source of frustration.
Submitted by: Jonathan Flint
Assigned to: Nobody
R-Forge link
This patch adds an option to chartSeries
which allows the default behaviour with regard to removing NAs to be changed. The default is to remove NAs (na.omit
behaviour); this change would allow for na.omit = FALSE
to be explicitly set.
This is useful for cases where data gaps should be graphically represented.
Index: pkg/R/chartSeries.R
===================================================================
--- pkg/R/chartSeries.R (revision 611)
+++ pkg/R/chartSeries.R (working copy)
@@ -378,7 +378,7 @@
major.ticks='auto',minor.ticks=TRUE,
yrange=NULL,
plot=TRUE,
- up.col,dn.col,color.vol=TRUE,multi.col=FALSE,...
+ up.col,dn.col,color.vol=TRUE,multi.col=FALSE, na.omit=TRUE,...
) {
#sys.TZ <- Sys.getenv('TZ')
#Sys.setenv(TZ='GMT')
@@ -386,9 +386,9 @@
#if(!is.xts(x)) x <- as.xts(x)
x <- try.xts(x, error='chartSeries requires an xtsible object')
-
- x <- na.omit(x)
-
+ if(na.omit==TRUE){
+ x <- na.omit(x)
+ }
indexClass(x) <- "POSIXct"
if(!is.null(subset) & is.character(subset)) {
It looks like OANDA updated it's URL and page structure which has broken getFX where it is returning a 404 error.
step:
I read the code of getSymbols.csv and found the line
fr <- xts(fr[,-1], as.Date(fr[,1], format=format, origin='1970-01-01'), src='csv', updated=Sys.time())
when format is '', the fr will have wrong date index.
I suggest the default value of format should be set as '%Y-%m-%d' , rather than ''.
thanks.
rick
Submitted by: ivan popivanov
Assigned to: Nobody
R-Forge link
require(quantmod)
spy = getSymbols('SPY',auto.assign=F)
spy.weekly = to.weekly(spy, indexAt='endof')
spy.wrets = na.trim( ROC( Cl( spy.weekly ) ) )
spy.lr1 = na.trim( lag( spy.wrets, k=1 ) )
spy.lr2 = na.trim( lag( spy.wrets, k=2 ) )
spy.mm = merge( spy.lr1, spy.lr2, all=F )
NROW(spy.lr1[index(spy.mm)]) # result is 0
attributes(attr(last(spy.lr1), 'index')) # result is NULL
spy.rets = na.trim( ROC( Cl( spy ) ) )
spy.lr1 = na.trim( lag( spy.rets, k=1 ) )
spy.lr2 = na.trim( lag( spy.rets, k=2 ) )
spy.mm = merge( spy.lr1, spy.lr2, all=F )
NROW(spy.lr1[index(spy.mm)]) # result is greater than 0
attributes(attr(last(spy.lr1), 'index')) # result is two attributes, tzone and tclass
The last two lines in the output are different. I suspect that the strange behaviour in the weekly data is because the attributes of the index were dropped.
Followups:
Date: 2013-02-03 05:03
Sender: Jeff Ryan
This was actually a regression issue in xts. Patched as of version 768 due to this report. Closing as invalid as it isn't quantmod, but the report was very useful. Thanks!
Submitted by: Joshua Ulrich
Assigned to: Joshua Ulrich
R-Forge link
The function returned by newTA does not work without the ::: operator to access the unexported get.current.chob() function.
Followups:
Date: 2014-12-07 20:25
Sender: Joshua Ulrich
Fixed in r613 and r615.
Submitted by: Garrett See
Assigned to: Nobody
R-Forge link
This fixes the problem mentioned by Darren Cook at http://stackoverflow.com/a/11174404/967840.
There's one place in chart_Series
where axTicksByTime
is used instead of axTicksByTime2
. If you change to axTicksBytime2
and then add support for quarterly data in axTicksByTime2.R
, the chart is pretty.
Patch below:
Index: R/axTicksByTime2.R
===================================================================
--- R/axTicksByTime2.R (revision 582)
+++ R/axTicksByTime2.R (working copy)
@@ -6,8 +6,8 @@
x <- xts(rep(1, length(x)), x)
#tick.opts <- c("years", "months", "days", "hours",
# "minutes", "seconds")
- tick.opts <- c("years", "months", "weeks", "days")
- tick.k.opts <- c(1,1,1,1)
+ tick.opts <- c("years", "quarters", "months", "weeks", "days")
+ tick.k.opts <- c(1,1,1,1,1)
if (ticks.on %in% tick.opts) {
cl <- ticks.on[1]
ck <- k
@@ -43,6 +43,7 @@
#fmt <- ifelse(unix, "%n%b%n%Y", "%b %Y")
fmt <- switch(cl,
"years"="%Y",
+ "quarters"="%Y Q%q",
"months"="%b",
"days"="%d",
"weeks"="W%W",
Index: R/chart_Series.R
===================================================================
--- R/chart_Series.R (revision 582)
+++ R/chart_Series.R (working copy)
@@ -300,7 +300,7 @@
{axis(1,at=1:NROW(xdata[xsubset]),labels=FALSE,col=theme$grid2,tcl=0.3)}),expr=TRUE)
# add "month" or "month.abb"
- cs$add(expression(axt <- axTicksByTime(xdata[xsubset],format.labels=format.labels),
+ cs$add(expression(axt <- axTicksByTime2(xdata[xsubset],format.labels=format.labels),
axis(1,at=axt, #axTicksByTime(xdata[xsubset]),
labels=names(axt), #axTicksByTime(xdata[xsubset],format.labels=format.labels)),
las=1,lwd.ticks=1,mgp=c(3,1.5,0),tcl=-0.4,cex.axis=.9)),
Submitted by: Brian Wagener
Assigned to: Joshua Ulrich
R-Forge link
I'm guessing that Yahoo changed something today, such that the parsing no longer works. The source of the problem is the line opt <- opt[grep('Expire at',opt)], which 'Expire at' no longer shows up in page. But since there is no results opt becomes empty, and is what is parsed.
Followups:
Date: 2014-12-13 01:12
Sender: Joshua Ulrich
Partially fixed in r625.
Date: 2014-10-28 12:41
Sender: Joshua Ulrich
To respond to your comments:
Thanks for the feedback! And patches are most welcome.
Date: 2014-10-28 12:32
Sender: Brian Wagener
So a few comments:
Date: 2014-10-26 00:06
Sender: Joshua Ulrich
I've attached a potential solution (getOption.R), but I'm hesitant to add a dependency on XML. Adding it as a Suggests might be a viable alternative. I'd also appreciate feedback because I'm not familiar with how the function is supposed to work.
Submitted by: g sc
Assigned to: Joshua Ulrich
R-Forge link
There is one sign error in the implementation of findValleys() function.
The fix is very easy as shown in :
xgdgsc/quantmod@bcb0dc9
And I hope the development of quantmod be moved to Github, the interface and visibility is much better. And I hope you release to CRAN more often.
Followups:
Date: 2014-12-07 21:13
Sender: Joshua Ulrich
Fixed in r620.
Currently getSymbols.csv
only handles date-based indexes (it calls as.Date
on the first column in the csv file). It would be nice to be able to read intraday data from CSV.
The first step would be to allow the user to call a function other than as.Date
on the first column of the CSV. Then it might be nice to support CSV layouts where the date and time are in different columns (e.g. this question stackoverflow).
Note that read.zoo
might provide some useful insight how to handle both of these cases.
Submitted by: Dmi Imd
Assigned to: Joshua Ulrich
R-Forge link
adjustOHLC() misses adjustments for data before 1970-01-01, as it doesn't have a 'from' argument, so getDividends()'s getSplits()'s default from='1970-01-01' is used and all dividends and splits before 1970-01-01 are ignored. Please add a 'from' argument to adjustOHLC() or at least change this part of adjustOHLC():
div <- getDividends(symbol.name)
splits <- getSplits(symbol.name)
for:
div <- getDividends(symbol.name, from='1950-01-01')
splits <- getSplits(symbol.name, from='1950-01-01')
Followups:
Date: 2014-05-19 10:26
Sender: Joshua Ulrich
Fixed in r611.
Submitted by: Evelyn Mitchell
Assigned to: Joshua Ulrich
R-Forge link
*** quantmod-package.Rd 2013-03-31 12:35:33.994495160 -0600
--- quantmod-package.Rd.orig 2013-03-31 12:35:20.030493696 -0600
*** 19,24 ****
--- 19,25 ----
Suggests: \tab DBI,RMySQL,TTR,fSeries,its\cr
LazyLoad: \tab yes\cr
License: \tab GPL-3\cr
*** DESCRIPTION 2013-03-31 12:37:05.082512448 -0600
--- DESCRIPTION.orig 2013-03-31 12:36:45.430508042 -0600
*** 10,13 ****
Description: Specify, build, trade, and analyse quantitative financial trading strategies
LazyLoad: yes
License: GPL-3
! URL: http://r-forge.r-project.org/projects/quantmod
--- 10,13 ----
Description: Specify, build, trade, and analyse quantitative financial trading strategies
LazyLoad: yes
License: GPL-3
! URL: http://www.quantmod.com http://r-forge.r-project.org/projects/quantmod
Followups:
Date: 2014-12-07 22:31
Sender: Joshua Ulrich
This has always worked for me (except for a few rare occasions), so I'm rejecting and closing.
Submitted by: Radek Maciaszek
Assigned to: Joshua Ulrich
R-Forge link
To replicate:
install.packages('quantmod', repos='http://r-forge.r-project.org')
m <- getFinancials('MMM')
Warning message:
In readLines(tmp) :
incomplete final line found on '/tmp/Rtmpx3fWOf/file461821442a0b'
m
[1] 'MMM.f'
viewFin(m)
Error in viewFin(m) : ‘x’ must be of type ‘financials’
I've tried this in both windows and linux, versions from both the r-forge and cran.
Followups:
Date: 2013-01-20 17:26
Sender: Joshua Ulrich
As Garrett See said, this is expected behavior, therefore not a bug.
Date: 2012-11-24 00:24
Sender: Radek Maciaszek
This warning message made me think something is just wrong with parsing of the answer, plus the variable was created which confused me further but it actually works after setting the auto.assign! Thanks a lot.
Any way to eliminate that warning? Maybe we should append empty line to the file before storing it?
Date: 2012-11-23 20:52
Sender: Garrett See
This is expected behavior. getFinancials() is similar to getSymbols() in that it has an auto.assign argument that is TRUE by default. So, when you assign the results of your call to m, you are really just assigning the name of the object that was assigned in the .GlobalEnv. Then, you are calling viewFin() with m which is 'character', not 'financials'
Here are 2 solutions:
m <- getFinancials('MMM', auto.assign=FALSE)
viewFin(m)
getFinancials('MMM')
viewFin(MMM.f)
Date: 2012-11-20 10:01
Sender: Radek Maciaszek
The same issue was reported here:
https://stat.ethz.ch/pipermail/r-sig-finance/2012q1/009631.html
Is there any way to get historical oil (WTI, Brent) prices with quantmod
? Any hint, may be? (yes, I know that futures are traded in contracts by months...)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.