查找股票所属的行业

时间:2013-05-08 04:13:00

标签: r

鉴于S& P500的股票,我如何找到每只股票属于哪个部门,例如:金融,能源......,使用R包或其他来源?

1 个答案:

答案 0 :(得分:4)

术语“部门”本身就是一个含糊不清的术语。一个数据提供者所谓的“消费者服务”可能被另一个称为“餐馆”。也就是说,TTR提供了一个名为stockSymbols的函数,该函数从纳斯达克返回一些信息,包括Sector,用于~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

如果您只想要S&amp; P 500中的股票,您可以欺骗并使用SPY的持股(或者有很多地方可以找到S&amp; P 500的股票,包括标准和放大器; Poors网站)

#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