[R-sig-Finance] Problem using merge with a loop and get.hist.quote

Gabor Grothendieck ggrothendieck at gmail.com
Sun Jun 4 09:00:22 CEST 2006


zoo has a function called index and by using a variable called
index the code gets confused.

Use another name.

On 6/4/06, Michael Cohen <michaelbcohen at gmail.com> wrote:
> I have a problem trying to use a loop structure to download prices from
> Yahoo.
> When I try the following code segment:
>
> library(tseries)
> # Initialize price vector
> prices <- get.hist.quote("^dji", start = "2006-01-01", compress = "m")[,
> "Close"]
> # Now download individual securities
> indices <- c("OEX", "IXIC")
> for (index in indices)
>  {
>    symbol = paste("^", index, sep="")
>    p <-  get.hist.quote(symbol, start = "2006-01-01", compress = "m")[,
> "Close"]
>    prices <- merge(prices, p, all = FALSE)
>  }
>
> I get the error message:
> "Error in get(x, envir, mode, inherits) : variable "OEX" of mode "function"
> was not found".
>
> The prices for the first item in the index series appears to be downlaoded
> correctly, but the "merge" fails?
>
> I have a lot of equities to process, so doing it by hand would be very
> unpleasant.
> Any help wold be appreciated.
> (As you might have guessed, I am not a programmer!)
>
> Michael.
>
> --
> Michael B Cohen
> Southern Cross University
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>



More information about the R-SIG-Finance mailing list