getHoldings: Get the holdings of an ETF

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/getHoldings.R

Description

Get the names and weights of ETF holdings.

Usage

1
2
  getHoldings(Symbols, env = .GlobalEnv,
    auto.assign = TRUE)

Arguments

Symbols

chr Symbols of ETFs. Presently, if not supplied the Symbols of the nine Sector SPDRs will be used. However, in the future it may be changed to require that Symbols be provided by the user.

env

environment to store the holdings data in

auto.assign

assign data?

Details

This function acts like a generic function. There are other functions, such as getHoldings.iShares and getHoldings.selectSPDR that act like “methods”.

getHoldings looks up the Symbols in the CSV at http://www.masterdata.com/helpfiles/ETF_List_Downloads/AllTypes.csv from http://www.masterdata.com/HelpFiles/ETF_List.htm. It uses the Name field to determine which getHoldings.* function to call.

Different getHoldings.* “methods” will return different columns, but all of them should have the Ticker Symbol or some other identifier as the rownames, the first column should be Weights (0-100), and the second column should be Name (a description of the security). Also, the returned holdings data will be a data.frame with class holdings, or a list of holdings classed objects.

Some iShares ETFs have more than one holding listed with the same Symbol. In the case that Symbols are duplicated, a “duplicates” attribute will be added to the returned object. Also, since rownames cannot be duplicated, they will be made unique with make.unique

Value

An object classed as “holdings” will be created that is a data.frame with columns for holdings' weights and names. If called with auto.assign=TRUE, it will be assigned in env with names that are Symbols appended with “.h”. Otherwise, the “holdings” will be returned and not stored. Returned objects may have more columns depending on which getHoldings.* “method” is used.

Author(s)

Garrett See

References

http://www.masterdata.com/HelpFiles/ETF_List.htm

See Also

getHoldings.SPDR, getHoldings.selectSPDR, getHoldings.iShares, qmao:::getHoldings.iShares.AsOf, getHoldings.vaneck, getHoldings.powershares, getHoldings.GlobalX, getHoldings.FirstTrust, getHoldings.WisdomTree

Examples

1
2
3
4
5
6
7
8
## Not run: 
getHoldings('XLB', auto.assign=FALSE) #getHoldings.SPDR or .selectSPDR depending on OS
getHoldings('IVE') #getHoldings.iShares
IVE.h
getHoldings(c("QQQ", "GDX")) #.powershares and .vaneck (Market Vectors)
getHoldings(c("XLY", "IVE", "QQQ", "GDX", "OIH", "XLU", "EPI"))

## End(Not run)

qmao documentation built on May 2, 2019, 4:54 p.m.