mirror of
https://github.com/1nchaos/adata.git
synced 2024-11-25 16:32:39 +08:00
version
2.7.0
This commit is contained in:
parent
a7de9faa6d
commit
c9360c0845
10
HISTORY.md
10
HISTORY.md
@ -9,6 +9,16 @@ master
|
||||
|
||||
专注股票量化数据,为Ai(爱)发电,向阳而生。
|
||||
|
||||
2.7.0 (2024-10-16)
|
||||
------------------
|
||||
1. 新增:股票:股票所属的板块:行业、地域板块、概念。
|
||||
2. 修复:股票:部分文档描述
|
||||
|
||||
2.6.0 (2024-09-04)
|
||||
------------------
|
||||
1. 新增:股票:财务数据-核心财务数据。
|
||||
2. 修复:股票:代码市场bug。
|
||||
|
||||
2.5.0 (2024-07-23)
|
||||
------------------
|
||||
1. 新增:股票:单只股票的申万一二级行业信息。
|
||||
|
@ -147,6 +147,7 @@ print(res_df)
|
||||
| 概念代码 | stock.info.all_concept_code_east() | 所有A股概念代码信息(东方财富) | 来源:[东方财富](https://data.eastmoney.com/bkzj/gn.html) |
|
||||
| 概念成分列表 | stock.info.concept_constituent_east() | 获取同花顺概念指数的成分股(东方财富) | 注意:返回结果只有股票代码和股票简称,可根据概念名称查询 |
|
||||
| 股票所属概念 | stock.info.get_concept_east() | 获取单只股票所属的概念板块 | [核心题材](https://emweb.securities.eastmoney.com/pc_hsf10/pages/index.html?type=web&code=SZ300059&color=b#/hxtc) |
|
||||
| 股票所属板块 | stock.info.get_plate_east() | 获取单只股票所属的板块 | 1. 行业 2. 地域板块 3.概念,综合的概念接口 |
|
||||
| **指数** | | | |
|
||||
| 指数代码 | stock.info.all_index_code() | 获取所有A股市场的指数代码 | 来源同花顺,可能存在同花顺对代码重新编码的情况 |
|
||||
| 指数对应的成分股 | stock.info.index_constituent() | 获取对应指数的成分股列表 | |
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
VERSION = (2, 6, 6)
|
||||
VERSION = (2, 7, 0)
|
||||
PRERELEASE = None # alpha, beta or rc
|
||||
REVISION = None
|
||||
|
||||
|
@ -100,8 +100,40 @@ class StockConceptEast(StockConceptTemplate):
|
||||
result_df = pd.DataFrame(data=data, columns=self._CONCEPT_INFO_COLUMNS)
|
||||
return result_df
|
||||
|
||||
def get_plate_east(self, stock_code: str = '000001', plate_type=None):
|
||||
"""
|
||||
根据股票代码获取,股票所属的所有的板块相关的信息
|
||||
:param stock_code: 股票代码
|
||||
:param plate_type: 1. 行业 2. 地域板块 3.概念 默认:0全部
|
||||
:return: 板块信息
|
||||
"""
|
||||
stock_code = compile_exchange_by_stock_code(stock_code)
|
||||
url = f'https://datacenter.eastmoney.com/securities/api/data/get?' \
|
||||
f'type=RPT_F10_CORETHEME_BOARDTYPE&' \
|
||||
f'sty=SECUCODE,SECURITY_CODE,SECURITY_NAME_ABBR,BOARD_CODE,BOARD_NAME,IS_PRECISE,BOARD_RANK,BOARD_TYPE&' \
|
||||
f'filter=(SECUCODE="{stock_code}")&p=1&ps=&sr=1&st=BOARD_RANK&source=HSF10&client=PC&v=08059745171648254'
|
||||
res_json = requests.request('get', url, headers={}, proxies={}).json()
|
||||
# 1. 返回结果判断
|
||||
if not res_json['success']:
|
||||
return pd.DataFrame(data=[], columns=self._PLATE_INFO_COLUMNS)
|
||||
|
||||
# 2. 正常返回数据结果封装
|
||||
res_data = res_json['result']['data']
|
||||
data = []
|
||||
for _ in res_data:
|
||||
plate_code = '0000' + _['BOARD_CODE']
|
||||
data.append({'stock_code': _['SECURITY_CODE'], 'plate_code': 'BK' + plate_code[-4:],
|
||||
'plate_name': _['BOARD_NAME'], 'source': '东方财富',
|
||||
'plate_type': _['BOARD_TYPE'] if _['BOARD_TYPE'] else '概念'})
|
||||
result_df = pd.DataFrame(data=data, columns=self._PLATE_INFO_COLUMNS)
|
||||
if plate_type is None:
|
||||
return result_df
|
||||
plate_type = {'1': '行业', '2': '板块', '3': '概念'}.get(str(plate_type), None)
|
||||
return result_df[result_df['plate_type'] == plate_type]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(StockConceptEast().all_concept_code_east())
|
||||
print(StockConceptEast().concept_constituent_east(concept_code="BK0637"))
|
||||
print(StockConceptEast().get_concept_east(stock_code="600020").to_string())
|
||||
print(StockConceptEast().get_plate_east(stock_code="600020", plate_type=1).to_string())
|
||||
|
@ -14,6 +14,7 @@ class StockConceptTemplate(object):
|
||||
_CONCEPT_CONSTITUENT_COLUMNS = ['stock_code', 'short_name']
|
||||
_CONCEPT_CODE_COLUMNS = ['concept_code', 'index_code', 'name', 'source']
|
||||
_CONCEPT_INFO_COLUMNS = ['stock_code', 'concept_code', 'name', 'source', 'reason']
|
||||
_PLATE_INFO_COLUMNS = ['stock_code', 'plate_code', 'plate_name', 'plate_type', 'source']
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
@ -298,3 +298,4 @@ if __name__ == '__main__':
|
||||
print(StockConceptThs().concept_constituent_ths(name='生物医药'))
|
||||
print(StockConceptThs().concept_constituent_ths(index_code='885403'))
|
||||
print(StockConceptThs().concept_constituent_ths(concept_code='300769'))
|
||||
print(StockConceptThs().get_concept_ths(stock_code='300033'))
|
||||
|
@ -45,4 +45,4 @@ class StockCapitalFlow(object):
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(StockCapitalFlow().get_capital_flow_min(stock_code='300059'))
|
||||
print(StockCapitalFlow().get_capital_flow(stock_code='000001'))
|
||||
print(StockCapitalFlow().get_capital_flow(stock_code='300059'))
|
||||
|
@ -36,6 +36,14 @@ class InfoTestCase(unittest.TestCase):
|
||||
print(df)
|
||||
self.assertEqual(True, len(df) > 2)
|
||||
|
||||
def test_get_plate_east(self):
|
||||
# 中青旅
|
||||
stock_code = '600138'
|
||||
print(f"开始测试:get_plate_east:{stock_code}")
|
||||
df = adata.stock.info.get_plate_east(stock_code=stock_code)
|
||||
print(df)
|
||||
self.assertEqual(True, len(df) > 2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
Reference in New Issue
Block a user