akshare 1.15.33__py3-none-any.whl → 1.15.35__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 +3 -9
- akshare/fund/fund_rank_em.py +1 -1
- akshare/futures/futures_basis.py +25 -8
- akshare/futures/futures_hf_em.py +65 -60
- akshare/futures/symbol_var.py +18 -13
- {akshare-1.15.33.dist-info → akshare-1.15.35.dist-info}/METADATA +1 -1
- {akshare-1.15.33.dist-info → akshare-1.15.35.dist-info}/RECORD +10 -11
- akshare/crypto/crypto_hist_investing.py +0 -249
- {akshare-1.15.33.dist-info → akshare-1.15.35.dist-info}/LICENSE +0 -0
- {akshare-1.15.33.dist-info → akshare-1.15.35.dist-info}/WHEEL +0 -0
- {akshare-1.15.33.dist-info → akshare-1.15.35.dist-info}/top_level.txt +0 -0
akshare/__init__.py
CHANGED
|
@@ -2943,9 +2943,11 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
|
|
|
2943
2943
|
1.15.31 fix: fix stock_zt_pool_strong_em interface
|
|
2944
2944
|
1.15.32 fix: fix stock_info_global_cls interface
|
|
2945
2945
|
1.15.33 add: add stock_value_em interface
|
|
2946
|
+
1.15.34 fix: fix fund_open_fund_rank_em interface
|
|
2947
|
+
1.15.35 fix: fix futures_spot_price_daily interface
|
|
2946
2948
|
"""
|
|
2947
2949
|
|
|
2948
|
-
__version__ = "1.15.
|
|
2950
|
+
__version__ = "1.15.35"
|
|
2949
2951
|
__author__ = "AKFamily"
|
|
2950
2952
|
|
|
2951
2953
|
import sys
|
|
@@ -4345,14 +4347,6 @@ from akshare.fund.fund_rank_em import (
|
|
|
4345
4347
|
fund_lcx_rank_em,
|
|
4346
4348
|
)
|
|
4347
4349
|
|
|
4348
|
-
"""
|
|
4349
|
-
英为财情-加密货币
|
|
4350
|
-
"""
|
|
4351
|
-
from akshare.crypto.crypto_hist_investing import (
|
|
4352
|
-
crypto_hist,
|
|
4353
|
-
crypto_name_url_table,
|
|
4354
|
-
)
|
|
4355
|
-
|
|
4356
4350
|
"""
|
|
4357
4351
|
电影票房
|
|
4358
4352
|
"""
|
akshare/fund/fund_rank_em.py
CHANGED
akshare/futures/futures_basis.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/
|
|
4
|
+
Date: 2024/11/28 22:00
|
|
5
5
|
Desc: 生意社网站采集大宗商品现货价格及相应基差数据, 数据时间段从 20110104-至今
|
|
6
6
|
备注:现期差 = 现货价格 - 期货价格(这里的期货价格为结算价)
|
|
7
7
|
黄金为 元/克, 白银为 元/千克, 玻璃现货为 元/平方米, 鸡蛋现货为 元/公斤, 鸡蛋期货为 元/500千克, 其余为 元/吨.
|
|
@@ -169,10 +169,17 @@ def _check_information(df_data, date):
|
|
|
169
169
|
]
|
|
170
170
|
records = pd.DataFrame()
|
|
171
171
|
for string in df_data["symbol"].tolist():
|
|
172
|
+
news = "".join(re.findall(r"[\u4e00-\u9fa5]", string))
|
|
173
|
+
if news == "":
|
|
174
|
+
news = string.strip()
|
|
175
|
+
|
|
176
|
+
"""
|
|
172
177
|
if string == "PTA":
|
|
173
178
|
news = "PTA"
|
|
174
179
|
else:
|
|
175
180
|
news = "".join(re.findall(r"[\u4e00-\u9fa5]", string))
|
|
181
|
+
"""
|
|
182
|
+
|
|
176
183
|
if news != "" and news not in [
|
|
177
184
|
"商品",
|
|
178
185
|
"价格",
|
|
@@ -193,6 +200,10 @@ def _check_information(df_data, date):
|
|
|
193
200
|
symbol == "FG"
|
|
194
201
|
): # 上表中现货单位为元/平方米, 期货单位为元/吨. 换算公式:元/平方米*80=元/吨(http://www.100ppi.com/sf/959.html)
|
|
195
202
|
record.loc[:, "spot_price"] = float(record["spot_price"].iloc[0]) * 80
|
|
203
|
+
elif (
|
|
204
|
+
symbol == "LH"
|
|
205
|
+
): # 上表中现货单位为元/公斤, 期货单位为元/吨. 换算公式:元/公斤*1000=元/吨(http://www.100ppi.com/sf/959.html)
|
|
206
|
+
record.loc[:, "spot_price"] = float(record["spot_price"].iloc[0]) * 1000
|
|
196
207
|
records = pd.concat([records, record])
|
|
197
208
|
|
|
198
209
|
records.loc[:, ["near_contract_price", "dominant_contract_price", "spot_price"]] = (
|
|
@@ -208,9 +219,11 @@ def _check_information(df_data, date):
|
|
|
208
219
|
r"[^0-9]*(\d*)$", r"\g<1>", regex=True
|
|
209
220
|
)
|
|
210
221
|
|
|
222
|
+
records.loc[:, "near_month"] = records.loc[:, "near_contract"]
|
|
211
223
|
records.loc[:, "near_contract"] = records["symbol"] + records.loc[
|
|
212
224
|
:, "near_contract"
|
|
213
225
|
].astype("int").astype("str")
|
|
226
|
+
records.loc[:, "dominant_month"] = records.loc[:, "dominant_contract"]
|
|
214
227
|
records.loc[:, "dominant_contract"] = records["symbol"] + records.loc[
|
|
215
228
|
:, "dominant_contract"
|
|
216
229
|
].astype("int").astype("str")
|
|
@@ -246,7 +259,7 @@ def _check_information(df_data, date):
|
|
|
246
259
|
records["dom_basis_rate"] = (
|
|
247
260
|
records["dominant_contract_price"] / records["spot_price"] - 1
|
|
248
261
|
)
|
|
249
|
-
records.
|
|
262
|
+
records.insert(0, "date", date.strftime("%Y%m%d"))
|
|
250
263
|
return records
|
|
251
264
|
|
|
252
265
|
|
|
@@ -289,20 +302,24 @@ def futures_spot_price_previous(date: str = "20240430") -> pd.DataFrame:
|
|
|
289
302
|
# Basis
|
|
290
303
|
basis = pd.concat(content[2:-1])
|
|
291
304
|
basis.columns = ["主力合约基差", "主力合约基差(%)"]
|
|
292
|
-
basis
|
|
305
|
+
basis.index = values.index
|
|
293
306
|
basis = pd.merge(
|
|
294
|
-
values[["商品", "现货价格", "主力合约代码", "主力合约价格"]],
|
|
307
|
+
values[["商品", "现货价格", "主力合约代码", "主力合约价格"]],
|
|
308
|
+
basis,
|
|
309
|
+
left_index=True,
|
|
310
|
+
right_index=True,
|
|
295
311
|
)
|
|
296
312
|
basis = pd.merge(
|
|
297
313
|
basis,
|
|
298
314
|
values[
|
|
299
315
|
[
|
|
300
|
-
"商品",
|
|
301
316
|
"180日内主力基差最高",
|
|
302
317
|
"180日内主力基差最低",
|
|
303
318
|
"180日内主力基差平均",
|
|
304
319
|
]
|
|
305
320
|
],
|
|
321
|
+
left_index=True,
|
|
322
|
+
right_index=True,
|
|
306
323
|
)
|
|
307
324
|
basis.columns = [
|
|
308
325
|
"商品",
|
|
@@ -321,12 +338,12 @@ def futures_spot_price_previous(date: str = "20240430") -> pd.DataFrame:
|
|
|
321
338
|
|
|
322
339
|
if __name__ == "__main__":
|
|
323
340
|
futures_spot_price_daily_df = futures_spot_price_daily(
|
|
324
|
-
start_day="
|
|
341
|
+
start_day="20241028", end_day="20241128", vars_list=["CU", "RB"]
|
|
325
342
|
)
|
|
326
343
|
print(futures_spot_price_daily_df)
|
|
327
344
|
|
|
328
|
-
futures_spot_price_df = futures_spot_price(date="
|
|
345
|
+
futures_spot_price_df = futures_spot_price(date="20241128")
|
|
329
346
|
print(futures_spot_price_df)
|
|
330
347
|
|
|
331
|
-
futures_spot_price_previous_df = futures_spot_price_previous(date="
|
|
348
|
+
futures_spot_price_previous_df = futures_spot_price_previous(date="20241128")
|
|
332
349
|
print(futures_spot_price_previous_df)
|
akshare/futures/futures_hf_em.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/
|
|
4
|
+
Date: 2024/11/28 22:00
|
|
5
5
|
Desc: 东方财富网-行情中心-期货市场-国际期货
|
|
6
6
|
https://quote.eastmoney.com/center/gridlist.html#futures_global
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import math
|
|
9
10
|
|
|
10
11
|
import pandas as pd
|
|
@@ -22,77 +23,81 @@ def futures_global_em():
|
|
|
22
23
|
"""
|
|
23
24
|
url = "https://futsseapi.eastmoney.com/list/COMEX,NYMEX,COBOT,SGX,NYBOT,LME,MDEX,TOCOM,IPE"
|
|
24
25
|
params = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
'_': '1705570814466'
|
|
26
|
+
"orderBy": "zdf",
|
|
27
|
+
"sort": "desc",
|
|
28
|
+
"pageSize": "20",
|
|
29
|
+
"pageIndex": "0",
|
|
30
|
+
"token": "58b2fa8f54638b60b87d69b31969089c",
|
|
31
|
+
"field": "dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl",
|
|
32
|
+
"blockName": "callback",
|
|
33
33
|
}
|
|
34
34
|
r = requests.get(url, params=params)
|
|
35
35
|
data_json = r.json()
|
|
36
|
-
total_num = data_json[
|
|
36
|
+
total_num = data_json["total"]
|
|
37
37
|
total_page = math.ceil(total_num / 20) - 1
|
|
38
38
|
tqdm = get_tqdm()
|
|
39
39
|
big_df = pd.DataFrame()
|
|
40
40
|
for page in tqdm(range(total_page), leave=False):
|
|
41
|
-
params.update({
|
|
41
|
+
params.update({"pageIndex": page})
|
|
42
42
|
r = requests.get(url, params=params)
|
|
43
43
|
data_json = r.json()
|
|
44
|
-
temp_df = pd.DataFrame(data_json[
|
|
45
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
44
|
+
temp_df = pd.DataFrame(data_json["list"])
|
|
45
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
46
46
|
big_df.reset_index(inplace=True)
|
|
47
|
-
big_df[
|
|
48
|
-
big_df.rename(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
big_df[
|
|
88
|
-
big_df[
|
|
89
|
-
big_df[
|
|
90
|
-
big_df[
|
|
91
|
-
big_df[
|
|
92
|
-
big_df[
|
|
47
|
+
big_df["index"] = big_df["index"] + 1
|
|
48
|
+
big_df.rename(
|
|
49
|
+
columns={
|
|
50
|
+
"index": "序号",
|
|
51
|
+
"np": "卖盘",
|
|
52
|
+
"h": "最高",
|
|
53
|
+
"dm": "代码",
|
|
54
|
+
"zsjd": "-",
|
|
55
|
+
"l": "最低",
|
|
56
|
+
"ccl": "持仓量",
|
|
57
|
+
"o": "今开",
|
|
58
|
+
"p": "最新价",
|
|
59
|
+
"sc": "-",
|
|
60
|
+
"vol": "成交量",
|
|
61
|
+
"name": "名称",
|
|
62
|
+
"wp": "买盘",
|
|
63
|
+
"zde": "涨跌额",
|
|
64
|
+
"zdf": "涨跌幅",
|
|
65
|
+
"zjsj": "昨结",
|
|
66
|
+
},
|
|
67
|
+
inplace=True,
|
|
68
|
+
)
|
|
69
|
+
big_df = big_df[
|
|
70
|
+
[
|
|
71
|
+
"序号",
|
|
72
|
+
"代码",
|
|
73
|
+
"名称",
|
|
74
|
+
"最新价",
|
|
75
|
+
"涨跌额",
|
|
76
|
+
"涨跌幅",
|
|
77
|
+
"今开",
|
|
78
|
+
"最高",
|
|
79
|
+
"最低",
|
|
80
|
+
"昨结",
|
|
81
|
+
"成交量",
|
|
82
|
+
"买盘",
|
|
83
|
+
"卖盘",
|
|
84
|
+
"持仓量",
|
|
85
|
+
]
|
|
86
|
+
]
|
|
87
|
+
big_df["最新价"] = pd.to_numeric(big_df["最新价"], errors="coerce")
|
|
88
|
+
big_df["涨跌额"] = pd.to_numeric(big_df["涨跌额"], errors="coerce")
|
|
89
|
+
big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"], errors="coerce")
|
|
90
|
+
big_df["今开"] = pd.to_numeric(big_df["今开"], errors="coerce")
|
|
91
|
+
big_df["最高"] = pd.to_numeric(big_df["最高"], errors="coerce")
|
|
92
|
+
big_df["最低"] = pd.to_numeric(big_df["最低"], errors="coerce")
|
|
93
|
+
big_df["昨结"] = pd.to_numeric(big_df["昨结"], errors="coerce")
|
|
94
|
+
big_df["成交量"] = pd.to_numeric(big_df["成交量"], errors="coerce")
|
|
95
|
+
big_df["买盘"] = pd.to_numeric(big_df["买盘"], errors="coerce")
|
|
96
|
+
big_df["卖盘"] = pd.to_numeric(big_df["卖盘"], errors="coerce")
|
|
97
|
+
big_df["持仓量"] = pd.to_numeric(big_df["持仓量"], errors="coerce")
|
|
93
98
|
return big_df
|
|
94
99
|
|
|
95
100
|
|
|
96
|
-
if __name__ ==
|
|
101
|
+
if __name__ == "__main__":
|
|
97
102
|
futures_global_em_df = futures_global_em()
|
|
98
103
|
print(futures_global_em_df)
|
akshare/futures/symbol_var.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/11/28 22:00
|
|
5
5
|
Desc: 期货品种映射表
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
import re
|
|
8
9
|
|
|
9
10
|
from akshare.futures import cons
|
|
@@ -151,18 +152,20 @@ def chinese_to_english(chinese_var: str):
|
|
|
151
152
|
"低硫燃料油仓库",
|
|
152
153
|
"低硫燃料油厂库",
|
|
153
154
|
"短纤",
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
155
|
+
"涤纶短纤",
|
|
156
|
+
"生猪",
|
|
157
|
+
"花生",
|
|
158
|
+
"工业硅",
|
|
159
|
+
"氧化铝",
|
|
160
|
+
"丁二烯橡胶",
|
|
161
|
+
"碳酸锂",
|
|
162
|
+
"氧化铝仓库",
|
|
163
|
+
"氧化铝厂库",
|
|
164
|
+
"烧碱",
|
|
165
|
+
"丁二烯橡胶仓库",
|
|
166
|
+
"丁二烯橡胶厂库",
|
|
167
|
+
"PX",
|
|
168
|
+
"原木",
|
|
166
169
|
]
|
|
167
170
|
english_list = [
|
|
168
171
|
"RU",
|
|
@@ -277,6 +280,8 @@ def chinese_to_english(chinese_var: str):
|
|
|
277
280
|
"SH",
|
|
278
281
|
"BR",
|
|
279
282
|
"BR",
|
|
283
|
+
"PX",
|
|
284
|
+
"LG",
|
|
280
285
|
]
|
|
281
286
|
pos = chinese_list.index(chinese_var)
|
|
282
287
|
return english_list[pos]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
akshare/__init__.py,sha256=
|
|
1
|
+
akshare/__init__.py,sha256=KAJU1QodcRiZp5BPcGhgvS4y0MlYYGjgMzM9y7Yaur8,184448
|
|
2
2
|
akshare/datasets.py,sha256=-qdwaQjgBlftX84uM74KJqCYJYkQ50PV416_neA4uls,995
|
|
3
3
|
akshare/exceptions.py,sha256=WEJjIhSmJ_xXNW6grwV4nufE_cfmmyuhmueVGiN1VAg,878
|
|
4
4
|
akshare/request.py,sha256=HtFFf9MhfEibR-ETWe-1Tts6ELU4VKSqA-ghaXjegQM,4252
|
|
@@ -40,7 +40,6 @@ akshare/cost/__init__.py,sha256=x1R9hH6E0M7C86XhHFzbPiipUWz9IknuhVZrk4gZus4,82
|
|
|
40
40
|
akshare/cost/cost_living.py,sha256=_yoGEW4jBfpjhgMxCXvMtBbrCx2PEuOngV3laEoEOvk,2078
|
|
41
41
|
akshare/crypto/__init__.py,sha256=lbmNMPPLGkW9AgGL4ZnCwoQvPjOFPDNUz6P3arSkNI0,83
|
|
42
42
|
akshare/crypto/crypto_bitcoin_cme.py,sha256=IO4dxPj-kwtJXo9F_h5tH64__yeDQXs2cavCkgxxp1I,2436
|
|
43
|
-
akshare/crypto/crypto_hist_investing.py,sha256=tIeEkFur-u-E2_-R4I_Zy0s_VFnR03CCl4GpgJkLYJw,9748
|
|
44
43
|
akshare/crypto/crypto_hold.py,sha256=029V9l8FI4Ewyq2Zg9HTLYX33BdF9nz4EUxtltKtKV8,2405
|
|
45
44
|
akshare/currency/__init__.py,sha256=d8yOOiPqY7_A0AuIpCI71-qxxwyUyCaax5jhE54CeMo,80
|
|
46
45
|
akshare/currency/currency.py,sha256=NwtfLAWVRoMb8BQ-E92XobydGTOcV_D5zKAZmf3rT6Q,6397
|
|
@@ -97,7 +96,7 @@ akshare/fund/fund_lof_em.py,sha256=eWpIlHzUYbscyxvz8awiDERxd7gTucHcGcrBPTCCFno,1
|
|
|
97
96
|
akshare/fund/fund_manager.py,sha256=yhpXp_WKradzSc0dMfGKJibNCksts2L2Bg_gvUU4_VQ,2801
|
|
98
97
|
akshare/fund/fund_portfolio_em.py,sha256=8kk7a8hA22ANfnlnK1j4f5qXepfkgJOiEMpuazP2Xlk,10785
|
|
99
98
|
akshare/fund/fund_position_lg.py,sha256=dxwGvfc8SXlRziWBWHIcaqOOltsKlxHgHL0Cxr7cCeM,3857
|
|
100
|
-
akshare/fund/fund_rank_em.py,sha256=
|
|
99
|
+
akshare/fund/fund_rank_em.py,sha256=e39e11YoctRRYX46mzoOCZQGSA6ZtImoEsuY3ElNjG4,17874
|
|
101
100
|
akshare/fund/fund_rating.py,sha256=oBZTOBaiC9RMfTK2XGKIMY58sPxc7M6GlMJ3_M3i0lQ,11680
|
|
102
101
|
akshare/fund/fund_report_cninfo.py,sha256=rhztaa3J48VdnCEXFAl8wMg-P7MI2iQa0HculkvL8CI,8785
|
|
103
102
|
akshare/fund/fund_scale_em.py,sha256=8XLZpz9DzsAnJCo1moBmzf3u7mfZNZHsb3cPKJ-gCJM,4237
|
|
@@ -106,14 +105,14 @@ akshare/fund/fund_xq.py,sha256=AxMZB-940bNY7-BatVLZiseHNxiWA17hQzTfuxGibPU,11306
|
|
|
106
105
|
akshare/futures/__init__.py,sha256=RMTf1bT5EOE3ttWpn3hGu1LtUmsVxDoa0W7W0gXHOy8,81
|
|
107
106
|
akshare/futures/cons.py,sha256=zD2uRQK3v-mywcDZfL28sDdRl6WIeWthHTfu8nrcQAo,16252
|
|
108
107
|
akshare/futures/cot.py,sha256=Kkza2slS7JQpXndKrQEEykzIjZIT3vhvtZHVJ7P1yac,58573
|
|
109
|
-
akshare/futures/futures_basis.py,sha256=
|
|
108
|
+
akshare/futures/futures_basis.py,sha256=I5PSlZRq1zE9lPDvunQ0bLutX8FjfYSadXWCVX9lIZ0,14539
|
|
110
109
|
akshare/futures/futures_comex_em.py,sha256=V-mkKQkH5N8PyaZWKdyggb2lTnY8DDDxiUPt-1leQu0,3171
|
|
111
110
|
akshare/futures/futures_comm_ctp.py,sha256=V8TEKO0R0i6LfE8DDFqrMA3JGwNlpmaQCvvMugKZ1I8,1004
|
|
112
111
|
akshare/futures/futures_comm_qihuo.py,sha256=uQfabZ63qME8sTaxUbIUVQBVi8yTaPPDhD7voR9PEx0,10504
|
|
113
112
|
akshare/futures/futures_contract_detail.py,sha256=auwzNdaoFi5hoJY6rNkO54v5FD2gmEkQu7B90yEDtkc,1175
|
|
114
113
|
akshare/futures/futures_daily_bar.py,sha256=E1zx4VswHra2Gh30wKgWuHRO36tsTvKYfjC0dOMTBPY,25281
|
|
115
114
|
akshare/futures/futures_foreign.py,sha256=oSIoAg5oy-CIlPWHkQffcvZGu02Y2GWOrt-6aPA53Xg,2059
|
|
116
|
-
akshare/futures/futures_hf_em.py,sha256=
|
|
115
|
+
akshare/futures/futures_hf_em.py,sha256=FVD7UTAXD2O_0DA0WlMdGrDqQOYIpOX_BGakKeDibmM,3322
|
|
117
116
|
akshare/futures/futures_hq_sina.py,sha256=eK1gEan4DPvpYmln8-tNnzh_J_733s95DBr--NqNYVA,9576
|
|
118
117
|
akshare/futures/futures_index_ccidx.py,sha256=9Rhk3ps-H69tU-NIV0W2NdLFUDTSUx0bwtePA6gLMZA,4566
|
|
119
118
|
akshare/futures/futures_international.py,sha256=EE_JTjQKekx8_FU8M12wHSd1DSlfMXYFiBJ6_wmThfc,6946
|
|
@@ -132,7 +131,7 @@ akshare/futures/futures_zh_sina.py,sha256=NMzqFbLkrUaeO1AouZUFqgekYBAm7j5ew2LTlr
|
|
|
132
131
|
akshare/futures/inventory_data.py,sha256=m1DCzClDudj4qQLjgl5i6Lbazu0wIm9R3RerHCPcp38,4097
|
|
133
132
|
akshare/futures/receipt.py,sha256=CGk0HKSJLeWSahkXmep8LVceAbN3wooTjMqGlQkegAY,22054
|
|
134
133
|
akshare/futures/requests_fun.py,sha256=s31tnP2qUwEux43RX_t3K1uToJiSQ7xHYYQ_0bp16O0,2832
|
|
135
|
-
akshare/futures/symbol_var.py,sha256=
|
|
134
|
+
akshare/futures/symbol_var.py,sha256=HnKKQ8waVW6sjlqh4F9vsloKY1NVs2s_-M4DB5hb7cA,5589
|
|
136
135
|
akshare/futures_derivative/__init__.py,sha256=COFyP01gIUhWs4EBr6hwL73B7IWePIzg7vP7oEY3G3I,82
|
|
137
136
|
akshare/futures_derivative/cons.py,sha256=Zdrfsln3ie3FXxu2YfMF1AxHSB0wAhQS5bM-nygJ_aM,5927
|
|
138
137
|
akshare/futures_derivative/futures_contract_info_cffex.py,sha256=f1n8_2G67sscHUatDP1ZqxwrKXiqPwSFMCa4pk8Colo,3248
|
|
@@ -384,8 +383,8 @@ akshare/utils/token_process.py,sha256=K4rGXjh_tgugbRcyOK2h2x0jP3PT65IIK7nxhUKhOe
|
|
|
384
383
|
akshare/utils/tqdm.py,sha256=MuPNwcswkOGjwWQOMWXi9ZvQ_RmW4obCWRj2i7HM7FE,847
|
|
385
384
|
tests/__init__.py,sha256=gNzhlO0UPjFq6Ieb38kaVIODXv4cTDByrdohAZnDYt4,82
|
|
386
385
|
tests/test_func.py,sha256=j1MGYbZI2if2j_LY1S4FLsf4qfq4NwVqD5wmRlv5Log,832
|
|
387
|
-
akshare-1.15.
|
|
388
|
-
akshare-1.15.
|
|
389
|
-
akshare-1.15.
|
|
390
|
-
akshare-1.15.
|
|
391
|
-
akshare-1.15.
|
|
386
|
+
akshare-1.15.35.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
|
|
387
|
+
akshare-1.15.35.dist-info/METADATA,sha256=RZFcqQxvr6By5y6FRGSPFaTyZWoqtLvuclOXseUld14,13423
|
|
388
|
+
akshare-1.15.35.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
389
|
+
akshare-1.15.35.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
|
|
390
|
+
akshare-1.15.35.dist-info/RECORD,,
|
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# -*- coding:utf-8 -*-
|
|
3
|
-
"""
|
|
4
|
-
Date: 2022/5/11 17:52
|
|
5
|
-
Desc: 加密货币
|
|
6
|
-
https://cn.investing.com/crypto/currencies
|
|
7
|
-
高频数据
|
|
8
|
-
https://bitcoincharts.com/about/markets-api/
|
|
9
|
-
"""
|
|
10
|
-
import math
|
|
11
|
-
|
|
12
|
-
import pandas as pd
|
|
13
|
-
import requests
|
|
14
|
-
from tqdm import tqdm
|
|
15
|
-
|
|
16
|
-
from akshare.datasets import get_crypto_info_csv
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def crypto_name_url_table(symbol: str = "web") -> pd.DataFrame:
|
|
20
|
-
"""
|
|
21
|
-
加密货币名称、代码和 ID,每次更新较慢
|
|
22
|
-
https://cn.investing.com/crypto/ethereum/historical-data
|
|
23
|
-
:param symbol: choice of {"web", "local"}; web 表示从网页获取最新,local 表示利用本地本文件
|
|
24
|
-
:type symbol: str
|
|
25
|
-
:return: 加密货币名称、代码和 ID
|
|
26
|
-
:rtype: pandas.DataFrame
|
|
27
|
-
"""
|
|
28
|
-
if symbol == "web":
|
|
29
|
-
headers = {
|
|
30
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
|
|
31
|
-
"X-Requested-With": "XMLHttpRequest",
|
|
32
|
-
}
|
|
33
|
-
url = "https://cn.investing.com/crypto/Service/LoadCryptoCurrencies"
|
|
34
|
-
payload = {
|
|
35
|
-
'draw': '14',
|
|
36
|
-
'columns[0][data]': 'currencies_order',
|
|
37
|
-
'columns[0][name]': 'currencies_order',
|
|
38
|
-
'columns[0][searchable]': 'true',
|
|
39
|
-
'columns[0][orderable]': 'true',
|
|
40
|
-
'columns[0][search][value]': '',
|
|
41
|
-
'columns[0][search][regex]': 'false',
|
|
42
|
-
'columns[1][data]': 'function',
|
|
43
|
-
'columns[1][name]': 'crypto_id',
|
|
44
|
-
'columns[1][searchable]': 'true',
|
|
45
|
-
'columns[1][orderable]': 'false',
|
|
46
|
-
'columns[1][search][value]': '',
|
|
47
|
-
'columns[1][search][regex]': 'false',
|
|
48
|
-
'columns[2][data]': 'function',
|
|
49
|
-
'columns[2][name]': 'name',
|
|
50
|
-
'columns[2][searchable]': 'true',
|
|
51
|
-
'columns[2][orderable]': 'true',
|
|
52
|
-
'columns[2][search][value]': '',
|
|
53
|
-
'columns[2][search][regex]': 'false',
|
|
54
|
-
'columns[3][data]': 'symbol',
|
|
55
|
-
'columns[3][name]': 'symbol',
|
|
56
|
-
'columns[3][searchable]': 'true',
|
|
57
|
-
'columns[3][orderable]': 'true',
|
|
58
|
-
'columns[3][search][value]': '',
|
|
59
|
-
'columns[3][search][regex]': 'false',
|
|
60
|
-
'columns[4][data]': 'function',
|
|
61
|
-
'columns[4][name]': 'price_usd',
|
|
62
|
-
'columns[4][searchable]': 'true',
|
|
63
|
-
'columns[4][orderable]': 'true',
|
|
64
|
-
'columns[4][search][value]': '',
|
|
65
|
-
'columns[4][search][regex]': 'false',
|
|
66
|
-
'columns[5][data]': 'market_cap_formatted',
|
|
67
|
-
'columns[5][name]': 'market_cap_usd',
|
|
68
|
-
'columns[5][searchable]': 'true',
|
|
69
|
-
'columns[5][orderable]': 'true',
|
|
70
|
-
'columns[5][search][value]': '',
|
|
71
|
-
'columns[5][search][regex]': 'false',
|
|
72
|
-
'columns[6][data]': '24h_volume_formatted',
|
|
73
|
-
'columns[6][name]': '24h_volume_usd',
|
|
74
|
-
'columns[6][searchable]': 'true',
|
|
75
|
-
'columns[6][orderable]': 'true',
|
|
76
|
-
'columns[6][search][value]': '',
|
|
77
|
-
'columns[6][search][regex]': 'false',
|
|
78
|
-
'columns[7][data]': 'total_volume',
|
|
79
|
-
'columns[7][name]': 'total_volume',
|
|
80
|
-
'columns[7][searchable]': 'true',
|
|
81
|
-
'columns[7][orderable]': 'true',
|
|
82
|
-
'columns[7][search][value]': '',
|
|
83
|
-
'columns[7][search][regex]': 'false',
|
|
84
|
-
'columns[8][data]': 'change_percent_formatted',
|
|
85
|
-
'columns[8][name]': 'change_percent',
|
|
86
|
-
'columns[8][searchable]': 'true',
|
|
87
|
-
'columns[8][orderable]': 'true',
|
|
88
|
-
'columns[8][search][value]': '',
|
|
89
|
-
'columns[8][search][regex]': 'false',
|
|
90
|
-
'columns[9][data]': 'percent_change_7d_formatted',
|
|
91
|
-
'columns[9][name]': 'percent_change_7d',
|
|
92
|
-
'columns[9][searchable]': 'true',
|
|
93
|
-
'columns[9][orderable]': 'true',
|
|
94
|
-
'columns[9][search][value]': '',
|
|
95
|
-
'columns[9][search][regex]': 'false',
|
|
96
|
-
'order[0][column]': 'currencies_order',
|
|
97
|
-
'order[0][dir]': 'asc',
|
|
98
|
-
'start': '0',
|
|
99
|
-
'length': '100',
|
|
100
|
-
'search[value]': '',
|
|
101
|
-
'search[regex]': 'false',
|
|
102
|
-
'currencyId': '12',
|
|
103
|
-
}
|
|
104
|
-
r = requests.post(url, data=payload, headers=headers)
|
|
105
|
-
data_json = r.json()
|
|
106
|
-
total_page = math.ceil(int(data_json['recordsTotal']) / 100)
|
|
107
|
-
big_df = pd.DataFrame()
|
|
108
|
-
for page in tqdm(range(1, total_page+1), leave=False):
|
|
109
|
-
payload.update({
|
|
110
|
-
"start": (page-1)*100,
|
|
111
|
-
'length': 100
|
|
112
|
-
})
|
|
113
|
-
r = requests.post(url, data=payload, headers=headers)
|
|
114
|
-
data_json = r.json()
|
|
115
|
-
temp_df = pd.DataFrame(data_json['data'])
|
|
116
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
117
|
-
big_df = big_df[[
|
|
118
|
-
'symbol',
|
|
119
|
-
'name',
|
|
120
|
-
'name_trans',
|
|
121
|
-
'sml_id',
|
|
122
|
-
'related_pair_ID',
|
|
123
|
-
]]
|
|
124
|
-
return big_df
|
|
125
|
-
else:
|
|
126
|
-
get_crypto_info_csv_path = get_crypto_info_csv()
|
|
127
|
-
name_url_df = pd.read_csv(get_crypto_info_csv_path)
|
|
128
|
-
return name_url_df
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def crypto_hist(
|
|
132
|
-
symbol: str = "BTC",
|
|
133
|
-
period: str = "每日",
|
|
134
|
-
start_date: str = "20191020",
|
|
135
|
-
end_date: str = "20201020",
|
|
136
|
-
):
|
|
137
|
-
"""
|
|
138
|
-
加密货币历史数据
|
|
139
|
-
https://cn.investing.com/crypto/ethereum/historical-data
|
|
140
|
-
:param symbol: 货币名称
|
|
141
|
-
:type symbol: str
|
|
142
|
-
:param period: choice of {"每日", "每周", "每月"}
|
|
143
|
-
:type period: str
|
|
144
|
-
:param start_date: '20151020', 注意格式
|
|
145
|
-
:type start_date: str
|
|
146
|
-
:param end_date: '20201020', 注意格式
|
|
147
|
-
:type end_date: str
|
|
148
|
-
:return: 加密货币历史数据获取
|
|
149
|
-
:rtype: pandas.DataFrame
|
|
150
|
-
"""
|
|
151
|
-
import warnings
|
|
152
|
-
warnings.filterwarnings('ignore')
|
|
153
|
-
headers = {
|
|
154
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
|
|
155
|
-
"X-Requested-With": "XMLHttpRequest",
|
|
156
|
-
}
|
|
157
|
-
period_map = {"每日": "Daily", "每周": "Weekly", "每月": "Monthly"}
|
|
158
|
-
start_date = "/".join([start_date[:4], start_date[4:6], start_date[6:]])
|
|
159
|
-
end_date = "/".join([end_date[:4], end_date[4:6], end_date[6:]])
|
|
160
|
-
name_url_df = crypto_name_url_table(symbol='local')
|
|
161
|
-
curr_id = name_url_df[name_url_df["symbol"] == symbol]["related_pair_ID"].values[0]
|
|
162
|
-
sml_id = name_url_df[name_url_df["symbol"] == symbol]["sml_id"].values[0]
|
|
163
|
-
url = "https://cn.investing.com/instruments/HistoricalDataAjax"
|
|
164
|
-
payload = {
|
|
165
|
-
"curr_id": curr_id,
|
|
166
|
-
"smlID": sml_id,
|
|
167
|
-
"header": "null",
|
|
168
|
-
"st_date": start_date,
|
|
169
|
-
"end_date": end_date,
|
|
170
|
-
"interval_sec": period_map[period],
|
|
171
|
-
"sort_col": "date",
|
|
172
|
-
"sort_ord": "DESC",
|
|
173
|
-
"action": "historical_data",
|
|
174
|
-
}
|
|
175
|
-
r = requests.post(url, data=payload, headers=headers)
|
|
176
|
-
|
|
177
|
-
temp_df = pd.read_html(r.text)[0]
|
|
178
|
-
df_data = temp_df.copy()
|
|
179
|
-
if period == "每月":
|
|
180
|
-
df_data.index = pd.to_datetime(df_data["日期"], format="%Y年%m月")
|
|
181
|
-
else:
|
|
182
|
-
df_data.index = pd.to_datetime(df_data["日期"], format="%Y年%m月%d日")
|
|
183
|
-
if any(df_data["交易量"].astype(str).str.contains("-")):
|
|
184
|
-
df_data["交易量"][df_data["交易量"].str.contains("-")] = df_data["交易量"][
|
|
185
|
-
df_data["交易量"].str.contains("-")
|
|
186
|
-
].replace("-", 0)
|
|
187
|
-
if any(df_data["交易量"].astype(str).str.contains("B")):
|
|
188
|
-
df_data["交易量"][df_data["交易量"].str.contains("B").fillna(False)] = (
|
|
189
|
-
df_data["交易量"][df_data["交易量"].str.contains("B").fillna(False)]
|
|
190
|
-
.str.replace("B", "")
|
|
191
|
-
.str.replace(",", "")
|
|
192
|
-
.astype(float)
|
|
193
|
-
* 1000000000
|
|
194
|
-
)
|
|
195
|
-
if any(df_data["交易量"].astype(str).str.contains("M")):
|
|
196
|
-
df_data["交易量"][df_data["交易量"].str.contains("M").fillna(False)] = (
|
|
197
|
-
df_data["交易量"][df_data["交易量"].str.contains("M").fillna(False)]
|
|
198
|
-
.str.replace("M", "")
|
|
199
|
-
.str.replace(",", "")
|
|
200
|
-
.astype(float)
|
|
201
|
-
* 1000000
|
|
202
|
-
)
|
|
203
|
-
if any(df_data["交易量"].astype(str).str.contains("K")):
|
|
204
|
-
df_data["交易量"][df_data["交易量"].str.contains("K").fillna(False)] = (
|
|
205
|
-
df_data["交易量"][df_data["交易量"].str.contains("K").fillna(False)]
|
|
206
|
-
.str.replace("K", "")
|
|
207
|
-
.str.replace(",", "")
|
|
208
|
-
.astype(float)
|
|
209
|
-
* 1000
|
|
210
|
-
)
|
|
211
|
-
df_data["交易量"] = df_data["交易量"].astype(float)
|
|
212
|
-
df_data["涨跌幅"] = pd.DataFrame(
|
|
213
|
-
round(
|
|
214
|
-
df_data["涨跌幅"].str.replace(",", "").str.replace("%", "").astype(float)
|
|
215
|
-
/ 100,
|
|
216
|
-
6,
|
|
217
|
-
)
|
|
218
|
-
)
|
|
219
|
-
del df_data["日期"]
|
|
220
|
-
df_data.reset_index(inplace=True)
|
|
221
|
-
df_data = df_data[[
|
|
222
|
-
"日期",
|
|
223
|
-
"收盘",
|
|
224
|
-
"开盘",
|
|
225
|
-
"高",
|
|
226
|
-
"低",
|
|
227
|
-
"交易量",
|
|
228
|
-
"涨跌幅",
|
|
229
|
-
]]
|
|
230
|
-
df_data['日期'] = pd.to_datetime(df_data['日期']).dt.date
|
|
231
|
-
df_data['收盘'] = pd.to_numeric(df_data['收盘'])
|
|
232
|
-
df_data['开盘'] = pd.to_numeric(df_data['开盘'])
|
|
233
|
-
df_data['高'] = pd.to_numeric(df_data['高'])
|
|
234
|
-
df_data['低'] = pd.to_numeric(df_data['低'])
|
|
235
|
-
df_data['交易量'] = pd.to_numeric(df_data['交易量'])
|
|
236
|
-
df_data['涨跌幅'] = pd.to_numeric(df_data['涨跌幅'])
|
|
237
|
-
df_data.sort_values('日期', inplace=True)
|
|
238
|
-
df_data.reset_index(inplace=True, drop=True)
|
|
239
|
-
return df_data
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
if __name__ == "__main__":
|
|
243
|
-
crypto_name_url_table_df = crypto_name_url_table(symbol="local")
|
|
244
|
-
print(crypto_name_url_table_df)
|
|
245
|
-
|
|
246
|
-
crypto_hist_df = crypto_hist(
|
|
247
|
-
symbol="BTC", period="每日", start_date="20201020", end_date="20220511"
|
|
248
|
-
)
|
|
249
|
-
print(crypto_hist_df)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|