Skip to content

Commit

Permalink
Date (#4369)
Browse files Browse the repository at this point in the history
* update date

* add version 1.12.5

* fix stock_zh_a_gdhs
  • Loading branch information
albertandking authored Dec 29, 2023
1 parent e56551e commit 201a2c1
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 111 deletions.
3 changes: 2 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2617,9 +2617,10 @@
1.12.2 fix: fix hurun_rank interface
1.12.3 fix: fix stock_gdfx_free_holding_teamwork_em interface
1.12.4 fix: fix tool_trade_date_hist_sina interface
1.12.5 fix: fix stock_zh_a_gdhs interface
"""

__version__ = "1.12.4"
__version__ = "1.12.5"
__author__ = "AKFamily"

import sys
Expand Down
11 changes: 8 additions & 3 deletions akshare/stock_feature/stock_gdfx_em.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,13 +837,16 @@ def stock_gdfx_free_holding_teamwork_em(symbol: str = "社保") -> pd.DataFrame:
return big_df


def stock_gdfx_holding_teamwork_em() -> pd.DataFrame:
def stock_gdfx_holding_teamwork_em(symbol: str = "社保") -> pd.DataFrame:
"""
东方财富网-数据中心-股东分析-股东协同-十大股东
https://data.eastmoney.com/gdfx/HoldingAnalyse.html
:param symbol: 全部; choice of {"全部", "个人", "基金", "QFII", "社保", "券商", "信托"}
:type symbol: str
:return: 十大股东
:rtype: pandas.DataFrame
"""
symbol_dict = {} if symbol == "全部" else {"filter": f'(HOLDER_TYPE="{symbol}")'}
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"sortColumns": "COOPERAT_NUM,HOLDER_NEW,COOPERAT_HOLDER_NEW",
Expand All @@ -855,6 +858,7 @@ def stock_gdfx_holding_teamwork_em() -> pd.DataFrame:
"source": "WEB",
"client": "WEB",
}
params.update(symbol_dict)
r = requests.get(url, params=params)
data_json = r.json()
total_page = data_json["result"]["pages"]
Expand All @@ -877,6 +881,7 @@ def stock_gdfx_holding_teamwork_em() -> pd.DataFrame:
"协同股东名称",
"协同股东类型",
"协同次数",
"-",
"个股详情",
]
big_df = big_df[
Expand All @@ -890,7 +895,7 @@ def stock_gdfx_holding_teamwork_em() -> pd.DataFrame:
"个股详情",
]
]
big_df["协同次数"] = pd.to_numeric(big_df["协同次数"])
big_df["协同次数"] = pd.to_numeric(big_df["协同次数"], errors="coerce")
return big_df


Expand Down Expand Up @@ -940,5 +945,5 @@ def stock_gdfx_holding_teamwork_em() -> pd.DataFrame:
stock_gdfx_free_holding_teamwork_em_df = stock_gdfx_free_holding_teamwork_em()
print(stock_gdfx_free_holding_teamwork_em_df)

stock_gdfx_holding_teamwork_em_df = stock_gdfx_holding_teamwork_em()
stock_gdfx_holding_teamwork_em_df = stock_gdfx_holding_teamwork_em(symbol="社保")
print(stock_gdfx_holding_teamwork_em_df)
44 changes: 23 additions & 21 deletions akshare/stock_feature/stock_gdhs.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Date: 2022/11/19 11:20
Date: 2023/12/29 18:00
Desc: 东方财富网-数据中心-特色数据-股东户数
https://data.eastmoney.com/gdhs/
"""
import pandas as pd
import requests
from tqdm import tqdm
from akshare.utils.tqdm import get_tqdm


def stock_zh_a_gdhs(symbol: str = "20210930") -> pd.DataFrame:
def stock_zh_a_gdhs(symbol: str = "20230930") -> pd.DataFrame:
"""
东方财富网-数据中心-特色数据-股东户数
https://data.eastmoney.com/gdhs/
:param symbol: choice of {"最新", "每个季度末"}
:param symbol: choice of {"最新", "每个季度末"}, 其中 每个季度末需要写成 `20230930` 格式
:type symbol: str
:return: 股东户数
:rtype: pandas.DataFrame
Expand Down Expand Up @@ -49,6 +49,7 @@ def stock_zh_a_gdhs(symbol: str = "20210930") -> pd.DataFrame:
data_json = r.json()
total_page_num = data_json["result"]["pages"]
big_df = pd.DataFrame()
tqdm = get_tqdm()
for page_num in tqdm(range(1, total_page_num + 1), leave=False):
params.update({
"pageNumber": page_num,
Expand Down Expand Up @@ -102,17 +103,17 @@ def stock_zh_a_gdhs(symbol: str = "20210930") -> pd.DataFrame:
big_df['股东户数-增减'] = pd.to_numeric(big_df['股东户数-增减'], errors="coerce")
big_df['股东户数-增减比例'] = pd.to_numeric(big_df['股东户数-增减比例'], errors="coerce")
big_df['区间涨跌幅'] = pd.to_numeric(big_df['区间涨跌幅'], errors="coerce")
big_df['股东户数统计截止日-本次'] = pd.to_datetime(big_df['股东户数统计截止日-本次']).dt.date
big_df['股东户数统计截止日-上次'] = pd.to_datetime(big_df['股东户数统计截止日-上次']).dt.date
big_df['户均持股市值'] = pd.to_numeric(big_df['户均持股市值'])
big_df['户均持股数量'] = pd.to_numeric(big_df['户均持股数量'])
big_df['总市值'] = pd.to_numeric(big_df['总市值'])
big_df['总股本'] = pd.to_numeric(big_df['总股本'])
big_df['公告日期'] = pd.to_datetime(big_df['公告日期']).dt.date
big_df['股东户数统计截止日-本次'] = pd.to_datetime(big_df['股东户数统计截止日-本次'], errors="coerce").dt.date
big_df['股东户数统计截止日-上次'] = pd.to_datetime(big_df['股东户数统计截止日-上次'], errors="coerce").dt.date
big_df['户均持股市值'] = pd.to_numeric(big_df['户均持股市值'], errors="coerce")
big_df['户均持股数量'] = pd.to_numeric(big_df['户均持股数量'], errors="coerce")
big_df['总市值'] = pd.to_numeric(big_df['总市值'], errors="coerce")
big_df['总股本'] = pd.to_numeric(big_df['总股本'], errors="coerce")
big_df['公告日期'] = pd.to_datetime(big_df['公告日期'], errors="coerce").dt.date
return big_df


def stock_zh_a_gdhs_detail_em(symbol: str = "000002") -> pd.DataFrame:
def stock_zh_a_gdhs_detail_em(symbol: str = "000001") -> pd.DataFrame:
"""
东方财富网-数据中心-特色数据-股东户数详情
https://data.eastmoney.com/gdhs/detail/000002.html
Expand All @@ -138,6 +139,7 @@ def stock_zh_a_gdhs_detail_em(symbol: str = "000002") -> pd.DataFrame:
data_json = r.json()
total_page_num = data_json["result"]["pages"]
big_df = pd.DataFrame()
tqdm = get_tqdm()
for page_num in tqdm(range(1, total_page_num + 1), leave=False):
params.update({
"pageNumber": page_num,
Expand Down Expand Up @@ -190,19 +192,19 @@ def stock_zh_a_gdhs_detail_em(symbol: str = "000002") -> pd.DataFrame:
big_df['股东户数-上次'] = pd.to_numeric(big_df['股东户数-上次'], errors="coerce")
big_df['股东户数-增减'] = pd.to_numeric(big_df['股东户数-增减'], errors="coerce")
big_df['股东户数-增减比例'] = pd.to_numeric(big_df['股东户数-增减比例'], errors="coerce")
big_df['户均持股市值'] = pd.to_numeric(big_df['户均持股市值'])
big_df['户均持股数量'] = pd.to_numeric(big_df['户均持股数量'])
big_df['总市值'] = pd.to_numeric(big_df['总市值'])
big_df['总股本'] = pd.to_numeric(big_df['总股本'])
big_df['股本变动'] = pd.to_numeric(big_df['股本变动'])
big_df['股东户数统计截止日'] = pd.to_datetime(big_df['股东户数统计截止日']).dt.date
big_df['股东户数公告日期'] = pd.to_datetime(big_df['股东户数公告日期']).dt.date
big_df['户均持股市值'] = pd.to_numeric(big_df['户均持股市值'], errors="coerce")
big_df['户均持股数量'] = pd.to_numeric(big_df['户均持股数量'], errors="coerce")
big_df['总市值'] = pd.to_numeric(big_df['总市值'], errors="coerce")
big_df['总股本'] = pd.to_numeric(big_df['总股本'], errors="coerce")
big_df['股本变动'] = pd.to_numeric(big_df['股本变动'], errors="coerce")
big_df['股东户数统计截止日'] = pd.to_datetime(big_df['股东户数统计截止日'], errors="coerce").dt.date
big_df['股东户数公告日期'] = pd.to_datetime(big_df['股东户数公告日期'], errors="coerce").dt.date
return big_df


if __name__ == "__main__":
stock_zh_a_gdhs_df = stock_zh_a_gdhs(symbol='20210930')
stock_zh_a_gdhs_df = stock_zh_a_gdhs(symbol='20230930')
print(stock_zh_a_gdhs_df)

stock_zh_a_gdhs_detail_em_df = stock_zh_a_gdhs_detail_em(symbol="000002")
stock_zh_a_gdhs_detail_em_df = stock_zh_a_gdhs_detail_em(symbol="000001")
print(stock_zh_a_gdhs_detail_em_df)
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@

## 更新说明详情

1.12.5 fix: fix stock_zh_a_gdhs interface

1. 修复 stock_zh_a_gdhs 接口

1.12.4 fix: fix tool_trade_date_hist_sina interface

1. 修复 tool_trade_date_hist_sina 接口
Expand Down Expand Up @@ -3277,6 +3281,8 @@

## 版本更新说明

1.12.5 fix: fix stock_zh_a_gdhs interface

1.12.4 fix: fix tool_trade_date_hist_sina interface

1.12.3 fix: fix stock_gdfx_free_holding_teamwork_em interface
Expand Down
Loading

0 comments on commit 201a2c1

Please sign in to comment.