Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #5516

Merged
merged 4 commits into from
Jan 9, 2025
Merged

Dev #5516

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2977,9 +2977,10 @@
1.15.65 fix: fix option_czce_daily interface
1.15.66 fix: fix fund_etf_dividend_sina interface
1.15.67 fix: fix stock_hold_change_cninfo interface
1.15.68 fix: fix stock_research_report_em interface
"""

__version__ = "1.15.67"
__version__ = "1.15.68"
__author__ = "AKFamily"

import sys
Expand Down
64 changes: 46 additions & 18 deletions akshare/stock_feature/stock_research_report_em.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Date: 2023/8/20 20:00
Date: 2025/1/9 21:35
Desc: 东方财富网-数据中心-研究报告-个股研报
https://data.eastmoney.com/report/stock.jshtml
"""

import pandas as pd
import requests
from tqdm import tqdm

from akshare.utils.tqdm import get_tqdm


def stock_research_report_em(symbol: str = "000001") -> pd.DataFrame:
Expand Down Expand Up @@ -40,7 +42,9 @@ def stock_research_report_em(symbol: str = "000001") -> pd.DataFrame:
r = requests.get(url, params=params)
data_json = r.json()
total_page = data_json["TotalPage"]
current_year = data_json["currentYear"]
big_df = pd.DataFrame()
tqdm = get_tqdm()
for page in tqdm(range(1, total_page + 1), leave=False):
params.update(
{
Expand All @@ -53,9 +57,15 @@ def stock_research_report_em(symbol: str = "000001") -> pd.DataFrame:
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"])
big_df = pd.concat([big_df, temp_df], axis=0, ignore_index=True)
big_df = pd.concat(objs=[big_df, temp_df], axis=0, ignore_index=True)
big_df.reset_index(inplace=True)
big_df["index"] = big_df["index"] + 1
predict_this_year_eps_title = f"{current_year}-盈利预测-收益"
predict_this_year_pe_title = f"{current_year}-盈利预测-市盈率"
predict_next_year_eps_title = f"{current_year + 1}-盈利预测-收益"
predict_next_year_pe_title = f"{current_year + 1}-盈利预测-市盈率"
predict_next_two_year_eps_title = f"{current_year + 2}-盈利预测-收益"
predict_next_two_year_pe_title = f"{current_year + 2}-盈利预测-市盈率"
big_df.rename(
columns={
"index": "序号",
Expand All @@ -68,12 +78,12 @@ def stock_research_report_em(symbol: str = "000001") -> pd.DataFrame:
"publishDate": "日期",
"infoCode": "-",
"column": "-",
"predictNextTwoYearEps": "-",
"predictNextTwoYearPe": "-",
"predictNextYearEps": "2024-盈利预测-收益",
"predictNextYearPe": "2024-盈利预测-市盈率",
"predictThisYearEps": "2023-盈利预测-收益",
"predictThisYearPe": "2023-盈利预测-市盈率",
"predictNextTwoYearEps": predict_next_two_year_eps_title,
"predictNextTwoYearPe": predict_next_two_year_pe_title,
"predictNextYearEps": predict_next_year_eps_title,
"predictNextYearPe": predict_next_year_pe_title,
"predictThisYearEps": predict_this_year_eps_title,
"predictThisYearPe": predict_this_year_pe_title,
"predictLastYearEps": "-",
"predictLastYearPe": "-",
"actualLastTwoYearEps": "-",
Expand Down Expand Up @@ -122,20 +132,38 @@ def stock_research_report_em(symbol: str = "000001") -> pd.DataFrame:
"东财评级",
"机构",
"近一月个股研报数",
"2023-盈利预测-收益",
"2023-盈利预测-市盈率",
"2024-盈利预测-收益",
"2024-盈利预测-市盈率",
predict_this_year_eps_title,
predict_this_year_pe_title,
predict_next_year_eps_title,
predict_next_year_pe_title,
predict_next_two_year_eps_title,
predict_next_two_year_pe_title,
"行业",
"日期",
]
]
big_df["日期"] = pd.to_datetime(big_df["日期"], errors="coerce").dt.date
big_df["近一月个股研报数"] = pd.to_numeric(big_df["近一月个股研报数"], errors="coerce")
big_df["2023-盈利预测-收益"] = pd.to_numeric(big_df["2023-盈利预测-收益"], errors="coerce")
big_df["2023-盈利预测-市盈率"] = pd.to_numeric(big_df["2023-盈利预测-市盈率"], errors="coerce")
big_df["2024-盈利预测-收益"] = pd.to_numeric(big_df["2024-盈利预测-收益"], errors="coerce")
big_df["2024-盈利预测-市盈率"] = pd.to_numeric(big_df["2024-盈利预测-市盈率"], errors="coerce")
big_df["近一月个股研报数"] = pd.to_numeric(
big_df["近一月个股研报数"], errors="coerce"
)
big_df[predict_this_year_eps_title] = pd.to_numeric(
big_df[predict_this_year_eps_title], errors="coerce"
)
big_df[predict_this_year_pe_title] = pd.to_numeric(
big_df[predict_this_year_pe_title], errors="coerce"
)
big_df[predict_next_year_eps_title] = pd.to_numeric(
big_df[predict_next_year_eps_title], errors="coerce"
)
big_df[predict_next_year_pe_title] = pd.to_numeric(
big_df[predict_next_year_pe_title], errors="coerce"
)
big_df[predict_next_two_year_eps_title] = pd.to_numeric(
big_df[predict_next_two_year_eps_title], errors="coerce"
)
big_df[predict_next_two_year_pe_title] = pd.to_numeric(
big_df[predict_next_two_year_pe_title], errors="coerce"
)
return big_df


Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@

## 更新说明详情

1.15.68 fix: fix stock_research_report_em interface

1. 修复 stock_research_report_em 接口

1.15.67 fix: fix stock_hold_change_cninfo interface

1. 修复 stock_hold_change_cninfo 接口
Expand Down Expand Up @@ -4957,6 +4961,8 @@

## 版本更新说明

1.15.68 fix: fix stock_research_report_em interface

1.15.67 fix: fix stock_hold_change_cninfo interface

1.15.66 fix: fix fund_etf_dividend_sina interface
Expand Down
32 changes: 17 additions & 15 deletions docs/data/stock/stock.md
Original file line number Diff line number Diff line change
Expand Up @@ -10278,7 +10278,7 @@ print(stock_zdhtmx_em_df)
数据示例

```
序号 股票代码 股票简称 ... 最新财务报表的营业收入 签署日期 公告日期
序号 股票代码 股票简称 ... 最新财务报表的营业收入 签署日期 公告日期
0 1 688516 奥特维 ... NaN NaN 2023-08-18
1 2 688132 邦彦技术 ... NaN NaN 2023-08-18
2 3 831526 凯华材料 ... 5.101723e+07 NaN 2023-08-17
Expand Down Expand Up @@ -10320,10 +10320,12 @@ print(stock_zdhtmx_em_df)
| 东财评级 | object | - |
| 机构 | object | - |
| 近一月个股研报数 | int64 | - |
| 2023-盈利预测-收益 | float64 | - |
| 2023-盈利预测-市盈率 | float64 | - |
| 2024-盈利预测-收益 | float64 | - |
| 2024-盈利预测-市盈率 | float64 | - |
| 2025-盈利预测-收益 | float64 | - |
| 2025-盈利预测-市盈率 | float64 | - |
| 2026-盈利预测-收益 | float64 | - |
| 2026-盈利预测-市盈率 | float64 | - |
| 行业 | object | - |
| 日期 | object | - |

Expand All @@ -10339,19 +10341,19 @@ print(stock_research_report_em_df)
数据示例

```
序号 股票代码 股票简称 ... 2024-盈利预测-市盈率 行业 日期
0 1 000001 平安银行 ... 4.13 银行 2023-04-29
1 2 000001 平安银行 ... 3.80 银行 2023-04-26
2 3 000001 平安银行 ... 4.13 银行 2023-04-25
3 4 000001 平安银行 ... 3.51 银行 2023-04-25
4 5 000001 平安银行 ... 3.89 银行 2023-04-25
序号 股票代码 股票简称 ... 2026-盈利预测-市盈率 行业 日期
0 1 000001 平安银行 ... 4.54 银行 2024-10-22
1 2 000001 平安银行 ... 4.54 银行 2024-10-22
2 3 000001 平安银行 ... 4.90 银行 2024-10-20
3 4 000001 平安银行 ... NaN 银行 2024-10-19
4 5 000001 平安银行 ... 3.90 银行 2024-08-30
.. ... ... ... ... ... .. ...
296 297 000001 平安银行 ... NaN 银行 2017-03-22
297 298 000001 平安银行 ... NaN 银行 2017-03-20
298 299 000001 平安银行 ... NaN 银行 2017-03-17
299 300 000001 平安银行 ... NaN 银行 2017-03-07
300 301 000001 平安银行 ... NaN 银行 2017-02-03
[301 rows x 13 columns]
271 272 000001 平安银行 ... NaN 银行 2017-03-22
272 273 000001 平安银行 ... NaN 银行 2017-03-20
273 274 000001 平安银行 ... NaN 银行 2017-03-17
274 275 000001 平安银行 ... NaN 银行 2017-03-07
275 276 000001 平安银行 ... NaN 银行 2017-02-03
[276 rows x 15 columns]
```

#### 沪深京 A 股公告
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
**风险提示**:[AKShare](https://github.com/akfamily/akshare) 开源财经数据接口库所采集的数据皆来自公开的数据源,不涉及任何个人隐私数据和非公开数据。
同时本项目提供的数据接口及相关数据仅用于学术研究,任何个人、机构及团体使用本项目的数据接口及相关数据请注意商业风险。

1. 本文档更新时间:**2025-01-08**;
1. 本文档更新时间:**2025-01-09**;
2. 如有 [AKShare](https://github.com/akfamily/akshare) 库、文档及数据的相关问题,请在 [AKShare Issues](https://github.com/akfamily/akshare/issues) 中提 Issues;
3. 欢迎关注 **数据科学实战** 微信公众号;<div><img src="https://jfds-1252952517.cos.ap-chengdu.myqcloud.com/akshare/readme/qrcode/ds.png"></div>
4. **知识星球【数据科学实战】** 2025 全新改版,聚焦于量化投资内容,欢迎加入 **知识星球【数据科学实战】** 高质量社区,里面有丰富的视频课程、问答、文章、书籍及代码等内容:
Expand Down
Loading