通过JQData可以完成股票的行业查询,具体安装过程见我之前发布的文章。

注意的是,这里查询的行业,默认为“证监会”分类,

相关代码:ShaoZC/Financial-report-acquisition-and-data-processing-with-Python​github.com

以下内容来自:https://www.joinquant.com/help/api/help?name=JQData#get_industry-%E6%9F%A5%E8%AF%A2%E8%82%A1%E7%A5%A8%E6%89%80%E5%B1%9E%E8%A1%8C%E4%B8%9A​www.joinquant.com

get_industry - 查询股票所属行业

get_industry(security, date=None)

参数security:标的代码,类型为字符串,形式如"000001.XSHE";或为包含标的代码字符串的列表,形如["000001.XSHE", "000002.XSHE"]

date:查询的日期。默认为None,指定查询当天数据。类型为字符串,形如"2018-06-01"或"2018-06-01 09:00:00";或为datetime.datetime对象和datetime.date。注意传入对象的时分秒将被忽略。

返回

返回结果是一个dict,key是传入的股票代码

示例

#获取贵州茅台("600519.XSHG")的所属行业数据

d = get_industry("600519.XSHG",date="2018-06-01")

print(d)

{'600519.XSHG': {'sw_l1': {'industry_code': '801120', 'industry_name': '食品饮料I'}, 'sw_l2': {'industry_code': '801123', 'industry_name': '饮料制造II'}, 'sw_l3': {'industry_code': '851231', 'industry_name': '白酒III'}, 'zjw': {'industry_code': 'C15', 'industry_name': '酒、饮料和精制茶制造业'}, 'jq_l2': {'industry_code': 'HY478', 'industry_name': '白酒与葡萄酒指数'}, 'jq_l1': {'industry_code': 'HY005', 'industry_name': '日常消费指数'}}}

#同时获取多只股票的所属行业信息

stock_list = ['000001.XSHE','000002.XSHE']

d = get_industry(security=stock_list, date="2018-06-01")

print(d)

{'000001.XSHE': {'sw_l1': {'industry_code': '801780', 'industry_name': '银行I'}, 'sw_l2': {'industry_code': '801192', 'industry_name': '银行II'}, 'sw_l3': {'industry_code': '851911', 'industry_name': '银行III'}, 'zjw': {'industry_code': 'J66', 'industry_name': '货币金融服务'}, 'jq_l2': {'industry_code': 'HY493', 'industry_name': '多元化银行指数'}, 'jq_l1': {'industry_code': 'HY007', 'industry_name': '金融指数'}}, '000002.XSHE': {'sw_l1': {'industry_code': '801180', 'industry_name': '房地产I'}, 'sw_l2': {'industry_code': '801181', 'industry_name': '房地产开发II'}, 'sw_l3': {'industry_code': '851811', 'industry_name': '房地产开发III'}, 'zjw': {'industry_code': 'K70', 'industry_name': '房地产业'}, 'jq_l2': {'industry_code': 'HY509', 'industry_name': '房地产开发指数'}, 'jq_l1': {'industry_code': 'HY011', 'industry_name': '房地产指数'}}}

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