Skip to content

Commit

Permalink
Date (#4279)
Browse files Browse the repository at this point in the history
* add version

* fix stock_comment_em
  • Loading branch information
albertandking authored Nov 14, 2023
1 parent 13bb474 commit e3a7b78
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 42 deletions.
3 changes: 2 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2587,9 +2587,10 @@
1.11.71 fix: fix stock_balance_sheet_by_report_em interface
1.11.72 fix: fix get_rank_sum_daily interface
1.11.73 fix: fix futures_comex_inventory interface
1.11.74 fix: fix stock_comment_em interface
"""

__version__ = "1.11.73"
__version__ = "1.11.74"
__author__ = "AKFamily"

import sys
Expand Down
55 changes: 26 additions & 29 deletions akshare/stock_feature/stock_comment_em.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Date: 2022/6/16 15:28
Date: 2023/11/14 20:20
Desc: 东方财富网-数据中心-特色数据-千股千评
http://data.eastmoney.com/stockcomment/
https://data.eastmoney.com/stockcomment/
"""
from datetime import datetime

import pandas as pd
import requests
from tqdm import tqdm

from akshare.utils.tqdm import get_tqdm


def stock_comment_em() -> pd.DataFrame:
"""
东方财富网-数据中心-特色数据-千股千评
http://data.eastmoney.com/stockcomment/
https://data.eastmoney.com/stockcomment/
:return: 千股千评数据
:rtype: pandas.DataFrame
"""
Expand All @@ -35,6 +36,7 @@ def stock_comment_em() -> pd.DataFrame:
data_json = r.json()
total_page = data_json["result"]["pages"]
big_df = pd.DataFrame()
tqdm = get_tqdm()
for page in tqdm(range(1, total_page + 1), leave=False):
params.update({"pageNumber": page})
r = requests.get(url, params=params)
Expand Down Expand Up @@ -135,10 +137,10 @@ def stock_comment_detail_zlkp_jgcyd_em(symbol: str = "600000") -> pd.DataFrame:
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df = temp_df[["TRADE_DATE", "ORG_PARTICIPATE"]]
temp_df.columns = ["date", "value"]
temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
temp_df["date"] = pd.to_datetime(temp_df["date"], errors="coerce").dt.date
temp_df.sort_values(["date"], inplace=True)
temp_df.reset_index(inplace=True, drop=True)
temp_df["value"] = pd.to_numeric(temp_df["value"]) * 100
temp_df["value"] = pd.to_numeric(temp_df["value"], errors="coerce") * 100
return temp_df


Expand All @@ -163,11 +165,11 @@ def stock_comment_detail_zhpj_lspf_em(symbol: str = "600000") -> pd.DataFrame:
).T
temp_df.columns = ["日期", "评分", "股价"]
temp_df["日期"] = str(datetime.now().year) + "-" + temp_df["日期"]
temp_df["日期"] = pd.to_datetime(temp_df["日期"]).dt.date
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
temp_df.sort_values(["日期"], inplace=True)
temp_df.reset_index(inplace=True, drop=True)
temp_df["评分"] = pd.to_numeric(temp_df["评分"])
temp_df["股价"] = pd.to_numeric(temp_df["股价"])
temp_df["评分"] = pd.to_numeric(temp_df["评分"], errors="coerce")
temp_df["股价"] = pd.to_numeric(temp_df["股价"], errors="coerce")
return temp_df


Expand All @@ -192,16 +194,16 @@ def stock_comment_detail_scrd_focus_em(symbol: str = "600000") -> pd.DataFrame:
).T
temp_df.columns = ["日期", "用户关注指数", "收盘价"]
temp_df["日期"] = str(datetime.now().year) + "-" + temp_df["日期"]
temp_df["日期"] = pd.to_datetime(temp_df["日期"]).dt.date
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
temp_df.sort_values(["日期"], inplace=True)
temp_df.reset_index(inplace=True, drop=True)
temp_df["用户关注指数"] = pd.to_numeric(temp_df["用户关注指数"])
temp_df["收盘价"] = pd.to_numeric(temp_df["收盘价"])
temp_df["用户关注指数"] = pd.to_numeric(temp_df["用户关注指数"], errors="coerce")
temp_df["收盘价"] = pd.to_numeric(temp_df["收盘价"], errors="coerce")
return temp_df


def stock_comment_detail_scrd_desire_em(
symbol: str = "600000",
symbol: str = "600000",
) -> pd.DataFrame:
"""
东方财富网-数据中心-特色数据-千股千评-市场热度-市场参与意愿
Expand Down Expand Up @@ -236,19 +238,17 @@ def stock_comment_detail_scrd_desire_em(
).T
temp_df.columns = ["日期时间", "大户", "全部", "散户"]
temp_df["日期时间"] = date_str + " " + temp_df["日期时间"]
temp_df["日期时间"] = pd.to_datetime(temp_df["日期时间"])

temp_df["日期时间"] = pd.to_datetime(temp_df["日期时间"], errors="coerce")
temp_df.sort_values(["日期时间"], inplace=True)
temp_df.reset_index(inplace=True, drop=True)
temp_df["大户"] = pd.to_numeric(temp_df["大户"])
temp_df["全部"] = pd.to_numeric(temp_df["全部"])
temp_df["散户"] = pd.to_numeric(temp_df["散户"])

temp_df["大户"] = pd.to_numeric(temp_df["大户"], errors="coerce")
temp_df["全部"] = pd.to_numeric(temp_df["全部"], errors="coerce")
temp_df["散户"] = pd.to_numeric(temp_df["散户"], errors="coerce")
return temp_df


def stock_comment_detail_scrd_desire_daily_em(
symbol: str = "600000",
symbol: str = "600000",
) -> pd.DataFrame:
"""
东方财富网-数据中心-特色数据-千股千评-市场热度-日度市场参与意愿
Expand Down Expand Up @@ -280,13 +280,12 @@ def stock_comment_detail_scrd_desire_daily_em(
).T
temp_df.columns = ["日期", "当日意愿下降", "五日累计意愿"]
temp_df["日期"] = date_str[:4] + "-" + temp_df["日期"]
temp_df["日期"] = pd.to_datetime(temp_df["日期"]).dt.date
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date

