On Mar 13, 2011, at 12:18 AM, algotr8der wrote:

Thanks David for the reply. I just tried the following with the same result:

library(tseries)
tickers <- read.csv("testticker.txt", header=FALSE, sep=",")
tickers <- tickers[1]
    V1
1   XOM
2   COP
3 PBR-A
4  FFIV
5    SU
6 PBR-B


tickers$V1 <- as.character(tickers$V1)
tickers$V1
[1] "XOM"   "COP"   "PBR-A" "FFIV"  "SU"    "PBR-B"

symbols <- tickers$V1
symbols
[1] "XOM"   "COP"   "PBR-A" "FFIV"  "SU"    "PBR-B"

stockdata <- data.frame()
stockdata <- coredata(get.hist.quote(instruments=symbols,
start="2011-01-01", end="2011-01-31", quote=c("Close"), provider="yahoo"))
Error in get.hist.quote(instruments = symbols, start = "2011-01-01", end =
"2011-01-31",  :
 unused argument(s) (instruments = symbols)

You might want to look more closely at:

?get.hist.quote

Note the name of the first argument .... and then note that it does not say "names" but only a "name" would be accepted as a value to that argument.

stockdata <- coredata(get.hist.quote(instrument=symbols,
+ start="2011-01-01", end="2011-01-31", quote=c("Close"), provider="yahoo"))
trying URL 
'http://chart.yahoo.com/table.csv?s=XOM&a=0&b=01&c=2011&d=0&e=31&f=2011&g=d&q=q&y=0&z=XOM&x=.csv'
Content type 'text/csv' length unknown
opened URL
.
downloaded 1042 bytes

time series starts 2011-01-03
Warning message:
In download.file(url, destfile, method = method, quiet = quiet) :
  only first element of 'url' argument used

(So this is telling you that get.hist.quote did not accept a vector of characters.)

You should be thinking about what data structure you want to work with. A dataframe does not seem like a good choice to me. I would be thinking of a list.

res <- lapply(symbols[1:5], get.hist.quote, start="2011-01-01", end="2011-01-31", quote=c("Close"), provider="yahoo")
names(res) <- symbols[1:5]

The examples suggested that a 'merge' operation might also be used. Perhaps you should be looking for a vignette that shows how to assemble a "portfolio" of timeseries.

--

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to