akshare 1.16.58__py3-none-any.whl → 1.16.60__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- akshare/__init__.py +7 -3
- akshare/option/option_czce.py +34 -6
- akshare/stock_a/stock_board_concept_name_em.py +171 -0
- akshare/stock_a/stock_individual_fund_flow_rank.py +258 -0
- {akshare-1.16.58.dist-info → akshare-1.16.60.dist-info}/METADATA +1 -1
- {akshare-1.16.58.dist-info → akshare-1.16.60.dist-info}/RECORD +9 -7
- {akshare-1.16.58.dist-info → akshare-1.16.60.dist-info}/WHEEL +1 -1
- {akshare-1.16.58.dist-info → akshare-1.16.60.dist-info}/licenses/LICENSE +0 -0
- {akshare-1.16.58.dist-info → akshare-1.16.60.dist-info}/top_level.txt +0 -0
akshare/__init__.py
CHANGED
@@ -3067,9 +3067,11 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
|
|
3067
3067
|
1.16.56 fix: fix stock_zh_a_daily interface
|
3068
3068
|
1.16.57 fix: fix stock_market_pe_lg interface
|
3069
3069
|
1.16.58 fix: fix stock_zh_a_spot interface
|
3070
|
+
1.16.59 fix: fix option_czce_hist interface
|
3071
|
+
1.16.60 fix: fix stock_individual_fund_flow_rank interface
|
3070
3072
|
"""
|
3071
3073
|
|
3072
|
-
__version__ = "1.16.
|
3074
|
+
__version__ = "1.16.60"
|
3073
3075
|
__author__ = "AKFamily"
|
3074
3076
|
|
3075
3077
|
import sys
|
@@ -3095,6 +3097,8 @@ del sys
|
|
3095
3097
|
异步接口
|
3096
3098
|
"""
|
3097
3099
|
from akshare.stock_a.stock_zh_a_spot import stock_zh_a_spot_em
|
3100
|
+
from akshare.stock_a.stock_individual_fund_flow_rank import stock_individual_fund_flow_rank
|
3101
|
+
from akshare.stock_a.stock_board_concept_name_em import stock_board_concept_name_em
|
3098
3102
|
|
3099
3103
|
"""
|
3100
3104
|
雪球-个股-公司概况-公司简介
|
@@ -4138,7 +4142,7 @@ from akshare.stock.stock_board_concept_em import (
|
|
4138
4142
|
stock_board_concept_cons_em,
|
4139
4143
|
stock_board_concept_hist_em,
|
4140
4144
|
stock_board_concept_hist_min_em,
|
4141
|
-
stock_board_concept_name_em,
|
4145
|
+
# stock_board_concept_name_em,
|
4142
4146
|
stock_board_concept_spot_em,
|
4143
4147
|
)
|
4144
4148
|
|
@@ -4781,7 +4785,7 @@ from akshare.stock.stock_fund_em import (
|
|
4781
4785
|
stock_individual_fund_flow,
|
4782
4786
|
stock_market_fund_flow,
|
4783
4787
|
stock_sector_fund_flow_rank,
|
4784
|
-
stock_individual_fund_flow_rank,
|
4788
|
+
# stock_individual_fund_flow_rank,
|
4785
4789
|
stock_sector_fund_flow_summary,
|
4786
4790
|
stock_sector_fund_flow_hist,
|
4787
4791
|
stock_concept_fund_flow_hist,
|
akshare/option/option_czce.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env python
|
2
2
|
# -*- coding:utf-8 -*-
|
3
3
|
"""
|
4
|
-
Date:
|
4
|
+
Date: 2025/3/22 16:30
|
5
5
|
Desc: 郑州商品交易所-交易数据-历史行情下载-期权历史行情下载
|
6
6
|
http://www.czce.com.cn/cn/jysj/lshqxz/H770319index_1.htm
|
7
7
|
自 20200101 起,成交量、空盘量、成交额、行权量均为单边计算
|
@@ -12,7 +12,21 @@ http://www.czce.com.cn/cn/jysj/lshqxz/H770319index_1.htm
|
|
12
12
|
"MA": "20191217"
|
13
13
|
"RM": "20200116"
|
14
14
|
"ZC": "20200630"
|
15
|
+
"OI": "20220826"
|
16
|
+
"PK": "20220826"
|
17
|
+
"PX": "20230915"
|
18
|
+
"SH": "20230915"
|
19
|
+
"SA": "20231020"
|
20
|
+
"PF": "20231020"
|
21
|
+
"SM": "20231020"
|
22
|
+
"SF": "20231020"
|
23
|
+
"UR": "20231020"
|
24
|
+
"AP": "20231020"
|
25
|
+
"CJ": "20240621"
|
26
|
+
"FG": "20240621"
|
27
|
+
"PR": "20241227"
|
15
28
|
"""
|
29
|
+
|
16
30
|
from io import StringIO
|
17
31
|
import warnings
|
18
32
|
|
@@ -24,7 +38,9 @@ def option_czce_hist(symbol: str = "SR", year: str = "2021") -> pd.DataFrame:
|
|
24
38
|
"""
|
25
39
|
郑州商品交易所-交易数据-历史行情下载-期权历史行情下载
|
26
40
|
http://www.czce.com.cn/cn/jysj/lshqxz/H770319index_1.htm
|
27
|
-
:param symbol: choice of {"白糖": "SR", "棉花": "CF", "PTA": "TA", "甲醇": "MA", "菜籽粕": "RM",
|
41
|
+
:param symbol: choice of {"白糖": "SR", "棉花": "CF", "PTA": "TA", "甲醇": "MA", "菜籽粕": "RM",
|
42
|
+
"动力煤": "ZC", "菜籽油": "OI", "花生": "PK", "对二甲苯": "PX", "烧碱": "SH", "纯碱": "SA", "短纤": "PF",
|
43
|
+
"锰硅": "SM", "硅铁": "SF", "尿素": "UR", "苹果": "AP", "红枣": "CJ", "玻璃": "FG", "瓶片": "PR"}
|
28
44
|
:type symbol: str
|
29
45
|
:param year: 需要获取数据的年份, 注意品种的上市时间
|
30
46
|
:type year: str
|
@@ -38,17 +54,29 @@ def option_czce_hist(symbol: str = "SR", year: str = "2021") -> pd.DataFrame:
|
|
38
54
|
"MA": "2019",
|
39
55
|
"RM": "2020",
|
40
56
|
"ZC": "2020",
|
57
|
+
"OI": "2022",
|
58
|
+
"PK": "2022",
|
59
|
+
"PX": "2023",
|
60
|
+
"SH": "2023",
|
61
|
+
"SA": "2023",
|
62
|
+
"PF": "2023",
|
63
|
+
"SM": "2023",
|
64
|
+
"SF": "2023",
|
65
|
+
"UR": "2023",
|
66
|
+
"AP": "2023",
|
67
|
+
"CJ": "2024",
|
68
|
+
"FG": "2024",
|
69
|
+
"PR": "2024",
|
41
70
|
}
|
42
71
|
if int(symbol_year_dict[symbol]) > int(year):
|
43
72
|
warnings.warn(f"{year} year, symbol {symbol} is not on trade")
|
44
|
-
return
|
45
|
-
|
46
|
-
url = f'http://www.czce.com.cn/cn/DFSStaticFiles/Option/2021/OptionDataAllHistory/{symbol}OPTIONS{year}.txt'
|
73
|
+
return pd.DataFrame()
|
74
|
+
url = f"http://www.czce.com.cn/cn/DFSStaticFiles/Option/{year}/OptionDataAllHistory/{symbol}OPTIONS{year}.txt"
|
47
75
|
r = requests.get(url)
|
48
76
|
option_df = pd.read_table(StringIO(r.text), skiprows=1, sep="|", low_memory=False)
|
49
77
|
return option_df
|
50
78
|
|
51
79
|
|
52
80
|
if __name__ == "__main__":
|
53
|
-
option_czce_hist_df = option_czce_hist(symbol="
|
81
|
+
option_czce_hist_df = option_czce_hist(symbol="RM", year="2025")
|
54
82
|
print(option_czce_hist_df)
|
@@ -0,0 +1,171 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding:utf-8 -*-
|
3
|
+
"""
|
4
|
+
Date: 2025/3/22 18:00
|
5
|
+
Desc: 东方财富网-行情中心-沪深京板块-概念板块-名称
|
6
|
+
https://quote.eastmoney.com/center/boardlist.html#concept_board
|
7
|
+
异步接口-测试版
|
8
|
+
"""
|
9
|
+
|
10
|
+
import asyncio
|
11
|
+
from typing import Dict, List
|
12
|
+
|
13
|
+
import aiohttp
|
14
|
+
import pandas as pd
|
15
|
+
|
16
|
+
|
17
|
+
async def fetch_single_page(
|
18
|
+
session: aiohttp.ClientSession, url: str, params: Dict
|
19
|
+
) -> Dict:
|
20
|
+
"""异步获取单页数据"""
|
21
|
+
async with session.get(url, params=params, ssl=False) as response:
|
22
|
+
return await response.json()
|
23
|
+
|
24
|
+
|
25
|
+
async def fetch_all_pages_async(url: str, base_params: Dict) -> List[Dict]:
|
26
|
+
"""异步获取所有页面数据"""
|
27
|
+
# 首先获取总数以计算页数
|
28
|
+
first_page_params = base_params.copy()
|
29
|
+
first_page_params["pn"] = "1"
|
30
|
+
|
31
|
+
async with aiohttp.ClientSession() as session:
|
32
|
+
first_page_data = await fetch_single_page(session, url, first_page_params)
|
33
|
+
|
34
|
+
# 检查是否成功获取数据
|
35
|
+
if first_page_data.get("rc") != 0 or not first_page_data.get("data"):
|
36
|
+
return [first_page_data] # 返回错误信息
|
37
|
+
|
38
|
+
total = first_page_data["data"]["total"]
|
39
|
+
page_size = int(base_params["pz"])
|
40
|
+
total_pages = (total + page_size - 1) // page_size
|
41
|
+
|
42
|
+
# 限制页数,避免过大请求
|
43
|
+
total_pages = min(total_pages, 100)
|
44
|
+
|
45
|
+
# 创建所有页面的任务
|
46
|
+
tasks = []
|
47
|
+
for page in range(1, total_pages + 1):
|
48
|
+
page_params = base_params.copy()
|
49
|
+
page_params["pn"] = str(page)
|
50
|
+
tasks.append(fetch_single_page(session, url, page_params))
|
51
|
+
|
52
|
+
# 并发执行所有任务
|
53
|
+
results = await asyncio.gather(*tasks)
|
54
|
+
return results
|
55
|
+
|
56
|
+
|
57
|
+
def process_concept_board_data(page_results: List[Dict]) -> pd.DataFrame:
|
58
|
+
"""处理概念板块数据,转换为DataFrame"""
|
59
|
+
all_data = []
|
60
|
+
|
61
|
+
for result in page_results:
|
62
|
+
if result.get("data") and result["data"].get("diff"):
|
63
|
+
page_data = result["data"]["diff"]
|
64
|
+
all_data.extend(page_data)
|
65
|
+
|
66
|
+
if not all_data:
|
67
|
+
return pd.DataFrame()
|
68
|
+
|
69
|
+
temp_df = pd.DataFrame(all_data)
|
70
|
+
|
71
|
+
# 转换数值类型,确保排序正确
|
72
|
+
numeric_columns = ["f2", "f3", "f4", "f8", "f20", "f104", "f105", "f136"]
|
73
|
+
for col in numeric_columns:
|
74
|
+
if col in temp_df.columns:
|
75
|
+
temp_df[col] = pd.to_numeric(temp_df[col], errors="coerce")
|
76
|
+
|
77
|
+
# 按涨跌幅(f3)降序排序
|
78
|
+
if "f3" in temp_df.columns:
|
79
|
+
temp_df.sort_values(by="f3", ascending=False, inplace=True)
|
80
|
+
|
81
|
+
# 重命名列
|
82
|
+
columns_map = {
|
83
|
+
"f2": "最新价",
|
84
|
+
"f3": "涨跌幅",
|
85
|
+
"f4": "涨跌额",
|
86
|
+
"f8": "换手率",
|
87
|
+
"f12": "板块代码",
|
88
|
+
"f14": "板块名称",
|
89
|
+
"f20": "总市值",
|
90
|
+
"f104": "上涨家数",
|
91
|
+
"f105": "下跌家数",
|
92
|
+
"f128": "领涨股票",
|
93
|
+
"f136": "领涨股票-涨跌幅",
|
94
|
+
}
|
95
|
+
|
96
|
+
# 选择需要的列并重命名
|
97
|
+
selected_columns = list(columns_map.keys())
|
98
|
+
available_columns = [col for col in selected_columns if col in temp_df.columns]
|
99
|
+
temp_df = temp_df[available_columns]
|
100
|
+
temp_df.rename(columns=columns_map, inplace=True)
|
101
|
+
|
102
|
+
# 重置索引并添加排名列
|
103
|
+
temp_df.reset_index(drop=True, inplace=True)
|
104
|
+
temp_df.insert(0, "排名", range(1, len(temp_df) + 1))
|
105
|
+
|
106
|
+
# 调整列顺序,与原函数保持一致
|
107
|
+
final_columns = [
|
108
|
+
"排名",
|
109
|
+
"板块名称",
|
110
|
+
"板块代码",
|
111
|
+
"最新价",
|
112
|
+
"涨跌额",
|
113
|
+
"涨跌幅",
|
114
|
+
"总市值",
|
115
|
+
"换手率",
|
116
|
+
"上涨家数",
|
117
|
+
"下跌家数",
|
118
|
+
"领涨股票",
|
119
|
+
"领涨股票-涨跌幅",
|
120
|
+
]
|
121
|
+
|
122
|
+
# 只保留存在的列
|
123
|
+
final_columns = [col for col in final_columns if col in temp_df.columns]
|
124
|
+
temp_df = temp_df[final_columns]
|
125
|
+
|
126
|
+
return temp_df
|
127
|
+
|
128
|
+
|
129
|
+
async def stock_board_concept_name_em_async() -> pd.DataFrame:
|
130
|
+
"""
|
131
|
+
异步获取东方财富网-行情中心-沪深京板块-概念板块-名称
|
132
|
+
https://quote.eastmoney.com/center/boardlist.html#concept_board
|
133
|
+
:return: 概念板块-名称
|
134
|
+
:rtype: pandas.DataFrame
|
135
|
+
"""
|
136
|
+
url = "https://79.push2.eastmoney.com/api/qt/clist/get"
|
137
|
+
params = {
|
138
|
+
"pn": "1",
|
139
|
+
"pz": "100",
|
140
|
+
"po": "1", # 按涨跌幅排序,1为降序
|
141
|
+
"np": "1",
|
142
|
+
"ut": "bd1d9ddb04089700cf9c27f6f7426281",
|
143
|
+
"fltt": "2",
|
144
|
+
"invt": "2",
|
145
|
+
"fid": "f3", # 按涨跌幅排序
|
146
|
+
"fs": "m:90 t:3 f:!50",
|
147
|
+
"fields": "f2,f3,f4,f8,f12,f14,f15,f16,f17,f18,f20,f21,f24,f25,f22,f33,f11,f62,f128,f124,f107,f104,f105,f136",
|
148
|
+
"_": "1626075887768",
|
149
|
+
}
|
150
|
+
|
151
|
+
results = await fetch_all_pages_async(url, params)
|
152
|
+
return process_concept_board_data(results)
|
153
|
+
|
154
|
+
|
155
|
+
def stock_board_concept_name_em() -> pd.DataFrame:
|
156
|
+
"""
|
157
|
+
东方财富网-行情中心-沪深京板块-概念板块-名称 (同步接口)
|
158
|
+
https://quote.eastmoney.com/center/boardlist.html#concept_board
|
159
|
+
:return: 概念板块-名称
|
160
|
+
:rtype: pandas.DataFrame
|
161
|
+
"""
|
162
|
+
import nest_asyncio
|
163
|
+
|
164
|
+
nest_asyncio.apply()
|
165
|
+
return asyncio.run(stock_board_concept_name_em_async())
|
166
|
+
|
167
|
+
|
168
|
+
if __name__ == "__main__":
|
169
|
+
# 测试同步接口
|
170
|
+
stock_board_concept_name_em_df = stock_board_concept_name_em()
|
171
|
+
print(stock_board_concept_name_em_df)
|
@@ -0,0 +1,258 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding:utf-8 -*-
|
3
|
+
"""
|
4
|
+
Date: 2025/3/22 18:00
|
5
|
+
Desc: 东方财富网-数据中心-资金流向-排名
|
6
|
+
https://data.eastmoney.com/zjlx/detail.html
|
7
|
+
异步接口-测试版
|
8
|
+
"""
|
9
|
+
|
10
|
+
import asyncio
|
11
|
+
from typing import Dict, List
|
12
|
+
|
13
|
+
import aiohttp
|
14
|
+
import pandas as pd
|
15
|
+
|
16
|
+
|
17
|
+
async def fetch_single_page(
|
18
|
+
session: aiohttp.ClientSession, url: str, params: Dict
|
19
|
+
) -> Dict:
|
20
|
+
"""异步获取单页数据"""
|
21
|
+
async with session.get(url, params=params, ssl=False) as response:
|
22
|
+
return await response.json()
|
23
|
+
|
24
|
+
|
25
|
+
async def fetch_all_pages_async(url: str, base_params: Dict) -> List[Dict]:
|
26
|
+
"""异步获取所有页面数据"""
|
27
|
+
# 首先获取总数以计算页数
|
28
|
+
first_page_params = base_params.copy()
|
29
|
+
first_page_params["pn"] = "1"
|
30
|
+
|
31
|
+
async with aiohttp.ClientSession() as session:
|
32
|
+
first_page_data = await fetch_single_page(session, url, first_page_params)
|
33
|
+
|
34
|
+
# 检查是否成功获取数据
|
35
|
+
if first_page_data.get("rc") != 0 or not first_page_data.get("data"):
|
36
|
+
return [first_page_data] # 返回错误信息
|
37
|
+
|
38
|
+
total = first_page_data["data"]["total"]
|
39
|
+
page_size = int(base_params["pz"])
|
40
|
+
total_pages = (total + page_size - 1) // page_size
|
41
|
+
|
42
|
+
# 限制页数,避免过大请求
|
43
|
+
total_pages = min(total_pages, 100)
|
44
|
+
|
45
|
+
# 创建所有页面的任务
|
46
|
+
tasks = []
|
47
|
+
for page in range(1, total_pages + 1):
|
48
|
+
page_params = base_params.copy()
|
49
|
+
page_params["pn"] = str(page)
|
50
|
+
tasks.append(fetch_single_page(session, url, page_params))
|
51
|
+
|
52
|
+
# 并发执行所有任务
|
53
|
+
results = await asyncio.gather(*tasks)
|
54
|
+
return results
|
55
|
+
|
56
|
+
|
57
|
+
def process_fund_flow_data(page_results: List[Dict], indicator: str) -> pd.DataFrame:
|
58
|
+
"""处理资金流向排名数据,转换为DataFrame"""
|
59
|
+
all_data = []
|
60
|
+
|
61
|
+
for result in page_results:
|
62
|
+
if result.get("data") and result["data"].get("diff"):
|
63
|
+
page_data = result["data"]["diff"]
|
64
|
+
all_data.extend(page_data)
|
65
|
+
|
66
|
+
if not all_data:
|
67
|
+
return pd.DataFrame()
|
68
|
+
|
69
|
+
temp_df = pd.DataFrame(all_data)
|
70
|
+
|
71
|
+
# 根据不同的指标设置列名并选择需要的列
|
72
|
+
if indicator == "今日":
|
73
|
+
columns_map = {
|
74
|
+
"f12": "代码",
|
75
|
+
"f14": "名称",
|
76
|
+
"f2": "最新价",
|
77
|
+
"f3": "今日涨跌幅",
|
78
|
+
"f62": "今日主力净流入-净额",
|
79
|
+
"f184": "今日主力净流入-净占比",
|
80
|
+
"f66": "今日超大单净流入-净额",
|
81
|
+
"f69": "今日超大单净流入-净占比",
|
82
|
+
"f72": "今日大单净流入-净额",
|
83
|
+
"f75": "今日大单净流入-净占比",
|
84
|
+
"f78": "今日中单净流入-净额",
|
85
|
+
"f81": "今日中单净流入-净占比",
|
86
|
+
"f84": "今日小单净流入-净额",
|
87
|
+
"f87": "今日小单净流入-净占比",
|
88
|
+
}
|
89
|
+
main_column = "f62" # 今日主力净流入-净额
|
90
|
+
|
91
|
+
elif indicator == "3日":
|
92
|
+
columns_map = {
|
93
|
+
"f12": "代码",
|
94
|
+
"f14": "名称",
|
95
|
+
"f2": "最新价",
|
96
|
+
"f127": "3日涨跌幅",
|
97
|
+
"f267": "3日主力净流入-净额",
|
98
|
+
"f268": "3日主力净流入-净占比",
|
99
|
+
"f269": "3日超大单净流入-净额",
|
100
|
+
"f270": "3日超大单净流入-净占比",
|
101
|
+
"f271": "3日大单净流入-净额",
|
102
|
+
"f272": "3日大单净流入-净占比",
|
103
|
+
"f273": "3日中单净流入-净额",
|
104
|
+
"f274": "3日中单净流入-净占比",
|
105
|
+
"f275": "3日小单净流入-净额",
|
106
|
+
"f276": "3日小单净流入-净占比",
|
107
|
+
}
|
108
|
+
main_column = "f267" # 3日主力净流入-净额
|
109
|
+
|
110
|
+
elif indicator == "5日":
|
111
|
+
columns_map = {
|
112
|
+
"f12": "代码",
|
113
|
+
"f14": "名称",
|
114
|
+
"f2": "最新价",
|
115
|
+
"f109": "5日涨跌幅",
|
116
|
+
"f164": "5日主力净流入-净额",
|
117
|
+
"f165": "5日主力净流入-净占比",
|
118
|
+
"f166": "5日超大单净流入-净额",
|
119
|
+
"f167": "5日超大单净流入-净占比",
|
120
|
+
"f168": "5日大单净流入-净额",
|
121
|
+
"f169": "5日大单净流入-净占比",
|
122
|
+
"f170": "5日中单净流入-净额",
|
123
|
+
"f171": "5日中单净流入-净占比",
|
124
|
+
"f172": "5日小单净流入-净额",
|
125
|
+
"f173": "5日小单净流入-净占比",
|
126
|
+
}
|
127
|
+
main_column = "f164" # 5日主力净流入-净额
|
128
|
+
|
129
|
+
elif indicator == "10日":
|
130
|
+
columns_map = {
|
131
|
+
"f12": "代码",
|
132
|
+
"f14": "名称",
|
133
|
+
"f2": "最新价",
|
134
|
+
"f160": "10日涨跌幅",
|
135
|
+
"f174": "10日主力净流入-净额",
|
136
|
+
"f175": "10日主力净流入-净占比",
|
137
|
+
"f176": "10日超大单净流入-净额",
|
138
|
+
"f177": "10日超大单净流入-净占比",
|
139
|
+
"f178": "10日大单净流入-净额",
|
140
|
+
"f179": "10日大单净流入-净占比",
|
141
|
+
"f180": "10日中单净流入-净额",
|
142
|
+
"f181": "10日中单净流入-净占比",
|
143
|
+
"f182": "10日小单净流入-净额",
|
144
|
+
"f183": "10日小单净流入-净占比",
|
145
|
+
}
|
146
|
+
main_column = "f174" # 10日主力净流入-净额
|
147
|
+
|
148
|
+
# 确保数值型列为数值类型
|
149
|
+
numeric_columns = [
|
150
|
+
col
|
151
|
+
for col in temp_df.columns
|
152
|
+
if col.startswith("f") and col not in ["f12", "f14"]
|
153
|
+
]
|
154
|
+
for col in numeric_columns:
|
155
|
+
if col in temp_df.columns:
|
156
|
+
temp_df[col] = pd.to_numeric(temp_df[col], errors="coerce")
|
157
|
+
|
158
|
+
# 按照主力净流入额降序排序
|
159
|
+
if main_column in temp_df.columns:
|
160
|
+
temp_df.sort_values(by=main_column, ascending=False, inplace=True)
|
161
|
+
|
162
|
+
# 首先重命名列
|
163
|
+
temp_df.rename(columns=columns_map, inplace=True)
|
164
|
+
|
165
|
+
# 选择需要的列
|
166
|
+
selected_columns = list(columns_map.values())
|
167
|
+
available_columns = [col for col in selected_columns if col in temp_df.columns]
|
168
|
+
temp_df = temp_df[available_columns]
|
169
|
+
|
170
|
+
# 重置索引并生成序号列
|
171
|
+
temp_df.reset_index(drop=True, inplace=True)
|
172
|
+
temp_df.insert(0, "序号", range(1, len(temp_df) + 1))
|
173
|
+
|
174
|
+
return temp_df
|
175
|
+
|
176
|
+
|
177
|
+
async def stock_individual_fund_flow_rank_async(indicator: str = "5日") -> pd.DataFrame:
|
178
|
+
"""
|
179
|
+
异步获取东方财富网-数据中心-资金流向-排名
|
180
|
+
https://data.eastmoney.com/zjlx/detail.html
|
181
|
+
:param indicator: choice of {"今日", "3日", "5日", "10日"}
|
182
|
+
:type indicator: str
|
183
|
+
:return: 指定 indicator 资金流向排行
|
184
|
+
:rtype: pandas.DataFrame
|
185
|
+
"""
|
186
|
+
indicator_map = {
|
187
|
+
"今日": [
|
188
|
+
"f62",
|
189
|
+
"f12,f14,f2,f3,f62,f184,f66,f69,f72,f75,f78,f81,f84,f87,f204,f205,f124",
|
190
|
+
],
|
191
|
+
"3日": [
|
192
|
+
"f267",
|
193
|
+
"f12,f14,f2,f127,f267,f268,f269,f270,f271,f272,f273,f274,f275,f276,f257,f258,f124",
|
194
|
+
],
|
195
|
+
"5日": [
|
196
|
+
"f164",
|
197
|
+
"f12,f14,f2,f109,f164,f165,f166,f167,f168,f169,f170,f171,f172,f173,f257,f258,f124",
|
198
|
+
],
|
199
|
+
"10日": [
|
200
|
+
"f174",
|
201
|
+
"f12,f14,f2,f160,f174,f175,f176,f177,f178,f179,f180,f181,f182,f183,f260,f261,f124",
|
202
|
+
],
|
203
|
+
}
|
204
|
+
|
205
|
+
url = "https://push2.eastmoney.com/api/qt/clist/get"
|
206
|
+
params = {
|
207
|
+
"fid": indicator_map[indicator][0],
|
208
|
+
"po": "1", # 按照降序排列
|
209
|
+
"pz": "100", # 每页100条
|
210
|
+
"pn": "1", # 从第1页开始
|
211
|
+
"np": "1",
|
212
|
+
"fltt": "2",
|
213
|
+
"invt": "2",
|
214
|
+
"ut": "b2884a393a59ad64002292a3e90d46a5",
|
215
|
+
"fs": "m:0+t:6+f:!2,m:0+t:13+f:!2,m:0+t:80+f:!2,m:1+t:2+f:!2,m:1+t:23+f:!2,m:0+t:7+f:!2,m:1+t:3+f:!2",
|
216
|
+
"fields": indicator_map[indicator][1],
|
217
|
+
}
|
218
|
+
|
219
|
+
results = await fetch_all_pages_async(url, params)
|
220
|
+
return process_fund_flow_data(results, indicator)
|
221
|
+
|
222
|
+
|
223
|
+
def stock_individual_fund_flow_rank(indicator: str = "5日") -> pd.DataFrame:
|
224
|
+
"""
|
225
|
+
东方财富网-数据中心-资金流向-排名 (同步接口)
|
226
|
+
https://data.eastmoney.com/zjlx/detail.html
|
227
|
+
:param indicator: choice of {"今日", "3日", "5日", "10日"}
|
228
|
+
:type indicator: str
|
229
|
+
:return: 指定 indicator 资金流向排行
|
230
|
+
:rtype: pandas.DataFrame
|
231
|
+
"""
|
232
|
+
import nest_asyncio
|
233
|
+
|
234
|
+
nest_asyncio.apply()
|
235
|
+
return asyncio.run(stock_individual_fund_flow_rank_async(indicator))
|
236
|
+
|
237
|
+
|
238
|
+
if __name__ == "__main__":
|
239
|
+
# 测试同步接口
|
240
|
+
stock_individual_fund_flow_rank_df = stock_individual_fund_flow_rank(
|
241
|
+
indicator="今日"
|
242
|
+
)
|
243
|
+
print(stock_individual_fund_flow_rank_df)
|
244
|
+
|
245
|
+
stock_individual_fund_flow_rank_df = stock_individual_fund_flow_rank(
|
246
|
+
indicator="3日"
|
247
|
+
)
|
248
|
+
print(stock_individual_fund_flow_rank_df)
|
249
|
+
|
250
|
+
stock_individual_fund_flow_rank_df = stock_individual_fund_flow_rank(
|
251
|
+
indicator="5日"
|
252
|
+
)
|
253
|
+
print(stock_individual_fund_flow_rank_df)
|
254
|
+
|
255
|
+
stock_individual_fund_flow_rank_df = stock_individual_fund_flow_rank(
|
256
|
+
indicator="10日"
|
257
|
+
)
|
258
|
+
print(stock_individual_fund_flow_rank_df)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
akshare/__init__.py,sha256=
|
1
|
+
akshare/__init__.py,sha256=gYwMK-te457YyNDH-L4RzmTa46Ix42084gAuwuGGUrM,192091
|
2
2
|
akshare/datasets.py,sha256=rKuRNZrqi6IMsZ9nyvO3Rx02js0tH3zMLjz8HQNAoPQ,963
|
3
3
|
akshare/exceptions.py,sha256=WEJjIhSmJ_xXNW6grwV4nufE_cfmmyuhmueVGiN1VAg,878
|
4
4
|
akshare/request.py,sha256=HtFFf9MhfEibR-ETWe-1Tts6ELU4VKSqA-ghaXjegQM,4252
|
@@ -197,7 +197,7 @@ akshare/option/cons.py,sha256=zTRZ62RFwOcAKfmso-7nZJtT3a8Dt1nQbNnEjSqgjpI,4811
|
|
197
197
|
akshare/option/option_comm_qihuo.py,sha256=kjbdp-94KJJJi1ex5U03abtlgviqwP0Aahb6FwddPkk,3128
|
198
198
|
akshare/option/option_commodity.py,sha256=KQ690k83wKnjYN5Sf3meLx0pvEYAc5dE2tOkv3AK3dk,26758
|
199
199
|
akshare/option/option_commodity_sina.py,sha256=r6qK_K7w3A6Uqp5ZtBb4pW7vH04oMyeCEZLLGqi0jpA,7776
|
200
|
-
akshare/option/option_czce.py,sha256=
|
200
|
+
akshare/option/option_czce.py,sha256=TxmLZn6hxjZa8TyEpwhZazL2m5XbympRHaRjJw1q7lk,2509
|
201
201
|
akshare/option/option_daily_stats_sse_szse.py,sha256=Ip_vE81qbEGt4ocbtWfUT7XGu0HWU0zKkzauZeq9RJA,4962
|
202
202
|
akshare/option/option_em.py,sha256=SV_pBGDE4rer1wZ3wsBsfjtOIIudBAHPuk6_5kPAPBc,5860
|
203
203
|
akshare/option/option_finance.py,sha256=7rnEeHo-7Sddrs36Q4c99CXL_9m8IJzw9S1Aqh3Bw90,12568
|
@@ -289,6 +289,8 @@ akshare/stock/stock_zh_b_sina.py,sha256=-sd0wG4zETsgrJSXivww4YieXfnVMNSfh3phsX_X
|
|
289
289
|
akshare/stock/stock_zh_kcb_report.py,sha256=7zRovNGqXrPIYtUj9C3ivlYzfiudkaeBNiYPYlzDWkQ,2914
|
290
290
|
akshare/stock/stock_zh_kcb_sina.py,sha256=ZKFoyq9Y-6LhBoYERc4Oqv5q3Llpne7ngDIZcCs8Yq0,9862
|
291
291
|
akshare/stock_a/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
292
|
+
akshare/stock_a/stock_board_concept_name_em.py,sha256=lcHzY_hetx-1orFM7J5gHRy1s84nnMGFwJzhxgKu2Js,5313
|
293
|
+
akshare/stock_a/stock_individual_fund_flow_rank.py,sha256=WBB8j2swF5WNlsfIk2kW4NzbhsozON2HXU5AiTYFgRw,8996
|
292
294
|
akshare/stock_a/stock_zh_a_spot.py,sha256=9gznZujzJ-awj7p4Ma_n5orGPpvyOc8RmSy695aFca8,6485
|
293
295
|
akshare/stock_feature/__init__.py,sha256=c2VDBGyg8nWZYLvtnnSqUoQ92Cu6dJ7UFOeJsB2Gff8,82
|
294
296
|
akshare/stock_feature/cons.py,sha256=UgwXlae3UpVRuhTt33nP-jmhNyug2mZLzuMgLja6pbA,465
|
@@ -390,10 +392,10 @@ akshare/utils/func.py,sha256=4cwmXFztU86yJNONJ40KJLvsIEQHBbct4iMm3zT2v30,2315
|
|
390
392
|
akshare/utils/multi_decrypt.py,sha256=aWoL2iEPeuXHJg8-n7OtMKixLnIhfzepACgxfrfmQB4,1657
|
391
393
|
akshare/utils/token_process.py,sha256=K4rGXjh_tgugbRcyOK2h2x0jP3PT65IIK7nxhUKhOeQ,666
|
392
394
|
akshare/utils/tqdm.py,sha256=MuPNwcswkOGjwWQOMWXi9ZvQ_RmW4obCWRj2i7HM7FE,847
|
393
|
-
akshare-1.16.
|
395
|
+
akshare-1.16.60.dist-info/licenses/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
|
394
396
|
tests/__init__.py,sha256=gNzhlO0UPjFq6Ieb38kaVIODXv4cTDByrdohAZnDYt4,82
|
395
397
|
tests/test_func.py,sha256=j1MGYbZI2if2j_LY1S4FLsf4qfq4NwVqD5wmRlv5Log,832
|
396
|
-
akshare-1.16.
|
397
|
-
akshare-1.16.
|
398
|
-
akshare-1.16.
|
399
|
-
akshare-1.16.
|
398
|
+
akshare-1.16.60.dist-info/METADATA,sha256=v9xEmqFvkD_za59kLO9KUkzg1ZiCSI0Co1XDf1vlVjo,13767
|
399
|
+
akshare-1.16.60.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
400
|
+
akshare-1.16.60.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
|
401
|
+
akshare-1.16.60.dist-info/RECORD,,
|
File without changes
|
File without changes
|