-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgenerate_lists.R
247 lines (188 loc) · 10.2 KB
/
generate_lists.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# March 9, 2017
# Dane Van Domelen
# R file to create various lists for stocks package
# Load stocks package
library("stocks")
# Vanguard ETFs -----------------------------------------------------------
# 55 ETFs as of Oct. 18, 2017
# https://investor.vanguard.com/etf/list#/etf/asset-class/month-end-returns
# Bond ETFs
(vanguard_bond_etfs <-
ticker_dates(tickers = c("EDV", "BIV", "VGIT", "BLV", "VGLT", "VMBS", "BSV",
"VTIP", "VGSH", "BND", "VCIT", "VCLT", "VCSH",
"VTC", "VTEB"))[, 1: 2])
# Bond ETFs -> Treasury/Agency
(vanguard_treasury_etfs <-
ticker_dates(tickers = c("EDV", "BIV", "VGIT", "BLV", "VGLT", "VMBS", "BSV",
"VGSH", "VTIP", "BND"))[, 1: 2])
# Bond ETFs -> Investment-grade
(vanguard_igrade_etfs <-
ticker_dates(tickers = c("VCIT", "VCLT", "VCSH", "VTC"))[, 1: 2])
# Stocks ETFs
(vanguard_stock_etfs <-
ticker_dates(tickers = c("VIG", "VUG", "VYM", "VV", "MGC", "MGK", "MGV",
"VOO", "VTI", "VTV", "VXF", "VO", "VOT", "VOE",
"VB", "VBK", "VBR"))[, 1: 2])
# Stock ETFs -> Large-cap
(vanguard_largecap_etfs <-
ticker_dates(tickers = c("VIG", "VUG", "VYM", "VV", "MGC", "MGK", "MGV",
"VOO", "VTI", "VTV"))[, 1: 2])
# Stock ETFs -> Mid-cap
(vanguard_midcap_etfs <-
ticker_dates(tickers = c("VXF", "VO", "VOT", "VOE"))[, 1: 2])
# Stock ETFs -> Small-cap
(vanguard_smallcap_etfs <-
ticker_dates(tickers = c("VB", "VBK", "VBR"))[, 1: 2])
# International ETFs
(vanguard_international_etfs <-
ticker_dates(tickers = c("VWOB", "VEU", "VSS", "VEA", "VWO", "VGK", "VPL",
"VNQI", "VIGI", "VYMI", "BNDX", "VXUS",
"VT"))[, 1: 2])
# Sector ETFs
(vanguard_sector_etfs <-
ticker_dates(tickers = c("VCR", "VDC", "VDE", "VFH", "VHT", "VIS", "VGT",
"VAW", "VNQ", "VOX", "VPU"))[, 1: 2])
# All Vanguard ETFs
(vanguard_etfs <- rbind(vanguard_bond_etfs, vanguard_stock_etfs,
vanguard_international_etfs, vanguard_sector_etfs))
# Vanguard mutual funds ---------------------------------------------------
# Bond funds
(vanguard_bond_funds <-
ticker_dates(tickers = c("VFIIX", "VIPSX", "VBILX", "VFITX", "VSIGX",
"VBLTX", "VUSTX", "VLGSX", "VMBSX", "VBIRX",
"VSGBX", "VTAPX", "VFISX", "VSBSX", "VBTLX",
"VCORX", "VICSX", "VFICX", "VLTCX", "VWESX",
"VSCSX", "VFSTX", "VUBFX", "VWEHX", "VCAIX",
"VCITX", "VWAHX", "VWITX", "VMLTX", "VWLTX",
"VMATX", "VNJTX", "VNYTX", "VOHIX", "VPAIX",
"VWSTX", "VTEAX"))[, 1: 2])
# Bond funds -> Treasury/Agency
(vanguard_treasury_funds <-
ticker_dates(tickers = c("VFIIX", "VIPSX", "VBILX", "VFITX", "VSIGX",
"VBLTX", "VUSTX", "VLGSX", "VMBSX", "VBIRX",
"VSGBX", "VTAPX", "VFISX", "VSBSX", "VBTLX"))[, 1: 2])
# Bond funds -> Investment-grade
(vanguard_igrade_funds <-
ticker_dates(tickers = c("VCORX", "VICSX", "VFICX", "VLTCX", "VWESX",
"VSCSX", "VFSTX", "VUBFX"))[, 1: 2])
# Bond funds -> Tax-exempt
(vanguard_taxexempt_bond_funds <-
ticker_dates(tickers = c("VCAIX", "VCITX", "VWAHX", "VWITX", "VMLTX",
"VWLTX", "VMATX", "VNJTX", "VNYTX", "VOHIX",
"VPAIX", "VWSTX", "VTEAX"))[, 1: 2])
# Balanced funds
(vanguard_balanced_funds <-
ticker_dates(tickers = c("VTXVX", "VTWNX", "VTTVX", "VTHRX", "VTTHX",
"VFORX", "VTIVX", "VFIFX", "VFFVX", "VTTSX",
"VLXVX", "VTINX", "VSCGX", "VASGX", "VASIX",
"VSMGX", "VBIAX", "VCVSX", "VGSTX", "VTMFX",
"VWINX", "VWELX", "VPGDX", "VGWIX", "VGWLX"))[, 1: 2])
# Balanced funds -> Target-date
(vanguard_targetdate_funds <-
ticker_dates(tickers = c("VTENX", "VTXVX", "VTWNX", "VTTVX", "VTHRX",
"VTTHX", "VFORX", "VTIVX", "VFIFX", "VFFVX",
"VTTSX", "VLXVX", "VTINX"))[, 1: 2])
# Balanced funds -> Target-risk
(vanguard_targetrisk_funds <-
ticker_dates(tickers = c("VSCGX", "VASGX", "VASIX", "VSMGX"))[, 1: 2])
# Balanced funds -> Traditional
(vanguard_traditional_funds <-
ticker_dates(tickers = c("VBIAX", "VCVSX", "VGSTX", "VTMFX", "VWINX",
"VWELX"))[, 1: 2])
# Stock funds
(vanguard_stock_funds <-
ticker_dates(tickers = c("VFIAX", "VDEQX", "VDADX", "VDIGX", "VEIPX",
"VFTSX", "VQNPX", "VIGAX", "VHDYX", "VLCAX",
"VMRGX", "VPMAX", "VPCCX", "VTCLX", "VTSAX",
"VWUSX", "VUVLX", "VVIAX", "VWNDX", "VWNFX",
"VHCAX", "VCVLX", "VEXAX", "VMGRX", "VMGMX",
"VIMAX", "VMVAX", "VASVX", "VSEQX", "VEXPX",
"VEVFX", "VSGAX", "VSMAX", "VSIAX", "VSTCX",
"VTMSX", "VMVFX"))[, 1: 2])
# Stock funds -> Large-cap
(vanguard_largecap_funds <-
ticker_dates(tickers = c("VFIAX", "VDEQX", "VDADX", "VDIGX", "VEIPX",
"VFTSX", "VQNPX", "VIGAX", "VHDYX", "VLCAX",
"VMRGX", "VPMAX", "VPCCX", "VTCLX", "VTSAX",
"VWUSX", "VUVLX", "VVIAX", "VWNDX", "VWNFX"))[, 1: 2])
# Stock funds -> Mid-cap
(vanguard_midcap_funds <-
ticker_dates(tickers = c("VHCAX", "VCVLX", "VEXAX", "VMGRX", "VMGMX",
"VIMAX", "VMVAX", "VASVX", "VSEQX"))[, 1: 2])
# Stock funds -> Small-cap
(vanguard_smallcap_funds <-
ticker_dates(tickers = c("VEXPX", "VEVFX", "VSGAX", "VSMAX", "VSIAX",
"VSTCX", "VTMSX"))[, 1: 2])
# Vanguard international funds
(vanguard_international_funds <-
ticker_dates(tickers = c("VTMGX", "VEMBX", "VGAVX", "VMMSX", "VEMAX",
"VEUSX", "VFWAX", "VFSVX", "VGRLX", "VIAAX",
"VINEX", "VWIGX", "VIHAX", "VTRIX", "VPADX",
"VTABX", "VTIAX", "VHGEX", "VTWSX"))[, 1: 2])
# Vanguard sector funds
(vanguard_sector_funds <-
ticker_dates(tickers = c("VGENX", "VGHCX", "VGPMX", "VGSLX"))[, 1: 2])
# All Vanguard mutual funds
(vanguard_funds <-
rbind(vanguard_bond_funds, vanguard_balanced_funds, vanguard_stock_funds,
vanguard_international_funds, vanguard_sector_funds))
# High yield ETFs ---------------------------------------------------------
# 47 ETFs as of Oct. 18, 2017
# From: http://etfdb.com/etfdb-category/high-yield-bonds/#etfs&sort_name=assets_under_management&sort_order=desc&page=2
(highyield_etfs <-
ticker_dates(tickers = c("ANGL", "BKLN", "BLHY", "BSJI", "BSJJ",
"BSJK", "BSJL", "BSJM", "BSJN", "BSJO",
"BSJP", "CJNK", "EMHY", "FALN", "FTSL",
"GHYG", "HHYX", "HYDB", "HYDW", "HYEM",
"HYG", "HYGH", "HYHG", "HYIH", "HYLB",
"HYLD", "HYLS", "HYLV", "HYND", "HYS",
"HYUP", "HYXE", "HYXU", "HYZD", "IHY",
"JNK", "JPHY", "PGHY", "PHB", "SFHY",
"SHYG", "SHYL", "SJNK", "SNLN", "SOVB",
"SRLN", "USHY", "WFHY", "WYDE", "YLD"))[, 1: 2])
# Sector SPDR ETFs -----------------------------------------------------
# 10 ETFs as of March 2, 2018
# From: http://www.sectorspdr.com/sectorspdr/sectors
sector_spdr_etfs <-
ticker_dates(tickers = c("XLY", "XLP", "XLE", "XLF", "XLV", "XLI", "XLB",
"XLRE", "XLK", "XLU"))[, 1: 2]
sector_spdr_etfs$sector <-
c("Cons. Disc.", "Cons. Staples", "Energy", "Financials", "Health Care",
"Industrials", "Materials", "Real Estate", "Technology", "Utilities")
(sector_spdr_etfs <- sector_spdr_etfs[, c(1, 3, 2)])
# 100 largest market cap ETFs ---------------------------------------------
# From: http://etfdb.com/compare/market-cap/
setwd("C:/Users/Dane/Google Drive/github/stocks")
(largest_etfs <-
ticker_dates(tickers = read.csv("largest100.csv", header = F,
stringsAsFactors = FALSE)[, 1])[, 1: 2])
# Save datasets -----------------------------------------------------------
setwd("C:/Users/Dane/Google Drive/github/stocks/data")
save(vanguard_bond_etfs, file = "vanguard_bond_etfs.rda")
save(vanguard_treasury_etfs, file = "vanguard_treasury_etfs.rda")
save(vanguard_igrade_etfs, file = "vanguard_igrade_etfs.rda")
save(vanguard_stock_etfs, file = "vanguard_stock_etfs.rda")
save(vanguard_largecap_etfs, file = "vanguard_largecap_etfs.rda")
save(vanguard_midcap_etfs, file = "vanguard_midcap_etfs.rda")
save(vanguard_smallcap_etfs, file = "vanguard_smallcap_etfs.rda")
save(vanguard_international_etfs, file = "vanguard_international_etfs.rda")
save(vanguard_sector_etfs, file = "vanguard_sector_etfs.rda")
save(vanguard_etfs, file = "vanguard_etfs.rda")
save(vanguard_bond_funds, file = "vanguard_bond_funds.rda")
save(vanguard_treasury_funds, file = "vanguard_treasury_funds.rda")
save(vanguard_igrade_funds, file = "vanguard_igrade_funds.rda")
save(vanguard_taxexempt_bond_funds, file = "vanguard_taxexempt_bond_funds.rda")
save(vanguard_balanced_funds, file = "vanguard_balanced_funds.rda")
save(vanguard_targetdate_funds, file = "vanguard_targetdate_funds.rda")
save(vanguard_targetrisk_funds, file = "vanguard_targetrisk_funds.rda")
save(vanguard_traditional_funds, file = "vanguard_traditional_funds.rda")
save(vanguard_stock_funds, file = "vanguard_stock_funds.rda")
save(vanguard_largecap_funds, file = "vanguard_largecap_funds.rda")
save(vanguard_midcap_funds, file = "vanguard_midcap_funds.rda")
save(vanguard_smallcap_funds, file = "vanguard_smallcap_funds.rda")
save(vanguard_international_funds, file = "vanguard_international_funds.rda")
save(vanguard_sector_funds, file = "vanguard_sector_funds.rda")
save(vanguard_funds, file = "vanguard_funds.rda")
save(highyield_etfs, file = "highyield_etfs.rda")
save(sector_spdr_etfs, file = "sector_spdr_etfs.rda")
save(largest_etfs, file = "largest_etfs.rda")