Skip to content

Commit

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

* fix stock_zt_pool_dtgc_em

* update date
  • Loading branch information
albertandking committed Nov 7, 2023
1 parent d6ba2de commit 5d292c8
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 44 deletions.
3 changes: 2 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2575,9 +2575,10 @@
1.11.59 fix: fix fund_portfolio_change_em interface
1.11.60 fix: fix bond_china_close_return interface
1.11.61 fix: fix fund_manager_em interface
1.11.62 fix: fix stock_zt_pool_dtgc_em interface
"""

__version__ = "1.11.61"
__version__ = "1.11.62"
__author__ = "AKFamily"

import sys
Expand Down
68 changes: 41 additions & 27 deletions akshare/stock_feature/stock_ztb_em.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Date: 2023/10/31 18:00
Date: 2023/11/7 17:00
Desc: 首页-行情中心-涨停板行情-涨停股池
https://quote.eastmoney.com/ztb/detail#type=ztgc
Expand All @@ -14,6 +14,8 @@
6. 跌停股池:包含当日当前跌停的所有A股股票。
注:涨停板行情专题统计不包含ST股票及科创板股票。
"""
from datetime import datetime, timedelta

import pandas as pd
import requests

Expand Down Expand Up @@ -62,9 +64,9 @@ def stock_zt_pool_em(date: str = "20220426") -> pd.DataFrame:
"涨停统计",
]
temp_df["涨停统计"] = (
temp_df["涨停统计"].apply(lambda x: dict(x)["days"]).astype(str)
+ "/"
+ temp_df["涨停统计"].apply(lambda x: dict(x)["ct"]).astype(str)
temp_df["涨停统计"].apply(lambda x: dict(x)["days"]).astype(str)
+ "/"
+ temp_df["涨停统计"].apply(lambda x: dict(x)["ct"]).astype(str)
)
temp_df = temp_df[
[
Expand Down Expand Up @@ -145,9 +147,9 @@ def stock_zt_pool_previous_em(date: str = "20210521") -> pd.DataFrame:
"涨停统计",
]
temp_df["涨停统计"] = (
temp_df["涨停统计"].apply(lambda x: dict(x)["days"]).astype(str)
+ "/"
+ temp_df["涨停统计"].apply(lambda x: dict(x)["ct"]).astype(str)
temp_df["涨停统计"].apply(lambda x: dict(x)["days"]).astype(str)
+ "/"
+ temp_df["涨停统计"].apply(lambda x: dict(x)["ct"]).astype(str)
)
temp_df = temp_df[
[
Expand Down Expand Up @@ -220,9 +222,9 @@ def stock_zt_pool_strong_em(date: str = "20210521") -> pd.DataFrame:
"所属行业",
]
temp_df["涨停统计"] = (
temp_df["涨停统计"].apply(lambda x: dict(x)["days"]).astype(str)
+ "/"
+ temp_df["涨停统计"].apply(lambda x: dict(x)["ct"]).astype(str)
temp_df["涨停统计"].apply(lambda x: dict(x)["days"]).astype(str)
+ "/"
+ temp_df["涨停统计"].apply(lambda x: dict(x)["ct"]).astype(str)
)
temp_df = temp_df[
[
Expand All @@ -249,7 +251,7 @@ def stock_zt_pool_strong_em(date: str = "20210521") -> pd.DataFrame:
return temp_df


def stock_zt_pool_sub_new_em(date: str = "20210525") -> pd.DataFrame:
def stock_zt_pool_sub_new_em(date: str = "20231107") -> pd.DataFrame:
"""
东方财富网-行情中心-涨停板行情-次新股池
https://quote.eastmoney.com/ztb/detail#type=cxgc
Expand All @@ -268,7 +270,7 @@ def stock_zt_pool_sub_new_em(date: str = "20210525") -> pd.DataFrame:
}
r = requests.get(url, params=params)
data_json = r.json()
if data_json["data"] is None:
if data_json["data"]["pool"] == 0:
return pd.DataFrame()
temp_df = pd.DataFrame(data_json["data"]["pool"])
temp_df.reset_index(inplace=True)
Expand All @@ -295,9 +297,9 @@ def stock_zt_pool_sub_new_em(date: str = "20210525") -> pd.DataFrame:
"所属行业",
]
temp_df["涨停统计"] = (
temp_df["涨停统计"].apply(lambda x: dict(x)["days"]).astype(str)
+ "/"
+ temp_df["涨停统计"].apply(lambda x: dict(x)["ct"]).astype(str)
temp_df["涨停统计"].apply(lambda x: dict(x)["days"]).astype(str)
+ "/"
+ temp_df["涨停统计"].apply(lambda x: dict(x)["ct"]).astype(str)
)
temp_df = temp_df[
[
Expand All @@ -322,17 +324,24 @@ def stock_zt_pool_sub_new_em(date: str = "20210525") -> pd.DataFrame:
temp_df["最新价"] = temp_df["最新价"] / 1000
temp_df["涨停价"] = temp_df["涨停价"] / 1000
temp_df.loc[temp_df["涨停价"] > 100000, "涨停价"] = pd.NA
temp_df['开板日期'] = pd.to_datetime(temp_df['开板日期'], format='%Y%m%d')
temp_df['上市日期'] = pd.to_datetime(temp_df['上市日期'], format='%Y%m%d')
temp_df.loc[temp_df["上市日期"] == 0, "上市日期"] = pd.NaT
return temp_df


def stock_zt_pool_zbgc_em(date: str = "20210525") -> pd.DataFrame:
def stock_zt_pool_zbgc_em(date: str = "20231107") -> pd.DataFrame:
"""
东方财富网-行情中心-涨停板行情-炸板股池
https://quote.eastmoney.com/ztb/detail#type=zbgc
:return: 炸板股池
:rtype: pandas.DataFrame
"""
thirty_days_ago = datetime.now() - timedelta(days=30)
thirty_days_ago_str = thirty_days_ago.strftime("%Y%m%d")
if int(date) < int(thirty_days_ago_str):
raise ValueError("炸板股池只能获取最近 30 个交易日的数据")

url = "http://push2ex.eastmoney.com/getTopicZBPool"
params = {
"ut": "7eea3edcaed734bea9cbfc24409ed989",
Expand Down Expand Up @@ -370,9 +379,9 @@ def stock_zt_pool_zbgc_em(date: str = "20210525") -> pd.DataFrame:
"所属行业",
]
temp_df["涨停统计"] = (
temp_df["涨停统计"].apply(lambda x: dict(x)["days"]).astype(str)
+ "/"
+ temp_df["涨停统计"].apply(lambda x: dict(x)["ct"]).astype(str)
temp_df["涨停统计"].apply(lambda x: dict(x)["days"]).astype(str)
+ "/"
+ temp_df["涨停统计"].apply(lambda x: dict(x)["ct"]).astype(str)
)
temp_df = temp_df[
[
Expand Down Expand Up @@ -400,7 +409,7 @@ def stock_zt_pool_zbgc_em(date: str = "20210525") -> pd.DataFrame:
return temp_df


def stock_zt_pool_dtgc_em(date: str = "20220425") -> pd.DataFrame:
def stock_zt_pool_dtgc_em(date: str = "20231106") -> pd.DataFrame:
"""
东方财富网-行情中心-涨停板行情-跌停股池
https://quote.eastmoney.com/ztb/detail#type=dtgc
Expand All @@ -409,6 +418,11 @@ def stock_zt_pool_dtgc_em(date: str = "20220425") -> pd.DataFrame:
:return: 跌停股池
:rtype: pandas.DataFrame
"""
thirty_days_ago = datetime.now() - timedelta(days=30)
thirty_days_ago_str = thirty_days_ago.strftime("%Y%m%d")
if int(date) < int(thirty_days_ago_str):
raise ValueError("跌停股池只能获取最近 30 个交易日的数据")

url = "http://push2ex.eastmoney.com/getTopicDTPool"
params = {
"ut": "7eea3edcaed734bea9cbfc24409ed989",
Expand All @@ -421,7 +435,7 @@ def stock_zt_pool_dtgc_em(date: str = "20220425") -> pd.DataFrame:
}
r = requests.get(url, params=params)
data_json = r.json()
if data_json["data"] is None:
if len(data_json["data"]["pool"]) == 0:
return pd.DataFrame()
temp_df = pd.DataFrame(data_json["data"]["pool"])
temp_df.reset_index(inplace=True)
Expand Down Expand Up @@ -485,20 +499,20 @@ def stock_zt_pool_dtgc_em(date: str = "20220425") -> pd.DataFrame:


if __name__ == "__main__":
stock_zt_pool_em_df = stock_zt_pool_em(date="20231011")
stock_zt_pool_em_df = stock_zt_pool_em(date="20231107")
print(stock_zt_pool_em_df)

stock_zt_pool_previous_em_df = stock_zt_pool_previous_em(date="20231011")
stock_zt_pool_previous_em_df = stock_zt_pool_previous_em(date="20231107")
print(stock_zt_pool_previous_em_df)

stock_zt_pool_strong_em_df = stock_zt_pool_strong_em(date="20231011")
stock_zt_pool_strong_em_df = stock_zt_pool_strong_em(date="20231107")
print(stock_zt_pool_strong_em_df)

stock_zt_pool_sub_new_em_df = stock_zt_pool_sub_new_em(date="20231011")
stock_zt_pool_sub_new_em_df = stock_zt_pool_sub_new_em(date="20231107")
print(stock_zt_pool_sub_new_em_df)

stock_zt_pool_zbgc_em_df = stock_zt_pool_zbgc_em(date="20231011")
stock_zt_pool_zbgc_em_df = stock_zt_pool_zbgc_em(date="20231107")
print(stock_zt_pool_zbgc_em_df)

stock_zt_pool_dtgc_em_df = stock_zt_pool_dtgc_em(date="20231011")
stock_zt_pool_dtgc_em_df = stock_zt_pool_dtgc_em(date="20231103")
print(stock_zt_pool_dtgc_em_df)
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@

## 更新说明详情

1.11.62 fix: fix stock_zt_pool_dtgc_em interface

1. 修复 stock_zt_pool_dtgc_em 接口

1.11.61 fix: fix fund_manager_em interface

1. 修复 fund_manager_em 接口
Expand Down Expand Up @@ -3088,6 +3092,8 @@

## 版本更新说明

1.11.62 fix: fix stock_zt_pool_dtgc_em interface

1.11.61 fix: fix fund_manager_em interface

1.11.60 fix: fix bond_china_close_return interface
Expand Down
22 changes: 7 additions & 15 deletions docs/data/stock/stock.md
Original file line number Diff line number Diff line change
Expand Up @@ -21290,13 +21290,13 @@ print(stock_zt_pool_zbgc_em_df)

描述: 东方财富网-行情中心-涨停板行情-跌停股池

限量: 单次返回所有跌停股池数据
限量: 单次返回所有跌停股池数据; 该接口只能获取近 30 天的数据

输入参数

| 名称 | 类型 | 描述 |
|------|-----|-----------------|
| date | str | date='20210525' |
| date | str | date='20231106' |

输出参数

Expand Down Expand Up @@ -21324,25 +21324,17 @@ print(stock_zt_pool_zbgc_em_df)
```python
import akshare as ak

stock_zt_pool_dtgc_em_df = ak.stock_zt_pool_dtgc_em(date='20220425')
stock_zt_pool_dtgc_em_df = ak.stock_zt_pool_dtgc_em(date='20231103')
print(stock_zt_pool_dtgc_em_df)
```

数据示例

```
序号 代码 名称 涨跌幅 最新价 ... 最后封板时间 板上成交额 连续跌停 开板次数 所属行业
0 1 603956 威派格 -9.973521 10.20 ... 145442 2880480 1 10 专用设备
1 2 600171 上海贝岭 -9.970326 15.17 ... 150000 8317180 1 0 半导体
2 3 002388 新亚制程 -9.894737 4.28 ... 144533 6366928 1 8 电子元件
3 4 002837 英维克 -10.011732 23.01 ... 145639 4198378 1 2 专用设备
4 5 603819 神力股份 -10.018553 9.70 ... 145503 3126386 1 5 电机
.. ... ... ... ... ... ... ... ... ... ... ...
575 576 000665 湖北广电 -10.024155 7.45 ... 094739 451719450 2 3 文化传媒
576 577 603696 安记食品 -10.000000 11.97 ... 092504 813969576 1 0 食品饮料
577 578 000968 蓝焰控股 -9.983767 11.09 ... 093136 70800778 1 0 燃气
578 579 600508 上海能源 -10.005817 15.47 ... 092504 1264782398 1 0 煤炭行业
579 580 002251 步 步 高 -10.035212 10.22 ... 092500 777495698 2 0 商业百货
序号 代码 名称 涨跌幅 最新价 ... 最后封板时间 板上成交额 连续跌停 开板次数 所属行业
0 1 002898 赛隆药业 -9.989259 16.76 ... 112739 78033218 1 1 化学制药
1 2 002889 东方嘉盛 -9.997110 31.15 ... 101730 293982486 1 4 物流行业
[2 rows x 16 columns]
```

### 赚钱效应分析
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. 本文档更新时间:**2023-11-05**
1. 本文档更新时间:**2023-11-07**
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. 如果您的问题未能在文档中找到答案,您也可以加入 **AKShare-VIP QQ 群**: 为了提高问答质量,此群为收费群(一杯咖啡钱即可入群,赠送[《AKShare-初阶-使用教学》](https://zmj.xet.tech/s/wck86)视频课),可以添加 **AKShare-小助手** QQ:1254836886,由小助手邀请入群! ![](https://jfds-1252952517.cos.ap-chengdu.myqcloud.com/akshare/readme/qrcode/qr_code_1254836886.jpg)
Expand Down

0 comments on commit 5d292c8

Please sign in to comment.