temp_df.sort_values(["日期"], inplace=True)
temp_df.reset_index(inplace=True, drop=True)
temp_df["当日意愿下降"] = pd.to_numeric(temp_df["当日意愿下降"])
temp_df["五日累计意愿"] = pd.to_numeric(temp_df["五日累计意愿"])

temp_df["当日意愿下降"] = pd.to_numeric(temp_df["当日意愿下降"], errors="coerce")
temp_df["五日累计意愿"] = pd.to_numeric(temp_df["五日累计意愿"], errors="coerce")
return temp_df


Expand Down Expand Up @@ -319,13 +318,11 @@ def stock_comment_detail_scrd_cost_em(symbol: str = "600000") -> pd.DataFrame:
).T
temp_df.columns = ["日期", "市场成本", "5日市场成本"]
temp_df["日期"] = date_str[:4] + "-" + temp_df["日期"]
temp_df["日期"] = pd.to_datetime(temp_df["日期"]).dt.date

temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
temp_df.sort_values(["日期"], inplace=True)
temp_df.reset_index(inplace=True, drop=True)
temp_df["市场成本"] = pd.to_numeric(temp_df["市场成本"])
temp_df["5日市场成本"] = pd.to_numeric(temp_df["5日市场成本"])

temp_df["市场成本"] = pd.to_numeric(temp_df["市场成本"], errors="coerce")
temp_df["5日市场成本"] = pd.to_numeric(temp_df["5日市场成本"], errors="coerce")
return temp_df


Expand Down
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.11.74 fix: fix stock_comment_em interface

1. 修复 stock_comment_em 接口

1.11.73 fix: fix futures_comex_inventory interface

1. 修复 futures_comex_inventory 接口
Expand Down Expand Up @@ -3137,6 +3141,8 @@

## 版本更新说明

1.11.74 fix: fix stock_comment_em interface

1.11.73 fix: fix futures_comex_inventory interface

1.11.72 fix: fix get_rank_sum_daily interface
Expand Down
25 changes: 13 additions & 12 deletions docs/data/stock/stock.md
Original file line number Diff line number Diff line change
Expand Up @@ -5535,7 +5535,7 @@ print(stock_em_analyst_detail_df)

接口: stock_comment_em

目标地址: http://data.eastmoney.com/stockcomment/
目标地址: https://data.eastmoney.com/stockcomment/

描述: 东方财富网-数据中心-特色数据-千股千评

Expand Down Expand Up @@ -5578,18 +5578,19 @@ print(stock_comment_em_df)
数据示例

```
序号 代码 名称 最新价 ... 上升 目前排名 关注指数 交易日
0 1 000001 平安银行 16.42 ... -279 72 89.6 2022-04-15
1 2 000002 万 科A 21.30 ... 55 162 92.4 2022-04-15
2 3 000004 国华网安 16.92 ... 198 4160 67.6 2022-04-15
3 4 000005 ST星源 2.24 ... -493 3415 69.6 2022-04-15
4 5 000006 深振业A 4.99 ... 368 1112 76.8 2022-04-15
序号 代码 名称 最新价 ... 上升 目前排名 关注指数 交易日
0 1 000001 平安银行 10.27 ... -181 1471 86.0 2023-11-14
1 2 000002 万 科A 11.78 ... -443 1670 92.4 2023-11-14
2 3 000004 国华网安 19.44 ... 1783 4093 90.4 2023-11-14
3 4 000005 ST星源 1.41 ... -316 4688 69.6 2023-11-14
4 5 000006 深振业A 4.55 ... 1106 3434 70.4 2023-11-14
... ... ... ... ... ... ... ... ...
4605 4606 688799 华纳药厂 33.96 ... 419 1906 61.2 2022-04-15
4606 4607 688800 瑞可达 90.00 ... -1945 869 61.2 2022-04-15
4607 4608 688819 天能股份 28.37 ... 231 2340 67.2 2022-04-15
4608 4609 688981 中芯国际 43.25 ... 26 1048 82.4 2022-04-15
4609 4610 689009 九号公司-WD 40.20 ... -353 1223 50.0 2022-04-15
5031 5032 688799 华纳药厂 44.30 ... 70 1587 65.6 2023-11-14
5032 5033 688800 瑞可达 46.78 ... -1681 251 64.0 2023-11-14
5033 5034 688819 天能股份 31.65 ... -739 827 69.6 2023-11-14
5034 5035 688981 中芯国际 54.65 ... -555 2157 84.0 2023-11-14
5035 5036 689009 九号公司-WD 34.55 ... 214 1749 70.8 2023-11-14
[5036 rows x 14 columns]
```

### 千股千评详情
Expand Down

0 comments on commit e3a7b78

Please sign in to comment.