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

G See gsee000 at gmail.com
Wed Jan 4 23:03:37 CET 2012


Yahoo doesn't provide that data as far as I'm aware.

Look at how there is a link for "Components" for DJI, but not for GSPC
http://finance.yahoo.com/q?s=^dji
http://finance.yahoo.com/q?s=^gspc

Garrett

On Wed, Jan 4, 2012 at 3:59 PM, Jun Zhu <junzhu98 at yahoo.com> wrote:
> Hi,
> I tried other indexes like S&P500 and it does not give the correct results:
>> getIndexComposition('^GSPC') [1] "@^GSPC" NA       "@^GSPC" NA       "@^GSPC" NA       "@^GSPC" NA       "@^GSPC" NA      [11] "@^GSPC" NA       "@^GSPC" NA       "@^GSPC" NA       "@^GSPC" NA       "@^GSPC">
> Anything wrong here ?
> Thanks,
> Jun
> --- On Wed, 1/4/12, Ledon, Alain <Alain.Ledon at ally.com> wrote:
>
> From: Ledon, Alain <Alain.Ledon at ally.com>
> Subject: Re: [R-SIG-Finance] List index constituents of an index in R? quantmod?
> To: "julien cuisinier" <j_cuisinier at hotmail.com>, "r-sig-finance at r-project.org" <r-sig-finance at r-project.org>
> Date: Wednesday, January 4, 2012, 8:24 AM
>
> Hi
>
> The package tawny includes a function to get the index composition using yahoo. It is not perfect but it could be a start:
>
>> library(tawny)
>> getIndexComposition('^DJI')
>  [1] "AA"   "AXP"  "BA"   "BAC"  "CAT"  "CSCO" "CVX"  "DD"   "DIS"  "GE"   "HD"   "HPQ"  "IBM"  "INTC" "JNJ"  "JPM"  "KFT"  "KO"   "MCD"  "MMM"  "MRK"  "MSFT" "PFE"  "PG"   "T"    "TRV"  "UTX"  "VZ"   "WMT"  "XOM"
>> getIndexComposition('^FTSE')
>   [1] "AAL.L"  "ABF.L"  "ADM.L"  "AGK.L"  "AMEC.L" "ANTO.L" "ARM.L"  "ASHM.L" "AV.L"   "AZN.L"  "BA.L"   "BARC.L" "BATS.L" "BG.L"   "BLND.L" "BLT.L"  "BNZL.L" "BP.L"   "BRBY.L" "BSY.L"  "BT-A.L" "CCL.L"  "CNA.L"  "CNE.L"  "CPG.L"
>  [26] "CPI.L"  "CRH.L"  "CSCG.L" "DGE.L"  "EMG.L"  "ENRC.L" "ESSR.L" "EXPN.L" "FRES.L" "GFS.L"  "GKN.L"  "GLEN.L" "GSK.L"  "HL.L"   "HMSO.L" "HSBA.L" "IAG.L"  "IAP.L"  "IHG.L"  "IMI.L"  "IMT.L"  "IPR.L"  "ITRK.L" "ITV.L"  "JMAT.L"
>  [51] "KAZ.L"  "KAZ.L"  "KGF.L"  "LAND.L" "LGEN.L" "LLOY.L" "MGGT.L" "MKS.L"  "MRW.L"  "NG.L"   "NXT.L"  "OML.L"  "PFC.L"  "POLY.L" "PRU.L"  "PSON.L" "RB.L"   "RBS.L"  "RDSA.L" "RDSB.L" "REL.L"  "REX.L"  "RIO.L"  "RR.L"   "RRS.L"
>  [76] "RSA.L"  "RSL.L"  "SAB.L"  "SBRY.L" "SDR.L"  "SDRC.L" "SGE.L"  "SHP.L"  "SL.L"   "SMIN.L" "SN.L"   "SRP.L"  "SSE.L"  "STAN.L" "SVT.L"  "TATE.L" "TLW.L"  "TSCO.L" "ULVR.L" "UU.L"   "VED.L"  "VOD.L"  "WEIR.L" "WOS.L"  "WPP.L"
> [101] "WTB.L"
>
> Regards
>
> Alain
>
> (646)781-2698
>
> -----Original Message-----
> From: r-sig-finance-bounces at r-project.org [mailto:r-sig-finance-bounces at r-project.org] On Behalf Of julien cuisinier
> Sent: Wednesday, January 04, 2012 7:25 AM
> To: r-sig-finance at r-project.org
> Subject: [R-SIG-Finance] List index constituents of an index in R? quantmod?
>
>
> Hi List,
>
>
> I know, I know not really following the posting guidelines...Is anyone aware of an existing function to download from yahoo finance the list of an index constituents?
>
> Could not find anything googling, hope I haven't missed an obvious thread...
>
> I am still on R 2.13 but I guess that would not really matter here, Windows 7
>
> I am learning quantstrat package like many of us & hoping to use that list of constituents to calculate cross sectional volatility & use it as a signal as exercise (some way between the list of constituent & this but I hope you get the point)
>
> Any hint / redirection appreciated - if my take is that it should not be too hard & it could be a great addition to quantmod
>
>
> Rgds,
> Julien
>
>
>
>
> Many thanks
>
>
>
>
>
>     [[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.
>
> _______________________________________________
> 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.
>
>        [[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