Hello,
How are you calling your function? Can you show us the actual code?
I am testing it like the following.
apnd(list("IBM"))
Error in
download.file(paste("https://finance.yahoo.com/d/quotes.csv?s=", :
cannot open URL
'https://finance.yahoo.com/d/quotes.csv?s=IBM&f=d1t1l1c1p2ohgv'
In addition: Warning message:
In download.file(paste("https://finance.yahoo.com/d/quotes.csv?s=", :
InternetOpenUrl failed: 'N?o foi poss?vel processar o nome ou o
endere?o do servidor'
So it's a server error. Note that getSymbols("IBM") works as
expected.
Hope this helps,
Rui Barradas
On 1/7/2018 12:29 PM, akshay kulkarni wrote:> dear members,
>
> I am using quantmod to work with stock
prices...
>
>
> I am trying to append the data got from getQuote to the one got by
getSymbols. The function is named "apnd". The code is as follows:
>
>
> function(x){
> if ((class(x) == "xts") || (class(x) ==
"zoo")){
> sym <- deparse(substitute(x))
> y <- getQuote(sym)
> # convert to xts
> y1 <- y[,-c(3,4)]
> y2 <- y1[,c("Trade
Time","Open","High","Low","Last","Volume")]
> yxts <- xts(y2[, -1], as.Date(y2[, 1]))
> yxts$Adjusted <- yxts[, 'Last']
> return(rbind(x, yxts))
>
> }
> if(class(x) == "list"){
> for(j in 1:length(x)){
> sym <- deparse(substitute(x[[j]]))
> y <- getQuote(sym)
> # convert to xts
> y1 <- y[,-c(3,4)]
> y2 <- y1[,c("Trade
Time","Open","High","Low","Last","Volume")]
> yxts[[j]] <- xts(y2[, -1], as.Date(y2[, 1]))
> yxts[[j]]$Adjusted <- yxts[[j]][, 'Last']
> yxts[[j]] <- rbind(x[[j]], yxts[[j]])
> }
> return(yxts)
> }
> }
>
> the part with class == xts or zoo is working fine. However, the part with
class == list is not working. The point is, instead of running apnd for each
stock, I create the list of stock names and run apnd with a for loop. However it
is not working.
>
>
> Any help will be highly appreciated
>
> Very many thanks for your precious time..
>
>
> yours sincerely,
>
> AKSHAY M KULKARNI
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>