Description Usage Arguments Details Value Author(s) See Also Examples
Functions to scrape and clean index constituent data from multiple sources for a given index.
Current src
methods available are: default.
Data is loaded silently without user assignment by default.
1 2 3 4 | getConstituents(index, env = .GlobalEnv, simple = TRUE, src = "default",
auto.assign = TRUE)
getConstituents.simple(index = "SPY")
|
index |
Character; string specifying the name of the index. One of |
env |
Environment; where to create objects. Setting |
simple |
Logical; should results include non-ticker data. If |
src |
Character; string specifying the source to retrieve the data from. As of 0.1-1,
the only source available is "default" which changes depending on the selected |
auto.assign |
Logical; should results be loaded to |
getConstituents
will try to format the index
parameter using cleanIndex
.
Data is loaded from various sources depending on input arguments:
For S&P 500 data, the source is the SPDR website, price data. For
SIMPLE=FALSE
, data is also drawn from Yahoo Finance.
For NASDAQ 100 data, the source is the NASDAQ website.
For SIMPLE=FALSE
, price data is also taken from NASDAQ. Constituent weightings are not available in a
form scrapable by R.
For DJIA 30 data, the souce is CNN Money, which updates its data every few
months. For SIMPLE=FALSE
, up-to-date price data is sourced from Yahoo Finance, and constituent weightings
are calculated manually.
Future versions will include Russel indexes with data sourced from Vanguard
a character vector or data.frame of index
's constituent tickers(, price, weight)
Alec Kulakowski, alecthekulak@gmail.com
1 2 3 4 5 6 7 8 9 | ## Not run:
getConstituents(index='S&P 500')
getConstituents(index='NASDAQ 100')
getConstituents(index='DJIA', auto.assign=FALSE)
getConstituents.simple(index='S&P 500')
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.