Re: [R] pass character vector in instrument field of get.hist.quote function

From: Joshua Ulrich <josh.m.ulrich_at_gmail.com>
Date: Sun, 13 Mar 2011 14:11:15 -0500

Sorry for the late reply. Here's another approach using quantmod::getSymbols. It implicitly loops over a vector of tickers.

require(quantmod)
getSymbols(tickers[,1], from="2011-01-01", to="2011-01-31") # If you want to merge all the close prices into one object: ClosePrices <- do.call(merge, lapply(tickers[,1], function(x) Cl(get(x)))) head(ClosePrices)

#            BCSI.Close WBSN.Close NTAP.Close FFIV.Close SU.Close
# 2011-01-03      30.50      20.36      57.41     134.33    38.82
# 2011-01-04      30.24      19.82      57.38     132.07    38.03
# 2011-01-05      31.36      19.90      57.87     137.29    38.40
# 2011-01-06      32.04      19.79      57.49     138.07    37.23
# 2011-01-07      31.95      19.77      57.20     138.35    37.30
# 2011-01-10      31.55      19.76      58.22     142.69    37.04

Hope that helps,

--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



On Sun, Mar 13, 2011 at 1:29 PM, algotr8der <algotr8der_at_gmail.com> wrote:

> Thank you all. Your solutions work. I suppose it doesnt matter whether I use
> coredata or not (at least for my current purposes). I have created a
> user-defined function and have saved it in a ".R" file in my current working
> directory. But now I'm not sure how to invoke this function. R complains
> that it cannot find the function.
>
> If I copy and paste the function code into the R console and call it after
> that everything works fine. Is there a way to bring that function into
> memory by giving a path to its location? I imagine that I will have many
> user-defined functions written in their own '.R' files over time.
>
> Thank you all.
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/pass-character-vector-in-instrument-field-of-get-hist-quote-function-tp3350779p3352344.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_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.
>
______________________________________________ R-help_at_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.
Received on Sun 13 Mar 2011 - 19:15:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Apr 2011 - 20:40:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive