Re: [R] Download multiple stock quotes in a loop

2007-07-26 Thread Vladimir Eremeev



Owe Jessen wrote:
> 
> Hi all,
> 
> this should be a simple question, but I haven't been able to do it 
> right. I am trying to download multiple stock quotes in a loop, so that 
> every timeseries is safed with the symbol of the stock. Can anybody help 
> me out? Here's the code:
> 
> require(tseries)
> startd <- "2000-06-01"
> stocks <- c("bmw.de", "vow.de", "dte.de")
> for(stock in stocks)
> stock <- as.timeSeries(get.hist.quote(instrument=stock, start=startd, 
> quote="Close", compress="d"))
> }
> 
> Thanks in advance,
> Owe
> 

The variable stock is assigned values twice in the cycle.
First, it gets the value of "bmw.de", and immediately after that it is
assigned with the result returned by as.timeSeries(  ... )

If you replace the interior of the loop with the

  assign(paste("stock.",stock,sep=""), as.timeSeries(get.hist.quote  [etc]))

you will get three variables, namely, stock.bmw.de, stock.vow.de and
stock.dte.de.
-- 
View this message in context: 
http://www.nabble.com/Download-multiple-stock-quotes-in-a-loop-tf4150838.html#a11808177
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch 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.


[R] Download multiple stock quotes in a loop

2007-07-26 Thread Owe Jessen
Hi all,

this should be a simple question, but I haven't been able to do it 
right. I am trying to download multiple stock quotes in a loop, so that 
every timeseries is safed with the symbol of the stock. Can anybody help 
me out? Here's the code:

require(tseries)
startd <- "2000-06-01"
stocks <- c("bmw.de", "vow.de", "dte.de")
for(stock in stocks)
stock <- as.timeSeries(get.hist.quote(instrument=stock, start=startd, 
quote="Close", compress="d"))
}

Thanks in advance,
Owe

-- 
Owe Jessen
Diplom-Volkswirt
Hanssenstraße 17
24106 Kiel

[EMAIL PROTECTED]
http://www.econinfo.de

__
R-help@stat.math.ethz.ch 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.