[R-SIG-Finance] List index constituents of an index in R? quantmod?

G See gsee000 at gmail.com
Wed Jan 4 15:24:40 CET 2012


Julien,

I did this for an example with the Dow Jones Industrial average.
It should be in this directory on your computer:
blotter/pkg/FinancialInstrument/inst/parser/DJIA.index.R

It's also available here:
http://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/FinancialInstrument/inst/parser/DJIA.index.R?revision=834&root=blotter

If you're interested in getting the holdings of an iShare ETR or a
Sector SPDR ETF, you can use a function called "getHoldings" from the
package "qmao"

Regards,
Garrett

On Wed, Jan 4, 2012 at 7:50 AM, julien cuisinier
<j_cuisinier at hotmail.com> wrote:
>
> Many thanks Vincent. It does run on several pages and layout seems to be constant so your route might be very useful..
>
> I was hoping it should be possible to request that data using http get method as for historical prices, I will also try to look down that route
>
> If / when I get around this I will keep the list posted
>
>
> Rgds,
> Julien
>
>
>
>> Date: Wed, 4 Jan 2012 21:47:31 +0900
>> Subject: Re: [R-SIG-Finance] List index constituents of an index in R? quantmod?
>> From: zoonek at gmail.com
>> To: r-sig-finance at r-project.org
>> CC: j_cuisinier at hotmail.com
>>
>> You can use the XML package to parse the page and extract the contents
>> of the table:
>>   library(XML)
>>   index <- "^DJI"
>>   url <- paste("http://uk.finance.yahoo.com/q/cp?s=", index, sep="")
>>   symbols <- readHTMLTable(url, as.data.frame=FALSE)[[10]]$Symbol
>>
>> You should check the size of the result: large indices may be split
>> across several pages, and the layout of the page may change.
>>
>> -- Vincent
>>
>> On 4 January 2012 21:24, julien cuisinier <j_cuisinier at hotmail.com> wrote:
>> > Is anyone aware of an existing function to download from yahoo finance
>> > the list of an index constituents?
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list