-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaveTickers.R
More file actions
23 lines (17 loc) · 824 Bytes
/
Copy pathSaveTickers.R
File metadata and controls
23 lines (17 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#Get ticker listing data
listings <- stockSymbols()
#order it ascend/descen
#listings <- listings[order(listings$MarketCap,decreasing=TRUE),]
#Generate files for each of the exchanges ticker symbols
listings <- stockSymbols("NYSE")
write.table(listings, file="tickersNYSE.txt",na="",sep="\t",row.names=FALSE)
listings <- stockSymbols("NASDAQ")
write.table(listings, file="tickersNASDAQ.txt",na="",sep="\t",row.names=FALSE)
listings <- stockSymbols("AMEX")
write.table(listings, file="tickersAMEX.txt",na="",sep="\t",row.names=FALSE)
#separate the symbols only, unique removes duplicates
tickers <- unique(gsub("-.*","",listings$Symbol))
#order alphabetically
tickers <- tickers[order(tickers,decreasing=FALSE)]
#Write to file, tab separated
write.table(tickers, file="tickers.txt", na="", sep="\t", row.names = FALSE)