Commit 6dfa7d0e authored by Dirk Eddelbuettel's avatar Dirk Eddelbuettel

Import Upstream version 0.10-33

parent 1fba4279
2015-02-10 Kurt Hornik <Kurt.Hornik@wu.ac.at>
* DESCRIPTION (Version): New version is 0.10-33.
* R/finance.R: Change get.hist.quote() to use new oanda URL and
file format.
2013-05-07 Adrian Trapletti <adrian@trapletti.org>
* DESCRIPTION (Version): New version is 0.10-32.
......
Package: tseries
Version: 0.10-32
Title: Time series analysis and computational finance
Authors@R: c(person("Adrian", "Trapletti", role = "aut", email =
"adrian@trapletti.org"), person("Kurt", "Hornik", role =
c("aut", "cre"), email = "Kurt.Hornik@R-project.org"),
person("Blake", "LeBaron", role = "ctb", comment = "BDS test
code"))
Description: Package for time series analysis and computational finance
Version: 0.10-33
Title: Time Series Analysis and Computational Finance
Authors@R: c(person("Adrian", "Trapletti", role = "aut",
email = "adrian@trapletti.org"),
person("Kurt", "Hornik", role = c("aut", "cre"),
email = "Kurt.Hornik@R-project.org"),
person("Blake", "LeBaron", role = "ctb",
comment = "BDS test code"))
Description: Time series analysis and computational finance.
Depends: R (>= 2.10.0)
Suggests: its
Imports: graphics, stats, utils, quadprog, zoo
License: GPL-2
Packaged: 2013-05-13 14:34:48 UTC; hornik
Author: Adrian Trapletti [aut], Kurt Hornik [aut, cre], Blake LeBaron
[ctb] (BDS test code)
Packaged: 2015-02-10 17:08:32 UTC; hornik
Author: Adrian Trapletti [aut],
Kurt Hornik [aut, cre],
Blake LeBaron [ctb] (BDS test code)
Maintainer: Kurt Hornik <Kurt.Hornik@R-project.org>
NeedsCompilation: yes
Repository: CRAN
Date/Publication: 2013-05-13 17:06:23
Date/Publication: 2015-02-10 18:36:00
15a4bd5b3846c6a61657346c7c97c185 *ChangeLog
6178a924f1c07d74a6eae52f8adb9f5f *DESCRIPTION
3ae2c49c0af60b42d01326ac5ca7494a *ChangeLog
5d1beb0908b7a8f1a427b8ccfb852791 *DESCRIPTION
2b3f182ac38fa94b06b0950bda63e2a1 *NAMESPACE
434cfb7f2cdc1fe1cab1922e3fb0e3d8 *R/arma.R
aba45885115ec20161ec3292223d0c8d *R/finance.R
07854a9470314f8e61d437c7949db01a *R/finance.R
f3d8df961e5a15c7e356a4566424e175 *R/garch.R
decf4a3134c069cf9d2dbc79b1b60706 *R/irts.R
d8a4828240a6352c63178d67daa65578 *R/test.R
ebc29d93799680f40e284960a8cd6950 *R/tsutils.R
6474314852bc0951b0cc3848febd98dc *R/zzz.R
e311649f01da4c522be8ff61cb4776a2 *README
50675eb730e7958562b9e2296e17086e *data/NelPlo.rda
3133f915ede00127ef4477d99ebc4a5b *data/USeconomic.rda
8376a1b77cc2abb1f04aebd8319d0aaa *data/bev.rda
863ab9ac7e339d5e85044cc58b8842e1 *data/camp.rda
87e2e66b5b3220cb7c8099e5ba931817 *data/ice.river.rda
b7624773702469d45d1003b304a795c3 *data/nino.rda
712ba5c8d17ea6ac6d4a33cc901ed437 *data/tcm.rda
7442f9f913b8abd03725d8e9dc87df81 *data/tcmd.rda
91fa46397d86167e3f3926c1f2f3dc3f *data/NelPlo.rda
7e3faf636934281212b7f0351b3ed3ec *data/USeconomic.rda
1a9709960dbaeb468c3b547df5cf3801 *data/bev.rda
831a3fbf581a28692dedebc80a5cdd53 *data/camp.rda
39f65d85f651da97f012ff025db90804 *data/ice.river.rda
4ffc1491121b0a99f7aa77f53f68d0c2 *data/nino.rda
792f2265f349c74e42d2c4e23e321562 *data/tcm.rda
53aa0486adca273a99e78cacc6b04f20 *data/tcmd.rda
ee522e5be7a4a8f15d449a342342c1f2 *inst/CITATION
39c832867f0093af08dba56ed7c89504 *man/NelPlo.Rd
a3fd00105442c79dbe9d8097b5877f40 *man/USeconomic.Rd
......
......@@ -275,18 +275,27 @@ function (instrument = "^gdax", start, end,
if(!missing(compression)) {
warning("argument 'compression' ignored for provider 'oanda'")
}
url <-
paste("http://www.oanda.com/convert/fxhistory?lang=en&date1=",
format(start, "%m"), "%2F", format(start, "%d"), "%2F", format(start, "%y"),
"&date=",
format(end, "%m"), "%2F", format(end, "%d"), "%2F", format(end, "%y"),
"&date_fmt=us&exch=",
unlist(strsplit(instrument, split = "/"))[1],
"&exch2=&expr=",
unlist(strsplit(instrument, split = "/"))[2],
"&expr2=&margin_fixed=0&&SUBMIT=Get+Table&format=ASCII&redirected=1",
sep="")
currencies <- unlist(strsplit(instrument, split = "/"))
ranges <- c("d7", "d30", "d60", "d90", "d180", "y1", "y2", "y5")
range <- ranges[c(7, 30, 60, 90, 180, 364, 728, 1820) >=
difftime(end, start, units="days")][1]
url <- paste0("http://www.oanda.com/currency/historical-rates/download?",
"quote_currency=", currencies[1],
"&end_date=", end,
"&start_date=", start,
"&period=daily",
"&display=absolute",
"&rate=0",
"&data_range=", range,
"&price=mid",
"&view=table",
"&base_currency_0=", currencies[2],
"&base_currency_1=",
"&base_currency_2=",
"&base_currency_3=",
"&base_currency_4=",
"&download=csv")
destfile <- tempfile()
status <- download.file(url, destfile, method = method, quiet = quiet)
......@@ -295,32 +304,11 @@ function (instrument = "^gdax", start, end,
stop(paste("download error, status", status))
}
x <- readLines(destfile, warn = quiet)
x <- read.csv(destfile, skip = 4, as.is = TRUE, header = TRUE)
unlink(destfile)
x <- head(x, -3)
if(length(grep("Sorry", x)) > 0) {
msg <- unlist(strsplit(gsub("<[a-zA-Z0-9\\/]*>", "", x[grep("Sorry", x)]), split = " "))
msg <- paste(msg[msg != ""], collapse = " ")
stop("Message from Oanda: ", msg)
}
## This used to have
## first <- which(substr(x, 1, 5) == "<PRE>")
## last <- which(x == "</PRE>") - 1
## but at least on 2007-11-04 we had an instance of <PRE> not
## being at the beginning of a line and </PRE> not being on a
## line of its own ...
first <- grep("<PRE>", x, fixed = TRUE)
last <- grep("</PRE>", x, fixed = TRUE) - 1
if((length(first) != 1) || (length(last) != 1) || (last < first)) {
stop(paste("no data available for", instrument))
}
x[first] <- sub(".*<PRE>", "", x[first])
con <- textConnection(x[first:last])
on.exit(close(con))
x <- scan(con, what = list(character(), double()), quiet = TRUE)
dat <- as.Date(x[[1]], format = "%m/%d/%Y")
dat <- as.Date(x[[1]])
n <- length(dat)
if(!quiet && (dat[1] != start))
cat(format(dat[1], "time series starts %Y-%m-%d\n"))
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment