2

给定 S&P500 中的股票,我如何使用 R 包或其他来源找到每只股票属于哪个行业,例如金融、能源……?

4

1 回答 1

4

“部门”一词本身就是一个模棱两可的词。一个数据提供者称为“消费者服务”的东西可能被另一个称为“餐厅”。也就是说,TTR提供了一个名为的函数,该函数stockSymbols返回一些信息,包括来自纳斯达克的约 6400 支 NMS 股票的部门信息。

library(TTR)
ss <- stockSymbols()
#Fetching AMEX symbols...
#Fetching NASDAQ symbols...
#Fetching NYSE symbols...
head(ss)
#  Symbol                      Name LastSale MarketCap IPOyear           Sector                        Industry Exchange
#1   AA-P                Alcoa Inc.   92.300         0      NA    Capital Goods              Metal Fabrications     AMEX
#2    AAU    Almaden Minerals, Ltd.    1.620  97228060      NA Basic Industries                 Precious Metals     AMEX
#3    ACU  Acme United Corporation.   12.984  40798351    1988    Capital Goods Industrial Machinery/Components     AMEX
#4    ACY         AeroCentury Corp.   20.280  31297252      NA       Technology Diversified Commercial Services     AMEX
#5   ADGE   American DG Energy Inc.    1.720  83404061      NA           Energy     Electric Utilities: Central     AMEX
#6    ADK Adcare Health Systems Inc    5.800  85018494      NA      Health Care     Hospital/Nursing Management     AMEX

如果你只想要标准普尔 500 指数的股票,你可以作弊并使用 SPY 的股票(或者有很多地方可以找到标准普尔 500 指数的股票,包括标准普尔网站)

#install.packages("qmao", repos="http://r-forge.r-project.org")
library(qmao)
spyh <- getHoldings("SPY", auto.assign=FALSE)
head(ss[ss$Symbol %in% rownames(spyh), ])
#    Symbol                            Name LastSale    MarketCap IPOyear        Sector
#455   AAPL                      Apple Inc.   452.97 425179837530    1980    Technology
#490   ADBE      Adobe Systems Incorporated    44.02  22095230291    1986    Technology
#493    ADI            Analog Devices, Inc.    46.79  14317018779      NA    Technology
#495    ADP Automatic Data Processing, Inc.    70.03  33980125863      NA    Technology
#500   ADSK                  Autodesk, Inc.    39.75   8896050000      NA    Technology
#535   AKAM       Akamai Technologies, Inc.    46.70   8333728621    1999 Miscellaneous
#                                   Industry Exchange
#455                  Computer Manufacturing   NASDAQ
#490 Computer Software: Prepackaged Software   NASDAQ
#493                          Semiconductors   NASDAQ
#495                            EDP Services   NASDAQ
#500 Computer Software: Prepackaged Software   NASDAQ
#535                       Business Services   NASDAQ
于 2013-05-13T15:29:19.427 回答