akshare 1.14.62__py3-none-any.whl → 1.14.64__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.
Potentially problematic release.
This version of akshare might be problematic. Click here for more details.
- akshare/__init__.py +4 -1
- akshare/futures/cot.py +1 -1
- akshare/futures/futures_hq_sina.py +3 -2
- akshare/futures_derivative/futures_other_index_nh.py +43 -44
- akshare/spot/spot_sge.py +61 -9
- akshare/stock/stock_board_industry_em.py +40 -34
- {akshare-1.14.62.dist-info → akshare-1.14.64.dist-info}/METADATA +1 -1
- {akshare-1.14.62.dist-info → akshare-1.14.64.dist-info}/RECORD +11 -11
- {akshare-1.14.62.dist-info → akshare-1.14.64.dist-info}/WHEEL +1 -1
- {akshare-1.14.62.dist-info → akshare-1.14.64.dist-info}/LICENSE +0 -0
- {akshare-1.14.62.dist-info → akshare-1.14.64.dist-info}/top_level.txt +0 -0
akshare/__init__.py
CHANGED
|
@@ -2873,9 +2873,11 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
|
|
|
2873
2873
|
1.14.60 fix: fix bond_zh_cov_info_ths interface
|
|
2874
2874
|
1.14.61 fix: fix stock_fund_flow_individual interface
|
|
2875
2875
|
1.14.62 fix: fix stock_zt_pool_em interface
|
|
2876
|
+
1.14.63 add: add spot_quotations_sge interface
|
|
2877
|
+
1.14.64 fix: fix stock_board_industry_spot_em interface
|
|
2876
2878
|
"""
|
|
2877
2879
|
|
|
2878
|
-
__version__ = "1.14.
|
|
2880
|
+
__version__ = "1.14.64"
|
|
2879
2881
|
__author__ = "AKFamily"
|
|
2880
2882
|
|
|
2881
2883
|
import sys
|
|
@@ -3563,6 +3565,7 @@ from akshare.spot.spot_sge import (
|
|
|
3563
3565
|
spot_symbol_table_sge,
|
|
3564
3566
|
spot_silver_benchmark_sge,
|
|
3565
3567
|
spot_golden_benchmark_sge,
|
|
3568
|
+
spot_quotations_sge,
|
|
3566
3569
|
)
|
|
3567
3570
|
|
|
3568
3571
|
"""
|
akshare/futures/cot.py
CHANGED
|
@@ -1371,7 +1371,7 @@ if __name__ == "__main__":
|
|
|
1371
1371
|
print(futures_dce_position_rank_other_df)
|
|
1372
1372
|
|
|
1373
1373
|
# 广州期货交易所
|
|
1374
|
-
futures_gfex_position_rank_df = futures_gfex_position_rank(date="
|
|
1374
|
+
futures_gfex_position_rank_df = futures_gfex_position_rank(date="20240805")
|
|
1375
1375
|
print(futures_gfex_position_rank_df)
|
|
1376
1376
|
|
|
1377
1377
|
# 总接口
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/
|
|
4
|
+
Date: 2024/8/21 17:00
|
|
5
5
|
Desc: 新浪财经-外盘期货
|
|
6
6
|
https://finance.sina.com.cn/money/future/hf.html
|
|
7
7
|
"""
|
|
@@ -129,7 +129,8 @@ def futures_foreign_commodity_realtime(symbol: Union[str, List[str]]) -> pd.Data
|
|
|
129
129
|
"Sec-Fetch-Dest": "script",
|
|
130
130
|
"Sec-Fetch-Mode": "no-cors",
|
|
131
131
|
"Sec-Fetch-Site": "cross-site",
|
|
132
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
132
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
133
|
+
"Chrome/97.0.4692.71 Safari/537.36",
|
|
133
134
|
}
|
|
134
135
|
r = requests.get(url, headers=headers)
|
|
135
136
|
data_text = r.text
|
|
@@ -10,11 +10,14 @@ https://www.nanhua.net/nhzc/varietychange.html
|
|
|
10
10
|
南华期货-相关系数矩阵
|
|
11
11
|
https://www.nanhua.net/nhzc/correltable.html
|
|
12
12
|
"""
|
|
13
|
+
|
|
13
14
|
import pandas as pd
|
|
14
15
|
import requests
|
|
15
16
|
|
|
16
17
|
|
|
17
|
-
def futures_board_index_nh(
|
|
18
|
+
def futures_board_index_nh(
|
|
19
|
+
start_date: str = "20231110", end_date: str = "20231116"
|
|
20
|
+
) -> pd.DataFrame:
|
|
18
21
|
"""
|
|
19
22
|
南华期货-市场涨跌-板块指数涨跌
|
|
20
23
|
https://www.nanhua.net/nhzc/platechange.html
|
|
@@ -27,42 +30,40 @@ def futures_board_index_nh(start_date: str = "20231110", end_date: str = "202311
|
|
|
27
30
|
"""
|
|
28
31
|
# 获取 start_date 的数据
|
|
29
32
|
url = f"https://www.nanhua.net/ianalysis/plate/{start_date[:4]}/{start_date[4:6]}/{start_date}.json"
|
|
30
|
-
params = {
|
|
31
|
-
't': '1649920913503'
|
|
32
|
-
}
|
|
33
|
+
params = {"t": "1649920913503"}
|
|
33
34
|
r = requests.get(url, params=params)
|
|
34
35
|
start_df = pd.DataFrame(r.json())
|
|
35
36
|
start_df.columns = [
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
"name",
|
|
38
|
+
"code",
|
|
38
39
|
start_date,
|
|
39
40
|
]
|
|
40
41
|
|
|
41
42
|
# 获取 end_date 的数据
|
|
42
43
|
url = f"https://www.nanhua.net/ianalysis/plate/{end_date[:4]}/{end_date[4:6]}/{end_date}.json"
|
|
43
|
-
params = {
|
|
44
|
-
't': '1649920913503'
|
|
45
|
-
}
|
|
44
|
+
params = {"t": "1649920913503"}
|
|
46
45
|
r = requests.get(url, params=params)
|
|
47
46
|
end_df = pd.DataFrame(r.json())
|
|
48
47
|
end_df.columns = [
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
"name",
|
|
49
|
+
"code",
|
|
51
50
|
end_date,
|
|
52
51
|
]
|
|
53
52
|
end_df.reset_index(inplace=True, drop=True)
|
|
54
53
|
|
|
55
54
|
# 计算数据
|
|
56
|
-
start_df = start_df.merge(end_df, on=[
|
|
55
|
+
start_df = start_df.merge(end_df, on=["name", "code"], how="inner")
|
|
57
56
|
# 去除异常数据 IF
|
|
58
|
-
start_df = start_df[start_df[
|
|
59
|
-
start_df[
|
|
60
|
-
temp_df = start_df[[
|
|
57
|
+
start_df = start_df[start_df["code"] != "IF"]
|
|
58
|
+
start_df["return"] = start_df[end_date] / start_df[start_date] - 1
|
|
59
|
+
temp_df = start_df[["name", "return"]]
|
|
61
60
|
|
|
62
61
|
return temp_df
|
|
63
62
|
|
|
64
63
|
|
|
65
|
-
def futures_variety_index_nh(
|
|
64
|
+
def futures_variety_index_nh(
|
|
65
|
+
start_date: str = "20231110", end_date: str = "20231116"
|
|
66
|
+
) -> pd.DataFrame:
|
|
66
67
|
"""
|
|
67
68
|
南华期货-市场涨跌-品种指数涨跌
|
|
68
69
|
https://www.nanhua.net/nhzc/varietychange.html
|
|
@@ -74,35 +75,31 @@ def futures_variety_index_nh(start_date: str = "20231110", end_date: str = "2023
|
|
|
74
75
|
:rtype: pandas.DataFrame
|
|
75
76
|
"""
|
|
76
77
|
url = f"https://www.nanhua.net/ianalysis/variety/{start_date[:4]}/{start_date[4:6]}/{start_date}.json"
|
|
77
|
-
params = {
|
|
78
|
-
't': '1649920913503'
|
|
79
|
-
}
|
|
78
|
+
params = {"t": "1649920913503"}
|
|
80
79
|
r = requests.get(url, params=params)
|
|
81
80
|
start_df = pd.DataFrame(r.json())
|
|
82
81
|
start_df.columns = [
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
"name",
|
|
83
|
+
"code",
|
|
85
84
|
start_date,
|
|
86
85
|
]
|
|
87
86
|
|
|
88
87
|
url = f"http://www.nanhua.net/ianalysis/variety/{end_date[:4]}/{end_date[4:6]}/{end_date}.json"
|
|
89
|
-
params = {
|
|
90
|
-
't': '1649920913503'
|
|
91
|
-
}
|
|
88
|
+
params = {"t": "1649920913503"}
|
|
92
89
|
r = requests.get(url, params=params)
|
|
93
90
|
end_df = pd.DataFrame(r.json())
|
|
94
91
|
end_df.columns = [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
"name",
|
|
93
|
+
"code",
|
|
94
|
+
"end_date",
|
|
98
95
|
]
|
|
99
|
-
start_df[end_date] = end_df[
|
|
96
|
+
start_df[end_date] = end_df["end_date"]
|
|
100
97
|
|
|
101
|
-
start_df[
|
|
102
|
-
start_df[
|
|
98
|
+
start_df["gap"] = start_df[end_date] - start_df[start_date]
|
|
99
|
+
start_df["return"] = start_df["gap"] / start_df[start_date]
|
|
103
100
|
|
|
104
101
|
temp_df = start_df
|
|
105
|
-
temp_df = temp_df[[
|
|
102
|
+
temp_df = temp_df[["name", "return"]]
|
|
106
103
|
return temp_df
|
|
107
104
|
|
|
108
105
|
|
|
@@ -118,28 +115,30 @@ def futures_correlation_nh(date: str = "20231110", period: str = "20") -> pd.Dat
|
|
|
118
115
|
:rtype: pandas.DataFrame
|
|
119
116
|
"""
|
|
120
117
|
url = f"https://www.nanhua.net/ianalysis/correl/{period}/{date[:4]}/{date[4:6]}/{date}.json"
|
|
121
|
-
params = {
|
|
122
|
-
't': '1649920913503'
|
|
123
|
-
}
|
|
118
|
+
params = {"t": "1649920913503"}
|
|
124
119
|
r = requests.get(url, params=params)
|
|
125
120
|
temp_df = pd.DataFrame(r.json())
|
|
126
121
|
temp_df.columns = [
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
"品种代码1",
|
|
123
|
+
"品种名称1",
|
|
124
|
+
"品种代码2",
|
|
125
|
+
"品种名称2",
|
|
126
|
+
"相关系数",
|
|
132
127
|
]
|
|
133
|
-
temp_df[
|
|
128
|
+
temp_df["相关系数"] = pd.to_numeric(temp_df["相关系数"], errors="coerce")
|
|
134
129
|
return temp_df
|
|
135
130
|
|
|
136
131
|
|
|
137
|
-
if __name__ ==
|
|
138
|
-
futures_board_index_nh_df = futures_board_index_nh(
|
|
132
|
+
if __name__ == "__main__":
|
|
133
|
+
futures_board_index_nh_df = futures_board_index_nh(
|
|
134
|
+
start_date="20230103", end_date="20231201"
|
|
135
|
+
)
|
|
139
136
|
print(futures_board_index_nh_df)
|
|
140
137
|
|
|
141
|
-
futures_variety_index_nh_df = futures_variety_index_nh(
|
|
138
|
+
futures_variety_index_nh_df = futures_variety_index_nh(
|
|
139
|
+
start_date="20231110", end_date="20231116"
|
|
140
|
+
)
|
|
142
141
|
print(futures_variety_index_nh_df)
|
|
143
142
|
|
|
144
|
-
futures_correlation_nh_df = futures_correlation_nh(date="
|
|
143
|
+
futures_correlation_nh_df = futures_correlation_nh(date="20240816", period="20")
|
|
145
144
|
print(futures_correlation_nh_df)
|
akshare/spot/spot_sge.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding:utf-8 -*-
|
|
2
2
|
# !/usr/bin/env python
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/
|
|
4
|
+
Date: 2024/8/22 10:00
|
|
5
5
|
Desc: 上海黄金交易所-数据资讯-行情走势
|
|
6
6
|
https://www.sge.com.cn/sjzx/mrhq
|
|
7
7
|
上海黄金交易所-数据资讯-上海金基准价-历史数据
|
|
@@ -11,6 +11,8 @@ https://www.sge.com.cn/sjzx/mrhq
|
|
|
11
11
|
import pandas as pd
|
|
12
12
|
import requests
|
|
13
13
|
|
|
14
|
+
from akshare.utils.cons import headers
|
|
15
|
+
|
|
14
16
|
|
|
15
17
|
def spot_symbol_table_sge() -> pd.DataFrame:
|
|
16
18
|
"""
|
|
@@ -45,11 +47,63 @@ def spot_symbol_table_sge() -> pd.DataFrame:
|
|
|
45
47
|
return temp_df
|
|
46
48
|
|
|
47
49
|
|
|
50
|
+
def spot_quotations_sge(symbol: str = "Au99.99") -> pd.DataFrame:
|
|
51
|
+
"""
|
|
52
|
+
上海黄金交易所-实时行情数据
|
|
53
|
+
https://www.sge.com.cn/
|
|
54
|
+
https://www.sge.com.cn/graph/quotations
|
|
55
|
+
:param symbol: choice of {'Au99.99', 'Au99.95', 'Au100g', 'Pt99.95', 'Ag(T+D)', 'Au(T+D)',
|
|
56
|
+
'mAu(T+D)', 'Au(T+N1)', 'Au(T+N2)', 'Ag99.99', 'iAu99.99', 'Au99.5', 'iAu100g',
|
|
57
|
+
'iAu99.5', 'PGC30g', 'NYAuTN06', 'NYAuTN12'}; 可以通过 ak.spot_symbol_table_sge() 获取品种表
|
|
58
|
+
:type symbol: str
|
|
59
|
+
:return: 行情数据
|
|
60
|
+
:rtype: pandas.DataFrame
|
|
61
|
+
"""
|
|
62
|
+
url = "https://www.sge.com.cn/graph/quotations"
|
|
63
|
+
payload = {"instid": symbol}
|
|
64
|
+
headers = {
|
|
65
|
+
"Accept": "application/json, text/javascript, */*; q=0.01",
|
|
66
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
67
|
+
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
|
68
|
+
"Cache-Control": "no-cache",
|
|
69
|
+
"Connection": "keep-alive",
|
|
70
|
+
"Content-Length": "15",
|
|
71
|
+
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
|
72
|
+
"Host": "www.sge.com.cn",
|
|
73
|
+
"Origin": "https://www.sge.com.cn",
|
|
74
|
+
"Pragma": "no-cache",
|
|
75
|
+
"Referer": "https://www.sge.com.cn/",
|
|
76
|
+
"sec-ch-ua": '"Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24"',
|
|
77
|
+
"sec-ch-ua-mobile": "?0",
|
|
78
|
+
"sec-ch-ua-platform": '"Windows"',
|
|
79
|
+
"Sec-Fetch-Dest": "empty",
|
|
80
|
+
"Sec-Fetch-Mode": "cors",
|
|
81
|
+
"Sec-Fetch-Site": "same-origin",
|
|
82
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
83
|
+
"Chrome/107.0.0.0 Safari/537.36",
|
|
84
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
85
|
+
}
|
|
86
|
+
r = requests.get(url, data=payload, headers=headers)
|
|
87
|
+
data_json = r.json()
|
|
88
|
+
temp_df = pd.DataFrame(
|
|
89
|
+
{
|
|
90
|
+
"品种": data_json["heyue"],
|
|
91
|
+
"时间": data_json["times"],
|
|
92
|
+
"现价": data_json["data"],
|
|
93
|
+
"更新时间": data_json["delaystr"],
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
temp_df["现价"] = pd.to_numeric(temp_df["现价"], errors="coerce")
|
|
97
|
+
return temp_df
|
|
98
|
+
|
|
99
|
+
|
|
48
100
|
def spot_hist_sge(symbol: str = "Au99.99") -> pd.DataFrame:
|
|
49
101
|
"""
|
|
50
102
|
上海黄金交易所-数据资讯-行情走势-历史数据
|
|
51
103
|
https://www.sge.com.cn/sjzx/mrhq
|
|
52
|
-
:param symbol: choice of {'Au99.99', 'Au99.95', 'Au100g', 'Pt99.95', 'Ag(T+D)', 'Au(T+D)',
|
|
104
|
+
:param symbol: choice of {'Au99.99', 'Au99.95', 'Au100g', 'Pt99.95', 'Ag(T+D)', 'Au(T+D)',
|
|
105
|
+
'mAu(T+D)', 'Au(T+N1)', 'Au(T+N2)', 'Ag99.99', 'iAu99.99', 'Au99.5', 'iAu100g', 'iAu99.5',
|
|
106
|
+
'PGC30g', 'NYAuTN06', 'NYAuTN12'}; 可以通过 ak.spot_symbol_table_sge() 获取品种表
|
|
53
107
|
:type symbol: str
|
|
54
108
|
:return: 历史数据
|
|
55
109
|
:rtype: pandas.DataFrame
|
|
@@ -74,7 +128,8 @@ def spot_hist_sge(symbol: str = "Au99.99") -> pd.DataFrame:
|
|
|
74
128
|
"Sec-Fetch-Dest": "empty",
|
|
75
129
|
"Sec-Fetch-Mode": "cors",
|
|
76
130
|
"Sec-Fetch-Site": "same-origin",
|
|
77
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
131
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
132
|
+
"Chrome/107.0.0.0 Safari/537.36",
|
|
78
133
|
"X-Requested-With": "XMLHttpRequest",
|
|
79
134
|
}
|
|
80
135
|
r = requests.post(url, data=payload, headers=headers)
|
|
@@ -105,9 +160,6 @@ def spot_golden_benchmark_sge() -> pd.DataFrame:
|
|
|
105
160
|
"""
|
|
106
161
|
url = "https://www.sge.com.cn/graph/DayilyJzj"
|
|
107
162
|
payload = {}
|
|
108
|
-
headers = {
|
|
109
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36",
|
|
110
|
-
}
|
|
111
163
|
r = requests.post(url, data=payload, headers=headers)
|
|
112
164
|
data_json = r.json()
|
|
113
165
|
temp_df = pd.DataFrame(data_json["wp"])
|
|
@@ -139,9 +191,6 @@ def spot_silver_benchmark_sge() -> pd.DataFrame:
|
|
|
139
191
|
"""
|
|
140
192
|
url = "https://www.sge.com.cn/graph/DayilyShsilverJzj"
|
|
141
193
|
payload = {}
|
|
142
|
-
headers = {
|
|
143
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36",
|
|
144
|
-
}
|
|
145
194
|
r = requests.post(url, data=payload, headers=headers)
|
|
146
195
|
data_json = r.json()
|
|
147
196
|
temp_df = pd.DataFrame(data_json["wp"])
|
|
@@ -180,3 +229,6 @@ if __name__ == "__main__":
|
|
|
180
229
|
for spot in spot_symbol_table_sge_df["品种"].tolist():
|
|
181
230
|
spot_hist_sge_df = spot_hist_sge(symbol=spot)
|
|
182
231
|
print(spot_hist_sge_df)
|
|
232
|
+
|
|
233
|
+
spot_quotations_sge_df = spot_quotations_sge(symbol="Au99.99")
|
|
234
|
+
print(spot_quotations_sge_df)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/8/23 17:50
|
|
5
5
|
Desc: 东方财富-沪深板块-行业板块
|
|
6
6
|
https://quote.eastmoney.com/center/boardlist.html#industry_board
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import re
|
|
9
10
|
|
|
10
11
|
import pandas as pd
|
|
@@ -18,7 +19,7 @@ def stock_board_industry_name_em() -> pd.DataFrame:
|
|
|
18
19
|
:return: 行业板块-名称
|
|
19
20
|
:rtype: pandas.DataFrame
|
|
20
21
|
"""
|
|
21
|
-
url = "
|
|
22
|
+
url = "https://17.push2.eastmoney.com/api/qt/clist/get"
|
|
22
23
|
params = {
|
|
23
24
|
"pn": "1",
|
|
24
25
|
"pz": "2000",
|
|
@@ -29,7 +30,9 @@ def stock_board_industry_name_em() -> pd.DataFrame:
|
|
|
29
30
|
"invt": "2",
|
|
30
31
|
"fid": "f3",
|
|
31
32
|
"fs": "m:90 t:2 f:!50",
|
|
32
|
-
"fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,
|
|
33
|
+
"fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,"
|
|
34
|
+
"f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,"
|
|
35
|
+
"f140,f141,f207,f208,f209,f222",
|
|
33
36
|
"_": "1626075887768",
|
|
34
37
|
}
|
|
35
38
|
r = requests.get(url, params=params)
|
|
@@ -104,7 +107,9 @@ def stock_board_industry_name_em() -> pd.DataFrame:
|
|
|
104
107
|
temp_df["换手率"] = pd.to_numeric(temp_df["换手率"], errors="coerce")
|
|
105
108
|
temp_df["上涨家数"] = pd.to_numeric(temp_df["上涨家数"], errors="coerce")
|
|
106
109
|
temp_df["下跌家数"] = pd.to_numeric(temp_df["下跌家数"], errors="coerce")
|
|
107
|
-
temp_df["领涨股票-涨跌幅"] = pd.to_numeric(
|
|
110
|
+
temp_df["领涨股票-涨跌幅"] = pd.to_numeric(
|
|
111
|
+
temp_df["领涨股票-涨跌幅"], errors="coerce"
|
|
112
|
+
)
|
|
108
113
|
return temp_df
|
|
109
114
|
|
|
110
115
|
|
|
@@ -117,7 +122,7 @@ def stock_board_industry_spot_em(symbol: str = "小金属") -> pd.DataFrame:
|
|
|
117
122
|
:return: 实时行情
|
|
118
123
|
:rtype: pandas.DataFrame
|
|
119
124
|
"""
|
|
120
|
-
url = "
|
|
125
|
+
url = "https://91.push2.eastmoney.com/api/qt/stock/get"
|
|
121
126
|
field_map = {
|
|
122
127
|
"f43": "最新",
|
|
123
128
|
"f44": "最高",
|
|
@@ -131,14 +136,14 @@ def stock_board_industry_spot_em(symbol: str = "小金属") -> pd.DataFrame:
|
|
|
131
136
|
"f169": "涨跌额",
|
|
132
137
|
}
|
|
133
138
|
|
|
134
|
-
if re.match(r
|
|
139
|
+
if re.match(pattern=r"^BK\d+", string=symbol):
|
|
135
140
|
em_code = symbol
|
|
136
141
|
else:
|
|
137
142
|
industry_listing = stock_board_industry_name_em()
|
|
138
|
-
em_code = industry_listing.query(
|
|
143
|
+
em_code = industry_listing.query("板块名称 == @symbol")["板块代码"].values[0]
|
|
139
144
|
|
|
140
145
|
params = dict(
|
|
141
|
-
fields=
|
|
146
|
+
fields=",".join(field_map.keys()),
|
|
142
147
|
mpi="1000",
|
|
143
148
|
invt="2",
|
|
144
149
|
fltt="1",
|
|
@@ -150,22 +155,22 @@ def stock_board_industry_spot_em(symbol: str = "小金属") -> pd.DataFrame:
|
|
|
150
155
|
result = pd.DataFrame.from_dict(data_dict["data"], orient="index")
|
|
151
156
|
result.rename(field_map, inplace=True)
|
|
152
157
|
result.reset_index(inplace=True)
|
|
153
|
-
result.columns = [
|
|
154
|
-
result[
|
|
158
|
+
result.columns = ["item", "value"]
|
|
159
|
+
result["value"] = pd.to_numeric(result["value"], errors="coerce")
|
|
155
160
|
|
|
156
161
|
# 各项转换成正常单位. 除了成交量与成交额, 原始数据中已是正常单位(元)
|
|
157
|
-
result[
|
|
162
|
+
result["value"] = result["value"] * 1e-2
|
|
158
163
|
result.iloc[4, 1] = result.iloc[4, 1] * 1e2
|
|
159
164
|
result.iloc[5, 1] = result.iloc[5, 1] * 1e2
|
|
160
165
|
return result
|
|
161
166
|
|
|
162
167
|
|
|
163
168
|
def stock_board_industry_hist_em(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
+
symbol: str = "小金属",
|
|
170
|
+
start_date: str = "20211201",
|
|
171
|
+
end_date: str = "20220401",
|
|
172
|
+
period: str = "日k",
|
|
173
|
+
adjust: str = "",
|
|
169
174
|
) -> pd.DataFrame:
|
|
170
175
|
"""
|
|
171
176
|
东方财富网-沪深板块-行业板块-历史行情
|
|
@@ -184,14 +189,14 @@ def stock_board_industry_hist_em(
|
|
|
184
189
|
:rtype: pandas.DataFrame
|
|
185
190
|
"""
|
|
186
191
|
period_map = {
|
|
187
|
-
"日k":
|
|
188
|
-
"周k":
|
|
189
|
-
"月k":
|
|
192
|
+
"日k": "101",
|
|
193
|
+
"周k": "102",
|
|
194
|
+
"月k": "103",
|
|
190
195
|
}
|
|
191
196
|
stock_board_concept_em_map = stock_board_industry_name_em()
|
|
192
197
|
stock_board_code = stock_board_concept_em_map[
|
|
193
198
|
stock_board_concept_em_map["板块名称"] == symbol
|
|
194
|
-
|
|
199
|
+
]["板块代码"].values[0]
|
|
195
200
|
adjust_map = {"": "0", "qfq": "1", "hfq": "2"}
|
|
196
201
|
url = "http://7.push2his.eastmoney.com/api/qt/stock/kline/get"
|
|
197
202
|
params = {
|
|
@@ -209,9 +214,7 @@ def stock_board_industry_hist_em(
|
|
|
209
214
|
}
|
|
210
215
|
r = requests.get(url, params=params)
|
|
211
216
|
data_json = r.json()
|
|
212
|
-
temp_df = pd.DataFrame(
|
|
213
|
-
[item.split(",") for item in data_json["data"]["klines"]]
|
|
214
|
-
)
|
|
217
|
+
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]["klines"]])
|
|
215
218
|
temp_df.columns = [
|
|
216
219
|
"日期",
|
|
217
220
|
"开盘",
|
|
@@ -254,7 +257,7 @@ def stock_board_industry_hist_em(
|
|
|
254
257
|
|
|
255
258
|
|
|
256
259
|
def stock_board_industry_hist_min_em(
|
|
257
|
-
|
|
260
|
+
symbol: str = "小金属", period: str = "5"
|
|
258
261
|
) -> pd.DataFrame:
|
|
259
262
|
"""
|
|
260
263
|
东方财富网-沪深板块-行业板块-分时历史行情
|
|
@@ -269,15 +272,15 @@ def stock_board_industry_hist_min_em(
|
|
|
269
272
|
stock_board_concept_em_map = stock_board_industry_name_em()
|
|
270
273
|
stock_board_code = stock_board_concept_em_map[
|
|
271
274
|
stock_board_concept_em_map["板块名称"] == symbol
|
|
272
|
-
|
|
275
|
+
]["板块代码"].values[0]
|
|
273
276
|
if period == "1":
|
|
274
277
|
url = "https://push2his.eastmoney.com/api/qt/stock/trends2/get"
|
|
275
278
|
params = {
|
|
276
279
|
"fields1": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",
|
|
277
280
|
"fields2": "f51,f52,f53,f54,f55,f56,f57,f58",
|
|
278
|
-
"ut":
|
|
279
|
-
"iscr":
|
|
280
|
-
"ndays":
|
|
281
|
+
"ut": "fa5fd1943c7b386f172d6893dbfba10b",
|
|
282
|
+
"iscr": "0",
|
|
283
|
+
"ndays": "1",
|
|
281
284
|
"secid": f"90.{stock_board_code}",
|
|
282
285
|
"_": "1687852931312",
|
|
283
286
|
}
|
|
@@ -378,7 +381,7 @@ def stock_board_industry_cons_em(symbol: str = "小金属") -> pd.DataFrame:
|
|
|
378
381
|
stock_board_concept_em_map = stock_board_industry_name_em()
|
|
379
382
|
stock_board_code = stock_board_concept_em_map[
|
|
380
383
|
stock_board_concept_em_map["板块名称"] == symbol
|
|
381
|
-
|
|
384
|
+
]["板块代码"].values[0]
|
|
382
385
|
url = "http://29.push2.eastmoney.com/api/qt/clist/get"
|
|
383
386
|
params = {
|
|
384
387
|
"pn": "1",
|
|
@@ -390,7 +393,8 @@ def stock_board_industry_cons_em(symbol: str = "小金属") -> pd.DataFrame:
|
|
|
390
393
|
"invt": "2",
|
|
391
394
|
"fid": "f3",
|
|
392
395
|
"fs": f"b:{stock_board_code} f:!50",
|
|
393
|
-
"fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,
|
|
396
|
+
"fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,"
|
|
397
|
+
"f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",
|
|
394
398
|
"_": "1626081702127",
|
|
395
399
|
}
|
|
396
400
|
r = requests.get(url, params=params)
|
|
@@ -477,7 +481,11 @@ if __name__ == "__main__":
|
|
|
477
481
|
print(stock_board_industry_spot_em_df)
|
|
478
482
|
|
|
479
483
|
stock_board_industry_hist_em_df = stock_board_industry_hist_em(
|
|
480
|
-
symbol="小金属",
|
|
484
|
+
symbol="小金属",
|
|
485
|
+
start_date="20211201",
|
|
486
|
+
end_date="20240222",
|
|
487
|
+
period="日k",
|
|
488
|
+
adjust="",
|
|
481
489
|
)
|
|
482
490
|
print(stock_board_industry_hist_em_df)
|
|
483
491
|
|
|
@@ -486,7 +494,5 @@ if __name__ == "__main__":
|
|
|
486
494
|
)
|
|
487
495
|
print(stock_board_industry_hist_min_em_df)
|
|
488
496
|
|
|
489
|
-
stock_board_industry_cons_em_df = stock_board_industry_cons_em(
|
|
490
|
-
symbol="小金属"
|
|
491
|
-
)
|
|
497
|
+
stock_board_industry_cons_em_df = stock_board_industry_cons_em(symbol="小金属")
|
|
492
498
|
print(stock_board_industry_cons_em_df)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
akshare/__init__.py,sha256=
|
|
1
|
+
akshare/__init__.py,sha256=zXYZnokPlRdH1ld70wQoCc3o6BGNDeMl4xYNDxEc66c,181054
|
|
2
2
|
akshare/datasets.py,sha256=oIu1zC7o_LMHY22lQmdM7vCnryHibKrJLBqJwQiitlI,1167
|
|
3
3
|
akshare/air/__init__.py,sha256=RMTf1bT5EOE3ttWpn3hGu1LtUmsVxDoa0W7W0gXHOy8,81
|
|
4
4
|
akshare/air/air_hebei.py,sha256=xIXNGLK7IGYqrkteM9fxnHAwWqk6PCQs6D9-ggZ7byY,4442
|
|
@@ -101,7 +101,7 @@ akshare/fund/fund_scale_sina.py,sha256=cQ39Pt6ia3GrVCFWv0GhLMqxyedX3qRrvkDLee7N9
|
|
|
101
101
|
akshare/fund/fund_xq.py,sha256=qGMKYC0Vi2AXfnjsS0P9B2ITfpkQ85i4ayXA6kJ6a7o,11295
|
|
102
102
|
akshare/futures/__init__.py,sha256=RMTf1bT5EOE3ttWpn3hGu1LtUmsVxDoa0W7W0gXHOy8,81
|
|
103
103
|
akshare/futures/cons.py,sha256=sc0LW_k_Poc3V3r_Mz8DiKfLy7aisda28pK0u8ffMus,16193
|
|
104
|
-
akshare/futures/cot.py,sha256=
|
|
104
|
+
akshare/futures/cot.py,sha256=Kkza2slS7JQpXndKrQEEykzIjZIT3vhvtZHVJ7P1yac,58573
|
|
105
105
|
akshare/futures/futures_basis.py,sha256=ixaucu9loaPUwa2BOhRek0bI6VhdXY_ScyQ2EOZEPBA,13884
|
|
106
106
|
akshare/futures/futures_comex_em.py,sha256=V-mkKQkH5N8PyaZWKdyggb2lTnY8DDDxiUPt-1leQu0,3171
|
|
107
107
|
akshare/futures/futures_comm_ctp.py,sha256=V8TEKO0R0i6LfE8DDFqrMA3JGwNlpmaQCvvMugKZ1I8,1004
|
|
@@ -110,7 +110,7 @@ akshare/futures/futures_contract_detail.py,sha256=auwzNdaoFi5hoJY6rNkO54v5FD2gmE
|
|
|
110
110
|
akshare/futures/futures_daily_bar.py,sha256=Zmabe58qHxF0gJ8CKAw9uuuUtxfYMhLNWSJioMGYK04,25363
|
|
111
111
|
akshare/futures/futures_foreign.py,sha256=oSIoAg5oy-CIlPWHkQffcvZGu02Y2GWOrt-6aPA53Xg,2059
|
|
112
112
|
akshare/futures/futures_hf_em.py,sha256=OEUltaq1LKabl9eTQoNxswnl1BLKpB27eiIHwbu_Rh4,3178
|
|
113
|
-
akshare/futures/futures_hq_sina.py,sha256=
|
|
113
|
+
akshare/futures/futures_hq_sina.py,sha256=4qDv8U99Ic82QbFNvwsuaHZX2VPl8Ei-yNsEnRpaPZA,9582
|
|
114
114
|
akshare/futures/futures_index_ccidx.py,sha256=9Rhk3ps-H69tU-NIV0W2NdLFUDTSUx0bwtePA6gLMZA,4566
|
|
115
115
|
akshare/futures/futures_international.py,sha256=EE_JTjQKekx8_FU8M12wHSd1DSlfMXYFiBJ6_wmThfc,6946
|
|
116
116
|
akshare/futures/futures_inventory_99.py,sha256=Nvw39obGGhgOkk_C4jOrV4gdq78dtHPOnits_B0Ljxk,8450
|
|
@@ -143,7 +143,7 @@ akshare/futures_derivative/futures_index_price_nh.py,sha256=TzrGGHvyz93UPdPGMokQ
|
|
|
143
143
|
akshare/futures_derivative/futures_index_return_nh.py,sha256=56V3Mic8a-bKlkv4bUm_vTUC1u5qdDzrlZwsbUTCTPM,1734
|
|
144
144
|
akshare/futures_derivative/futures_index_sina.py,sha256=G1dPeQcsHwMG81J4MqVjkHqFBM363ktzJmNI-EBsi3A,5902
|
|
145
145
|
akshare/futures_derivative/futures_index_volatility_nh.py,sha256=IInn3yf2RqBStFcS8dHtqr3YW8myBD71v_04KA5JAy0,1824
|
|
146
|
-
akshare/futures_derivative/futures_other_index_nh.py,sha256=
|
|
146
|
+
akshare/futures_derivative/futures_other_index_nh.py,sha256=b2oUWSuUIEL-lr2tUK6bIVxIhFNXbp7y2IaVXWqkcz0,4414
|
|
147
147
|
akshare/futures_derivative/futures_spot_sys.py,sha256=Ufqh7S7UAeW_zkASap_DZGqwyW_Vgrf2UOhedYhe-BU,3351
|
|
148
148
|
akshare/fx/__init__.py,sha256=fvH_pVxTFPnzXvnPvJZDD_vv0IBJusHkJxZ3dJ8ogl8,82
|
|
149
149
|
akshare/fx/cons.py,sha256=6xxySOGmJ-sd4mygg0dT48oz-vcyOQcqWY4T2h3wjQQ,585
|
|
@@ -228,13 +228,13 @@ akshare/sport/sport_olympic.py,sha256=CB1cvLpz2BWuadfonhHuQ17Qxt9X_3ks0Zc5Bff2w9
|
|
|
228
228
|
akshare/spot/__init__.py,sha256=VGuha94pXYoezmMs3F3Q_ofaN8RZIrkJ2NtVv8hWCjY,83
|
|
229
229
|
akshare/spot/spot_hog_soozhu.py,sha256=IEt7zrDs0ptAKgMA7QRIk45jcMLcA_LGq6Y3lKLFTi0,9397
|
|
230
230
|
akshare/spot/spot_price_qh.py,sha256=rRv09vR8K0U_x6x8AiLgGluxytIXkLatFNVkFbIh8eQ,3756
|
|
231
|
-
akshare/spot/spot_sge.py,sha256=
|
|
231
|
+
akshare/spot/spot_sge.py,sha256=sXaUGPm8yEXogssNFyFgTlnpf363g7s3U6xO4Zyvk9g,8213
|
|
232
232
|
akshare/stock/__init__.py,sha256=jSa9260d6aNZajaW68chI2mpPkDSXLOgi3eXrqo4MQ8,82
|
|
233
233
|
akshare/stock/cons.py,sha256=0oyUW5Pu-iQ3qgh-TFemM_O5f1fAwVe-PsI4Qa8EYpQ,42956
|
|
234
234
|
akshare/stock/stock_allotment_cninfo.py,sha256=qk--nWhskZWnUUOwBvfgiFJEOd1GqmQijzzVlORCG2I,6059
|
|
235
235
|
akshare/stock/stock_ask_bid_em.py,sha256=ioVkmRMVs7A7Lj_PboxwIoZINNk73nAko80wIJX4RKU,5510
|
|
236
236
|
akshare/stock/stock_board_concept_em.py,sha256=iajw06K04I-F9VGXbuJf5Vz_digDCgMi4J1vgzkmbFA,14039
|
|
237
|
-
akshare/stock/stock_board_industry_em.py,sha256=
|
|
237
|
+
akshare/stock/stock_board_industry_em.py,sha256=AfRVUVZrgSJXaoKAK81Ga-_m3hfv8YZzczBnnBdFq-I,16195
|
|
238
238
|
akshare/stock/stock_cg_equity_mortgage.py,sha256=Pui5aWKKPwGuKjF_GNpejDzsMGNPrxiaJviLz3x2e9I,3426
|
|
239
239
|
akshare/stock/stock_cg_guarantee.py,sha256=ts7qcQhhyN1PHB7Q4XlMn38HhfVvubOvky9RZfmUP94,3844
|
|
240
240
|
akshare/stock/stock_cg_lawsuit.py,sha256=6Y92pPw0JgyrInteqHuU07G1jwmdX2wjaDtrJN8y6Hg,4129
|
|
@@ -380,8 +380,8 @@ akshare/utils/token_process.py,sha256=K4rGXjh_tgugbRcyOK2h2x0jP3PT65IIK7nxhUKhOe
|
|
|
380
380
|
akshare/utils/tqdm.py,sha256=MuPNwcswkOGjwWQOMWXi9ZvQ_RmW4obCWRj2i7HM7FE,847
|
|
381
381
|
tests/__init__.py,sha256=gNzhlO0UPjFq6Ieb38kaVIODXv4cTDByrdohAZnDYt4,82
|
|
382
382
|
tests/test_func.py,sha256=tfvy_YnYmDra2dkKZ5JvprU1gNW5X9T634PszdSdH1A,944
|
|
383
|
-
akshare-1.14.
|
|
384
|
-
akshare-1.14.
|
|
385
|
-
akshare-1.14.
|
|
386
|
-
akshare-1.14.
|
|
387
|
-
akshare-1.14.
|
|
383
|
+
akshare-1.14.64.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
|
|
384
|
+
akshare-1.14.64.dist-info/METADATA,sha256=iIkiuYRQOUYJ_lxPDy1DMlpZ58i1nvkDoNUP--pLw-U,13961
|
|
385
|
+
akshare-1.14.64.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
|
|
386
|
+
akshare-1.14.64.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
|
|
387
|
+
akshare-1.14.64.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|