Skip to content

Commit

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

* fix stock_hot_follow_xq

* fix stock_hk_profit_forecast_et
  • Loading branch information
albertandking authored Jan 7, 2024
1 parent b4aa8c9 commit 0ec1b65
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 70 deletions.
3 changes: 2 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2628,9 +2628,10 @@
1.12.13 fix: fix index_stock_cons_csindex interface
1.12.14 add: add stock_hk_profit_forecast_et interface
1.12.15 fix: fix stock_hk_profit_forecast_et interface
1.12.16 fix: fix stock_hot_follow_xq interface
"""

__version__ = "1.12.15"
__version__ = "1.12.16"
__author__ = "AKFamily"

import sys
Expand Down
85 changes: 58 additions & 27 deletions akshare/stock_feature/stock_hot_xq.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# -*- coding:utf-8 -*-
# !/usr/bin/env python
"""
Date: 2022/4/27 17:01
Date: 2024/1/7 17:00
Desc: 雪球-沪深股市-热度排行榜
https://xueqiu.com/hq
"""
import math

import pandas as pd
import requests

from akshare.utils.tqdm import get_tqdm


def stock_hot_follow_xq(symbol: str = "本周新增") -> pd.DataFrame:
def stock_hot_follow_xq(symbol: str = "最热门") -> pd.DataFrame:
"""
雪球-沪深股市-热度排行榜-关注排行榜
https://xueqiu.com/hq
Expand All @@ -25,7 +29,7 @@ def stock_hot_follow_xq(symbol: str = "本周新增") -> pd.DataFrame:
url = "https://xueqiu.com/service/v5/stock/screener/screen"
params = {
"category": "CN",
"size": "10000",
"size": "200",
"order": "desc",
"order_by": symbol_map[symbol],
"only_count": "0",
Expand All @@ -52,9 +56,18 @@ def stock_hot_follow_xq(symbol: str = "本周新增") -> pd.DataFrame:
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
total_num = data_json["data"]['count']
total_page = math.ceil(total_num / 200)
tqdm = get_tqdm()
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page + 1), leave=False):
params.update({"page": page})
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
if symbol == "本周新增":
temp_df = temp_df[
big_df = big_df[
[
"symbol",
"name",
Expand All @@ -63,26 +76,26 @@ def stock_hot_follow_xq(symbol: str = "本周新增") -> pd.DataFrame:
]
]
else:
temp_df = temp_df[
big_df = big_df[
[
"symbol",
"name",
"follow",
"current",
]
]
temp_df.columns = [
big_df.columns = [
"股票代码",
"股票简称",
"关注",
"最新价",
]
temp_df["关注"] = pd.to_numeric(temp_df["关注"])
temp_df["最新价"] = pd.to_numeric(temp_df["最新价"])
return temp_df
big_df["关注"] = pd.to_numeric(big_df["关注"], errors="coerce")
big_df["最新价"] = pd.to_numeric(big_df["最新价"], errors="coerce")
return big_df


def stock_hot_tweet_xq(symbol: str = "本周新增") -> pd.DataFrame:
def stock_hot_tweet_xq(symbol: str = "最热门") -> pd.DataFrame:
"""
雪球-沪深股市-热度排行榜-讨论排行榜
https://xueqiu.com/hq
Expand All @@ -98,7 +111,7 @@ def stock_hot_tweet_xq(symbol: str = "本周新增") -> pd.DataFrame:
url = "https://xueqiu.com/service/v5/stock/screener/screen"
params = {
"category": "CN",
"size": "10000",
"size": "200",
"order": "desc",
"order_by": symbol_map[symbol],
"only_count": "0",
Expand All @@ -125,9 +138,18 @@ def stock_hot_tweet_xq(symbol: str = "本周新增") -> pd.DataFrame:
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
total_num = data_json["data"]['count']
total_page = math.ceil(total_num / 200)
tqdm = get_tqdm()
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page + 1), leave=False):
params.update({"page": page})
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
if symbol == "本周新增":
temp_df = temp_df[
big_df = big_df[
[
"symbol",
"name",
Expand All @@ -136,26 +158,26 @@ def stock_hot_tweet_xq(symbol: str = "本周新增") -> pd.DataFrame:
]
]
else:
temp_df = temp_df[
big_df = big_df[
[
"symbol",
"name",
"tweet",
"current",
]
]
temp_df.columns = [
big_df.columns = [
"股票代码",
"股票简称",
"关注",
"最新价",
]
temp_df["关注"] = pd.to_numeric(temp_df["关注"])
temp_df["最新价"] = pd.to_numeric(temp_df["最新价"])
return temp_df
big_df["关注"] = pd.to_numeric(big_df["关注"], errors="coerce")
big_df["最新价"] = pd.to_numeric(big_df["最新价"], errors="coerce")
return big_df


def stock_hot_deal_xq(symbol: str = "本周新增") -> pd.DataFrame:
def stock_hot_deal_xq(symbol: str = "最热门") -> pd.DataFrame:
"""
雪球-沪深股市-热度排行榜-分享交易排行榜
https://xueqiu.com/hq
Expand Down Expand Up @@ -198,9 +220,18 @@ def stock_hot_deal_xq(symbol: str = "本周新增") -> pd.DataFrame:
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
total_num = data_json["data"]['count']
total_page = math.ceil(total_num / 200)
tqdm = get_tqdm()
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page + 1), leave=False):
params.update({"page": page})
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
if symbol == "本周新增":
temp_df = temp_df[
big_df = big_df[
[
"symbol",
"name",
Expand All @@ -209,23 +240,23 @@ def stock_hot_deal_xq(symbol: str = "本周新增") -> pd.DataFrame:
]
]
else:
temp_df = temp_df[
big_df = big_df[
[
"symbol",
"name",
"deal",
"current",
]
]
temp_df.columns = [
big_df.columns = [
"股票代码",
"股票简称",
"关注",
"最新价",
]
temp_df["关注"] = pd.to_numeric(temp_df["关注"])
temp_df["最新价"] = pd.to_numeric(temp_df["最新价"])
return temp_df
big_df["关注"] = pd.to_numeric(big_df["关注"], errors="coerce")
big_df["最新价"] = pd.to_numeric(big_df["最新价"], errors="coerce")
return big_df


if __name__ == "__main__":
Expand Down
3 changes: 1 addition & 2 deletions akshare/stock_fundamental/stock_profit_forecast_hk_etnet.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Date: 2024/1/6 15:00
Date: 2024/1/7 15:00
Desc: 东方财富网-数据中心-研究报告-盈利预测
https://data.eastmoney.com/report/profitforecast.jshtml
"""
Expand Down Expand Up @@ -59,7 +59,6 @@ def stock_hk_profit_forecast_et(symbol: str = "09999", indicator: str = "盈利
"最高 (百万港元)": "最高",
"最低 (百万元人民币)": "最低",
"最低 (百万港元)": "最低",

}, inplace=True)
temp_df['纯利/亏损'] = pd.to_numeric(temp_df['纯利/亏损'], errors='coerce')
temp_df['每股盈利/每股亏损'] = pd.to_numeric(temp_df['每股盈利/每股亏损'], errors='coerce')
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@

## 更新说明详情

1.12.16 fix: fix stock_hot_follow_xq interface

1. 修复 stock_hot_follow_xq 接口
2. 修复 stock_hot_tweet_xq 接口
3. 修复 stock_hot_deal_xq 接口

1.12.15 fix: fix stock_hk_profit_forecast_et interface

1. 修复 stock_hk_profit_forecast_et 接口
Expand Down Expand Up @@ -3330,6 +3336,8 @@

## 版本更新说明

1.12.16 fix: fix stock_hot_follow_xq interface

1.12.15 fix: fix stock_hk_profit_forecast_et interface

1.12.14 add: add stock_hk_profit_forecast_et interface
Expand Down
83 changes: 43 additions & 40 deletions docs/data/stock/stock.md
Original file line number Diff line number Diff line change
Expand Up @@ -20016,7 +20016,7 @@ print(stock_board_industry_hist_min_em_df)

描述: 雪球-沪深股市-热度排行榜-关注排行榜

限量: 单次返回所有股票的热度数据
限量: 单次返回指定 symbol 的排行数据

输入参数

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

```
股票代码 股票简称 关注 最新价
0 SH600519 贵州茅台 2305090.0 1794.92
1 SH601318 中国平安 1964067.0 43.91
2 SH600036 招商银行 1622413.0 38.04
3 SZ000651 格力电器 1403675.0 30.46
4 SZ000002 万科A 1110551.0 18.23
股票代码 股票简称 关注 最新价
0 SH600519 贵州茅台 2763065.0 1663.36
1 SH601318 中国平安 2321952.0 38.97
2 SH600036 招商银行 2039407.0 28.29
3 SZ000651 格力电器 1768422.0 32.98
4 SZ002594 比亚迪 1494585.0 192.68
... ... ... ...
4884 BJ831689 克莱特 162.0 9.50
4885 BJ832419 路斯股份 159.0 5.25
4886 BJ873169 七丰精工 120.0 6.12
4887 SZ000739 普洛药业 NaN 18.73
4888 SZ001203 大中矿业 NaN 11.11
5420 BJ836957 汉维科技 180.0 9.42
5421 BJ836942 恒立钻具 178.0 13.07
5422 BJ836419 万德股份 176.0 11.15
5423 BJ873690 N捷众 30.0 21.01
5424 SZ300307 慈星股份 NaN 6.20
[5425 rows x 4 columns]
```

##### 讨论排行榜
Expand All @@ -20067,7 +20068,7 @@ print(stock_hot_follow_xq_df)

描述: 雪球-沪深股市-热度排行榜-讨论排行榜

限量: 单次返回所有股票的热度数据
限量: 单次返回指定 symbol 的排行数据

输入参数

Expand Down Expand Up @@ -20096,29 +20097,30 @@ print(stock_hot_tweet_xq_df)
数据示例

```
股票代码 股票简称 关注 最新价
0 SH600519 贵州茅台 255129.0 1794.92
1 SH601919 中远海控 254436.0 13.93
2 SZ300750 宁德时代 177185.0 407.05
3 SZ002594 比亚迪 176794.0 235.01
4 SZ000651 格力电器 162797.0 30.46
... ... ... ...
4884 BJ838924 广脉科技 0.0 6.30
4885 BJ837212 智新电子 0.0 8.10
4886 BJ831305 海希通讯 0.0 20.05
4887 BJ830799 艾融软件 0.0 9.53
4888 SZ001203 大中矿业 NaN 11.11
股票代码 股票简称 关注 最新价
0 SZ002594 比亚迪 89745 192.680
1 SH600519 贵州茅台 85990 1663.360
2 SZ300750 宁德时代 52705 150.900
3 SZ000977 浪潮信息 50664 30.160
4 SZ002229 鸿博股份 46794 24.690
... ... ... ...
5420 SH900913 国新B股 0 0.246
5421 SH900901 云赛B股 0 0.496
5422 BJ870508 丰安股份 0 12.530
5423 BJ836149 旭杰科技 0 7.970
5424 BJ831175 派诺科技 0 22.490
[5425 rows x 4 columns]
```

##### 分享交易排行榜
##### 交易排行榜

接口: stock_hot_deal_xq

目标地址: https://xueqiu.com/hq

描述: 雪球-沪深股市-热度排行榜-分享交易排行榜
描述: 雪球-沪深股市-热度排行榜-交易排行榜

限量: 单次返回所有股票的热度数据
限量: 单次返回指定 symbol 的排行数据

输入参数

Expand Down Expand Up @@ -20147,18 +20149,19 @@ print(stock_hot_deal_xq_df)
数据示例

```
股票代码 股票简称 关注 最新价
0 SH601318 中国平安 529.0 43.91
1 SZ000002 万科A 299.0 18.23
2 SZ000651 格力电器 271.0 30.46
3 SH600519 贵州茅台 263.0 1794.92
4 SH600036 招商银行 217.0 38.04
... ... ... ...
4884 BJ838924 广脉科技 0.0 6.30
4885 BJ837212 智新电子 0.0 8.10
4886 BJ831305 海希通讯 0.0 20.05
4887 BJ830799 艾融软件 0.0 9.53
4888 SZ001203 大中矿业 NaN 11.11
股票代码 股票简称 关注 最新价
0 SH601318 中国平安 304 38.97
1 SZ002229 鸿博股份 258 24.69
2 SH600519 贵州茅台 257 1663.36
3 SZ002594 比亚迪 257 192.68
4 SH600880 博瑞传播 231 4.90
... ... ... ...
5420 SZ300932 三友联众 0 15.95
5421 SZ300956 英力股份 0 18.21
5422 SH688618 三旺通信 0 52.82
5423 BJ836149 旭杰科技 0 7.97
5424 SH688655 迅捷兴 0 14.64
[5425 rows x 4 columns]
```

#### 股票热度-问财
Expand Down

0 comments on commit 0ec1b65

Please sign in to comment.