akshare 1.16.26__py3-none-any.whl → 1.16.29__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 +5 -2
- akshare/futures/cons.py +120 -12
- akshare/futures/futures_foreign.py +14 -8
- akshare/futures/futures_hf_em.py +149 -4
- akshare/futures/futures_hq_sina.py +1 -1
- akshare/futures/futures_inventory_99.py +3 -3
- akshare/futures/futures_inventory_em.py +6 -6
- akshare/futures_derivative/futures_cot_sina.py +3 -1
- {akshare-1.16.26.dist-info → akshare-1.16.29.dist-info}/METADATA +1 -1
- {akshare-1.16.26.dist-info → akshare-1.16.29.dist-info}/RECORD +13 -13
- {akshare-1.16.26.dist-info → akshare-1.16.29.dist-info}/LICENSE +0 -0
- {akshare-1.16.26.dist-info → akshare-1.16.29.dist-info}/WHEEL +0 -0
- {akshare-1.16.26.dist-info → akshare-1.16.29.dist-info}/top_level.txt +0 -0
akshare/__init__.py
CHANGED
@@ -3035,9 +3035,12 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
|
|
3035
3035
|
1.16.24 fix: fix stock_financial_hk_report_em interface
|
3036
3036
|
1.16.25 fix: fix stock_financial_abstract_ths interface
|
3037
3037
|
1.16.26 add: add stock_hsgt_sh_hk_spot_em interface
|
3038
|
+
1.16.27 fix: fix futures_global_em interface
|
3039
|
+
1.16.28 fix: fix futures_global_hist_em interface
|
3040
|
+
1.16.29 fix: fix futures_global_hist_em interface
|
3038
3041
|
"""
|
3039
3042
|
|
3040
|
-
__version__ = "1.16.
|
3043
|
+
__version__ = "1.16.29"
|
3041
3044
|
__author__ = "AKFamily"
|
3042
3045
|
|
3043
3046
|
import sys
|
@@ -3212,7 +3215,7 @@ from akshare.stock_feature.stock_hsgt_min_em import stock_hsgt_fund_min_em
|
|
3212
3215
|
"""
|
3213
3216
|
东方财富网-行情中心-期货市场-国际期货
|
3214
3217
|
"""
|
3215
|
-
from akshare.futures.futures_hf_em import
|
3218
|
+
from akshare.futures.futures_hf_em import futures_global_spot_em, futures_global_hist_em
|
3216
3219
|
|
3217
3220
|
"""
|
3218
3221
|
雪球行情数据
|
akshare/futures/cons.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/5 18:00
|
5
5
|
Desc: 期货配置文件
|
6
6
|
"""
|
7
7
|
|
@@ -11,8 +11,92 @@ import os
|
|
11
11
|
import pickle
|
12
12
|
import re
|
13
13
|
|
14
|
+
|
15
|
+
futures_inventory_em_symbol_dict = {
|
16
|
+
"a": "A", # 豆一
|
17
|
+
"ag": "AG", # 沪银
|
18
|
+
"al": "AL", # 沪铝
|
19
|
+
"ao": "AO", # 氧化铝
|
20
|
+
"AP": "AP", # 苹果
|
21
|
+
"au": "AU", # 沪金
|
22
|
+
"b": "B", # 豆二
|
23
|
+
"bb": None, # 胶合板 (new中没有对应)
|
24
|
+
"bc": None, # 国际铜 (new中没有对应)
|
25
|
+
"br": "BR", # BR橡胶
|
26
|
+
"bu": "BU", # 沥青
|
27
|
+
"c": "C", # 玉米
|
28
|
+
"CF": "CF", # 棉花/郑棉
|
29
|
+
"CJ": "CJ", # 红枣
|
30
|
+
"cs": "CS", # 淀粉/玉米淀粉
|
31
|
+
"cu": "CU", # 沪铜
|
32
|
+
"CY": "CY", # 棉纱
|
33
|
+
"eb": "EB", # 苯乙烯
|
34
|
+
"ec": "ec", # 集运欧线/集运指数(欧线)
|
35
|
+
"eg": "EG", # 乙二醇
|
36
|
+
"fb": None, # 纤维板 (new中没有对应)
|
37
|
+
"FG": "FG", # 玻璃
|
38
|
+
"fu": "FU", # 燃料油/燃油
|
39
|
+
"hc": "HC", # 热卷
|
40
|
+
"i": "I", # 铁矿石
|
41
|
+
"IC": "IC", # 中证500
|
42
|
+
"IF": "IF", # 沪深300
|
43
|
+
"IH": "IH", # 上证50
|
44
|
+
"IM": "IM", # 中证1000
|
45
|
+
"j": "J", # 焦炭
|
46
|
+
"jd": "JD", # 鸡蛋
|
47
|
+
"jm": "JM", # 焦煤
|
48
|
+
"JR": None, # 粳稻 (new中没有对应)
|
49
|
+
"l": "L", # 塑料
|
50
|
+
"lc": "lc", # 碳酸锂
|
51
|
+
"lh": "LH", # 生猪
|
52
|
+
"LR": None, # 晚籼稻 (new中没有对应)
|
53
|
+
"lu": "lu", # LU燃油/低硫燃料油
|
54
|
+
"m": "M", # 豆粕
|
55
|
+
"MA": "MA", # 甲醇
|
56
|
+
"ni": "NI", # 沪镍/镍
|
57
|
+
"nr": "nr", # 20号胶
|
58
|
+
"OI": "OI", # 菜籽油/菜油
|
59
|
+
"p": "P", # 棕榈油/棕榈
|
60
|
+
"pb": "PB", # 沪铅
|
61
|
+
"PF": "PF", # 短纤
|
62
|
+
"pg": "PG", # 液化气/液化石油气
|
63
|
+
"PK": "PK", # 花生
|
64
|
+
"PM": None, # 普麦 (new中没有对应)
|
65
|
+
"pp": "PP", # 聚丙烯
|
66
|
+
"PX": "PX", # 对二甲苯
|
67
|
+
"rb": "RB", # 螺纹钢
|
68
|
+
"RI": None, # 早籼稻 (new中没有对应)
|
69
|
+
"RM": "RM", # 菜籽粕/菜粕
|
70
|
+
"rr": None, # 粳米 (new中没有对应)
|
71
|
+
"RS": "RS", # 油菜籽/菜籽
|
72
|
+
"ru": "RU", # 橡胶
|
73
|
+
"SA": "SA", # 纯碱
|
74
|
+
"sc": None, # 原油 (new中没有对应)
|
75
|
+
"SF": "SF", # 硅铁
|
76
|
+
"SH": "SH", # 烧碱
|
77
|
+
"si": "si", # 工业硅
|
78
|
+
"SM": "SM", # 锰硅
|
79
|
+
"sn": "SN", # 沪锡/锡
|
80
|
+
"sp": "SP", # 纸浆
|
81
|
+
"SR": "SR", # 白糖
|
82
|
+
"ss": "SS", # 不锈钢
|
83
|
+
"T": "T", # 十年国债/10年期国债
|
84
|
+
"TA": "TA", # PTA
|
85
|
+
"TF": "TF", # 五年国债/5年期国债
|
86
|
+
"TL": "TL", # 三十年国债/30年期国债期货
|
87
|
+
"TS": "TS", # 二年国债/2年期国债
|
88
|
+
"UR": "UR", # 尿素
|
89
|
+
"v": "V", # PVC
|
90
|
+
"WH": None, # 强麦 (new中没有对应)
|
91
|
+
"wr": None, # 线材 (new中没有对应)
|
92
|
+
"y": "Y", # 豆油
|
93
|
+
"ZC": None, # 动力煤 (new中没有对应)
|
94
|
+
"zn": "ZN", # 沪锌
|
95
|
+
}
|
96
|
+
|
14
97
|
hq_sina_spot_headers = {
|
15
|
-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,
|
98
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,"
|
99
|
+
"image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
|
16
100
|
"Accept-Encoding": "gzip, deflate",
|
17
101
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
18
102
|
"Cache-Control": "no-cache",
|
@@ -21,14 +105,18 @@ hq_sina_spot_headers = {
|
|
21
105
|
"Pragma": "no-cache",
|
22
106
|
"Referer": "https://finance.sina.com.cn/futuremarket/",
|
23
107
|
"Upgrade-Insecure-Requests": "1",
|
24
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
|
108
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
109
|
+
"(KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36",
|
25
110
|
}
|
26
111
|
|
27
112
|
# zh_sina_spot
|
28
113
|
zh_subscribe_exchange_symbol_url = (
|
29
114
|
"http://vip.stock.finance.sina.com.cn/quotes_service/view/js/qihuohangqing.js"
|
30
115
|
)
|
31
|
-
zh_match_main_contract_url =
|
116
|
+
zh_match_main_contract_url = (
|
117
|
+
"http://vip.stock.finance.sina.com.cn/quotes_service/"
|
118
|
+
"api/json_v2.php/Market_Center.getHQFuturesData"
|
119
|
+
)
|
32
120
|
zh_match_main_contract_payload = {
|
33
121
|
"page": "1",
|
34
122
|
"num": "5",
|
@@ -48,7 +136,8 @@ zh_sina_spot_headers = {
|
|
48
136
|
"Referer": "https://finance.sina.com.cn/futuremarket/",
|
49
137
|
"Sec-Fetch-Mode": "no-cors",
|
50
138
|
"Sec-Fetch-Site": "cross-site",
|
51
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
139
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
140
|
+
"Chrome/78.0.3904.97 Safari/537.36",
|
52
141
|
}
|
53
142
|
|
54
143
|
# 99 期货
|
@@ -58,10 +147,18 @@ inventory_temp_headers = {
|
|
58
147
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
59
148
|
"Connection": "keep-alive",
|
60
149
|
"Content-Type": "application/x-www-form-urlencoded",
|
61
|
-
"Cookie": "UM_distinctid=16c378978de5cc-02cfeac5f7869b-c343162-1fa400-16c378978df8d7;
|
150
|
+
"Cookie": "UM_distinctid=16c378978de5cc-02cfeac5f7869b-c343162-1fa400-16c378978df8d7; "
|
151
|
+
"__utmz=181566328.1570520149.3.2.utmcsr=baidu|utmccn=(organic)|utmcmd=organic; "
|
152
|
+
"ASP.NET_SessionId=wj5gxuzl3fvvr25503tquq55; __utmc=181566328; _fxaid=1D9A634AB9F5D026585"
|
153
|
+
"6F7E85E7BC196%1D%2BOOl1inxPE7181fmKs5HCs%2BdLO%2Fq%2FbSvf46UVjo%2BE7w%3D%1DPYphpUa9OlzW"
|
154
|
+
"UzatrOQTXLPOVillbwMhTIJas%2ByfkyVL2Hd5XA1GOSslksqDkMTccXvQ2duLNsc0CHT4789JrYNbakJrpzrxL"
|
155
|
+
"nwtBC5GCTssKHGEpor6EwAZfWJgBUlCs4JYFcGUnh3jIO69A4LsOlRMOGf4c9cd%2FbohSjTx3VA%3D; __utma"
|
156
|
+
"=181566328.1348268634.1564299852.1571066568.1571068391.7; tgw_l7_route=eb1311426274fc07"
|
157
|
+
"631b2135a6431f7d; __utmt=1; __utmb=181566328.7.10.1571068391",
|
62
158
|
"Host": "service.99qh.com",
|
63
159
|
"Referer": "http://service.99qh.com/Storage/Storage.aspx?page=99qh",
|
64
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
|
160
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
161
|
+
"(KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36",
|
65
162
|
}
|
66
163
|
|
67
164
|
# 奇货可查
|
@@ -177,7 +274,8 @@ headers = {
|
|
177
274
|
"Cache-Control": "max-age=0",
|
178
275
|
"Accept": "text/html, */*; q=0.01",
|
179
276
|
"X-Requested-With": "XMLHttpRequest",
|
180
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
|
277
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
278
|
+
"Chrome/56.0.2924.87 Safari/537.36",
|
181
279
|
"DNT": "1",
|
182
280
|
"Referer": "http://www.super-ping.com/?ping=www.google.com&locale=sc",
|
183
281
|
"Accept-Encoding": "gzip, deflate, sdch",
|
@@ -187,7 +285,8 @@ headers = {
|
|
187
285
|
shfe_headers = {"User-Agent": "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)"}
|
188
286
|
|
189
287
|
dce_headers = {
|
190
|
-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng
|
288
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,"
|
289
|
+
"*/*;q=0.8,application/signed-exchange;v=b3",
|
191
290
|
"Accept-Encoding": "gzip, deflate",
|
192
291
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
193
292
|
"Cache-Control": "max-age=0",
|
@@ -198,7 +297,8 @@ dce_headers = {
|
|
198
297
|
"Proxy-Connection": "keep-alive",
|
199
298
|
"Referer": "http://www.dce.com.cn/publicweb/quotesdata/weekQuotesCh.html",
|
200
299
|
"Upgrade-Insecure-Requests": "1",
|
201
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
300
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
301
|
+
"Chrome/77.0.3865.90 Safari/537.36",
|
202
302
|
}
|
203
303
|
|
204
304
|
SYS_SPOT_PRICE_URL = "http://www.100ppi.com/sf/day-{}.html"
|
@@ -206,8 +306,16 @@ SYS_SPOT_PRICE_LATEST_URL = "http://www.100ppi.com/sf/"
|
|
206
306
|
|
207
307
|
SHFE_VOL_RANK_URL = "https://tsite.shfe.com.cn/data/dailydata/kx/pm%s.dat"
|
208
308
|
CFFEX_VOL_RANK_URL = "http://www.cffex.com.cn/sj/ccpm/%s/%s/%s_1.csv"
|
209
|
-
DCE_VOL_RANK_URL_1 =
|
210
|
-
|
309
|
+
DCE_VOL_RANK_URL_1 = (
|
310
|
+
"http://www.dce.com.cn/publicweb/quotesdata/exportMemberDealPosiQuotesData.html?"
|
311
|
+
"memberDealPosiQuotes.variety=%s&memberDealPosiQuotes.trade_type=0&contract.cont"
|
312
|
+
"ract_id=%s&contract.variety_id=%s&year=%s&month=%s&day=%s&exportFlag=txt"
|
313
|
+
)
|
314
|
+
DCE_VOL_RANK_URL_2 = (
|
315
|
+
"http://www.dce.com.cn/publicweb/quotesdata/memberDealPosiQuotes.html?memberDeal"
|
316
|
+
"PosiQuotes.variety=%s&memberDealPosiQuotes.trade_type=0&contract.contract_id="
|
317
|
+
"all&contract.variety_id=%s&year=%s&month=%s&day=%s"
|
318
|
+
)
|
211
319
|
CZCE_VOL_RANK_URL_1 = "http://www.czce.com.cn/cn/exchange/jyxx/pm/pm%s.html"
|
212
320
|
CZCE_VOL_RANK_URL_2 = "http://www.czce.com.cn/cn/exchange/%s/datatradeholding/%s.htm"
|
213
321
|
CZCE_VOL_RANK_URL_3 = (
|
@@ -1,30 +1,36 @@
|
|
1
1
|
#!/usr/bin/env python
|
2
2
|
# -*- coding:utf-8 -*-
|
3
3
|
"""
|
4
|
-
Date:
|
4
|
+
Date: 2025/3/5 18:00
|
5
5
|
Desc: 外盘期货-历史行情数据-日频率
|
6
6
|
https://finance.sina.com.cn/money/future/hf.html
|
7
7
|
"""
|
8
|
+
|
8
9
|
from datetime import datetime
|
9
10
|
from io import StringIO
|
10
11
|
|
11
12
|
import pandas as pd
|
12
13
|
import requests
|
13
14
|
|
14
|
-
from akshare.futures.futures_hq_sina import
|
15
|
+
from akshare.futures.futures_hq_sina import (
|
16
|
+
futures_foreign_commodity_subscribe_exchange_symbol,
|
17
|
+
)
|
15
18
|
|
16
19
|
|
17
20
|
def futures_foreign_hist(symbol: str = "ZSD") -> pd.DataFrame:
|
18
21
|
"""
|
19
22
|
外盘期货-历史行情数据-日频率
|
20
23
|
https://finance.sina.com.cn/money/future/hf.html
|
21
|
-
:param symbol:
|
24
|
+
:param symbol: 外盘期货代码, 可以通过 ak.futures_foreign_commodity_subscribe_exchange_symbol() 来获取所有品种代码
|
22
25
|
:type symbol: str
|
23
|
-
:return:
|
26
|
+
:return: 历史行情数据-日频率
|
24
27
|
:rtype: pandas.DataFrame
|
25
28
|
"""
|
26
|
-
today = f
|
27
|
-
url =
|
29
|
+
today = f"{datetime.today().year}_{datetime.today().month}_{datetime.today().day}"
|
30
|
+
url = (
|
31
|
+
f"https://stock2.finance.sina.com.cn/futures/api/jsonp.php/var%20_S{today}=/"
|
32
|
+
f"GlobalFuturesService.getGlobalFuturesDailyKLine"
|
33
|
+
)
|
28
34
|
params = {
|
29
35
|
"symbol": symbol,
|
30
36
|
"_": today,
|
@@ -32,7 +38,7 @@ def futures_foreign_hist(symbol: str = "ZSD") -> pd.DataFrame:
|
|
32
38
|
}
|
33
39
|
r = requests.get(url, params=params)
|
34
40
|
data_text = r.text
|
35
|
-
data_df = pd.read_json(StringIO(data_text[data_text.find("[")
|
41
|
+
data_df = pd.read_json(StringIO(data_text[data_text.find("[") : -2]))
|
36
42
|
return data_df
|
37
43
|
|
38
44
|
|
@@ -52,7 +58,7 @@ def futures_foreign_detail(symbol: str = "ZSD") -> pd.DataFrame:
|
|
52
58
|
return data_df
|
53
59
|
|
54
60
|
|
55
|
-
if __name__ ==
|
61
|
+
if __name__ == "__main__":
|
56
62
|
futures_foreign_hist_df = futures_foreign_hist(symbol="ZSD")
|
57
63
|
print(futures_foreign_hist_df)
|
58
64
|
|
akshare/futures/futures_hf_em.py
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
#!/usr/bin/env python
|
2
2
|
# -*- coding:utf-8 -*-
|
3
3
|
"""
|
4
|
-
Date:
|
4
|
+
Date: 2025/3/5 19:00
|
5
5
|
Desc: 东方财富网-行情中心-期货市场-国际期货
|
6
6
|
https://quote.eastmoney.com/center/gridlist.html#futures_global
|
7
7
|
"""
|
8
8
|
|
9
9
|
import math
|
10
|
+
from typing import Optional
|
10
11
|
|
11
12
|
import pandas as pd
|
12
13
|
import requests
|
@@ -14,7 +15,76 @@ import requests
|
|
14
15
|
from akshare.utils.tqdm import get_tqdm
|
15
16
|
|
16
17
|
|
17
|
-
def
|
18
|
+
def __futures_global_hist_market_code(symbol: str = "HG00Y") -> Optional[int]:
|
19
|
+
"""
|
20
|
+
东方财富网-行情中心-期货市场-国际期货-品种市场对照表
|
21
|
+
https://quote.eastmoney.com/center/gridlist.html#futures_global
|
22
|
+
:param symbol: HG00Y, 品种代码;可以通过 ak.futures_global_spot_em() 来获取所有可获取历史行情数据的品种代码
|
23
|
+
:type symbol: str
|
24
|
+
:return: 品种所属于的市场
|
25
|
+
:rtype: str
|
26
|
+
"""
|
27
|
+
# 提取品种代码(去掉年份和月份部分)
|
28
|
+
base_symbol = ""
|
29
|
+
i = 0
|
30
|
+
while i < len(symbol) and not symbol[i].isdigit():
|
31
|
+
base_symbol += symbol[i]
|
32
|
+
i += 1
|
33
|
+
# 如果代码中没有数字(异常情况),则返回整个代码作为基础品种代码
|
34
|
+
if not base_symbol and i == len(symbol):
|
35
|
+
base_symbol = symbol
|
36
|
+
# 金属和贵金属品种 - 101
|
37
|
+
if base_symbol in ["HG", "GC", "SI", "QI", "QO", "MGC", "LTH"]:
|
38
|
+
return 101
|
39
|
+
# 能源品种 - 102
|
40
|
+
if base_symbol in ["CL", "NG", "RB", "HO", "PA", "PL", "QM"]:
|
41
|
+
return 102
|
42
|
+
# 农产品和金融品种 - 103
|
43
|
+
if base_symbol in [
|
44
|
+
"ZW",
|
45
|
+
"ZM",
|
46
|
+
"ZS",
|
47
|
+
"ZC",
|
48
|
+
"XC",
|
49
|
+
"XK",
|
50
|
+
"XW",
|
51
|
+
"YM",
|
52
|
+
"TY",
|
53
|
+
"US",
|
54
|
+
"EH",
|
55
|
+
"ZL",
|
56
|
+
"ZR",
|
57
|
+
"ZO",
|
58
|
+
"FV",
|
59
|
+
"TU",
|
60
|
+
"UL",
|
61
|
+
"NQ",
|
62
|
+
"ES",
|
63
|
+
]:
|
64
|
+
return 103
|
65
|
+
# 中国市场特有品种 - 104
|
66
|
+
if base_symbol in ["TF", "RT", "CN"]:
|
67
|
+
return 104
|
68
|
+
# 软商品期货 - 108
|
69
|
+
if base_symbol in ["SB", "CT", "SF"]:
|
70
|
+
return 108
|
71
|
+
# 特殊L开头品种 - 109
|
72
|
+
if base_symbol in ["LCPT", "LZNT", "LALT", "LTNT", "LLDT", "LNKT"]:
|
73
|
+
return 109
|
74
|
+
# MPM开头品种 - 110
|
75
|
+
if base_symbol == "MPM":
|
76
|
+
return 110
|
77
|
+
# 日本市场品种 - 111
|
78
|
+
if base_symbol.startswith("J"):
|
79
|
+
return 111
|
80
|
+
# 单字母代码品种 - 112
|
81
|
+
if base_symbol in ["M", "B", "G"]:
|
82
|
+
return 112
|
83
|
+
# 如果没有匹配到任何规则,返回一个默认值或者错误
|
84
|
+
return None
|
85
|
+
|
86
|
+
|
87
|
+
def futures_global_spot_em() -> pd.DataFrame:
|
18
88
|
"""
|
19
89
|
东方财富网-行情中心-期货市场-国际期货
|
20
90
|
https://quote.eastmoney.com/center/gridlist.html#futures_global
|
@@ -98,6 +168,81 @@ def futures_global_em() -> pd.DataFrame:
|
|
98
168
|
return big_df
|
99
169
|
|
100
170
|
|
171
|
+
def futures_global_hist_em(symbol: str = "HG00Y") -> pd.DataFrame:
|
172
|
+
"""
|
173
|
+
东方财富网-行情中心-期货市场-国际期货-历史行情数据
|
174
|
+
https://quote.eastmoney.com/globalfuture/HG25J.html
|
175
|
+
:param symbol: 品种代码;可以通过 ak.futures_global_spot_em() 来获取所有可获取历史行情数据的品种代码
|
176
|
+
:type symbol: str
|
177
|
+
:return: 历史行情数据
|
178
|
+
:rtype: pandas.DataFrame
|
179
|
+
"""
|
180
|
+
url = "https://push2his.eastmoney.com/api/qt/stock/kline/get"
|
181
|
+
market_code = __futures_global_hist_market_code(symbol)
|
182
|
+
params = {
|
183
|
+
"secid": f"{market_code}.{symbol}",
|
184
|
+
"klt": "101",
|
185
|
+
"fqt": "1",
|
186
|
+
"lmt": "6600",
|
187
|
+
"end": "20500000",
|
188
|
+
"iscca": "1",
|
189
|
+
"fields1": "f1,f2,f3,f4,f5,f6,f7,f8",
|
190
|
+
"fields2": "f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",
|
191
|
+
"ut": "f057cbcbce2a86e2866ab8877db1d059",
|
192
|
+
"forcect": "1",
|
193
|
+
}
|
194
|
+
r = requests.get(url, params=params)
|
195
|
+
data_json = r.json()
|
196
|
+
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]["klines"]])
|
197
|
+
temp_df["code"] = data_json["data"]["code"]
|
198
|
+
temp_df["name"] = data_json["data"]["name"]
|
199
|
+
temp_df.columns = [
|
200
|
+
"日期",
|
201
|
+
"开盘",
|
202
|
+
"最新价",
|
203
|
+
"最高",
|
204
|
+
"最低",
|
205
|
+
"总量",
|
206
|
+
"-",
|
207
|
+
"-",
|
208
|
+
"涨幅",
|
209
|
+
"-",
|
210
|
+
"-",
|
211
|
+
"-",
|
212
|
+
"持仓",
|
213
|
+
"日增",
|
214
|
+
"代码",
|
215
|
+
"名称",
|
216
|
+
]
|
217
|
+
temp_df = temp_df[
|
218
|
+
[
|
219
|
+
"日期",
|
220
|
+
"代码",
|
221
|
+
"名称",
|
222
|
+
"开盘",
|
223
|
+
"最新价",
|
224
|
+
"最高",
|
225
|
+
"最低",
|
226
|
+
"总量",
|
227
|
+
"涨幅",
|
228
|
+
"持仓",
|
229
|
+
"日增",
|
230
|
+
]
|
231
|
+
]
|
232
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
233
|
+
temp_df["开盘"] = pd.to_numeric(temp_df["开盘"], errors="coerce")
|
234
|
+
temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
|
235
|
+
temp_df["最高"] = pd.to_numeric(temp_df["最高"], errors="coerce")
|
236
|
+
temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce")
|
237
|
+
temp_df["总量"] = pd.to_numeric(temp_df["总量"], errors="coerce")
|
238
|
+
temp_df["涨幅"] = pd.to_numeric(temp_df["涨幅"], errors="coerce")
|
239
|
+
temp_df["日增"] = pd.to_numeric(temp_df["日增"], errors="coerce")
|
240
|
+
return temp_df
|
241
|
+
|
242
|
+
|
101
243
|
if __name__ == "__main__":
|
102
|
-
|
103
|
-
print(
|
244
|
+
futures_global_spot_em_df = futures_global_spot_em()
|
245
|
+
print(futures_global_spot_em_df)
|
246
|
+
|
247
|
+
futures_global_hist_em_df = futures_global_hist_em(symbol="HG00Y")
|
248
|
+
print(futures_global_hist_em_df)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env python
|
2
2
|
# -*- coding:utf-8 -*-
|
3
3
|
"""
|
4
|
-
Date: 2025/
|
4
|
+
Date: 2025/3/5 17:30
|
5
5
|
Desc: 99 期货网-大宗商品库存数据
|
6
6
|
https://www.99qh.com/
|
7
7
|
"""
|
@@ -73,7 +73,7 @@ def futures_inventory_99(symbol: str = "豆一") -> pd.DataFrame:
|
|
73
73
|
"productId": product_id,
|
74
74
|
"type": "1",
|
75
75
|
"pageNo": "1",
|
76
|
-
"pageSize": "
|
76
|
+
"pageSize": "5000",
|
77
77
|
"startDate": "",
|
78
78
|
"endDate": f"{datetime.now().date().isoformat()}",
|
79
79
|
"appCategory": "web",
|
@@ -90,5 +90,5 @@ def futures_inventory_99(symbol: str = "豆一") -> pd.DataFrame:
|
|
90
90
|
|
91
91
|
|
92
92
|
if __name__ == "__main__":
|
93
|
-
futures_inventory_99_df = futures_inventory_99(symbol="
|
93
|
+
futures_inventory_99_df = futures_inventory_99(symbol="a")
|
94
94
|
print(futures_inventory_99_df)
|
@@ -1,16 +1,17 @@
|
|
1
1
|
#!/usr/bin/env python
|
2
2
|
# -*- coding:utf-8 -*-
|
3
3
|
"""
|
4
|
-
Date: 2025/
|
4
|
+
Date: 2025/3/5 17:30
|
5
5
|
Desc: 东方财富网-数据中心-期货库存数据
|
6
6
|
https://data.eastmoney.com/ifdata/kcsj.html
|
7
7
|
"""
|
8
8
|
|
9
9
|
import pandas as pd
|
10
10
|
import requests
|
11
|
+
from akshare.futures.cons import futures_inventory_em_symbol_dict
|
11
12
|
|
12
13
|
|
13
|
-
def futures_inventory_em(symbol: str = "
|
14
|
+
def futures_inventory_em(symbol: str = "a") -> pd.DataFrame:
|
14
15
|
"""
|
15
16
|
东方财富网-数据中心-期货库存数据
|
16
17
|
https://data.eastmoney.com/ifdata/kcsj.html
|
@@ -36,11 +37,10 @@ def futures_inventory_em(symbol: str = "A") -> pd.DataFrame:
|
|
36
37
|
symbol_dict = dict(zip(temp_df["TRADE_TYPE"], temp_df["TRADE_CODE"]))
|
37
38
|
if symbol in symbol_dict.keys():
|
38
39
|
product_id = symbol_dict[symbol]
|
39
|
-
elif symbol in
|
40
|
-
product_id = symbol
|
40
|
+
elif symbol in futures_inventory_em_symbol_dict.keys(): # 如果输入的是代码
|
41
|
+
product_id = futures_inventory_em_symbol_dict[symbol]
|
41
42
|
else:
|
42
43
|
raise ValueError(f"请输入正确的 symbol, 可选项为: {symbol_dict}")
|
43
|
-
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
|
44
44
|
params = {
|
45
45
|
"reportName": "RPT_FUTU_STOCKDATA",
|
46
46
|
"columns": "SECURITY_CODE,TRADE_DATE,ON_WARRANT_NUM,ADDCHANGE",
|
@@ -67,5 +67,5 @@ def futures_inventory_em(symbol: str = "A") -> pd.DataFrame:
|
|
67
67
|
|
68
68
|
|
69
69
|
if __name__ == "__main__":
|
70
|
-
futures_inventory_em_df = futures_inventory_em(symbol="
|
70
|
+
futures_inventory_em_df = futures_inventory_em(symbol="a")
|
71
71
|
print(futures_inventory_em_df)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env python
|
2
2
|
# -*- coding:utf-8 -*-
|
3
3
|
"""
|
4
|
-
Date:
|
4
|
+
Date: 2025/3/5 18:00
|
5
5
|
Desc: 新浪财经-期货-成交持仓
|
6
6
|
https://vip.stock.finance.sina.com.cn/q/view/vFutures_Positions_cjcc.php
|
7
7
|
"""
|
@@ -55,6 +55,8 @@ def futures_hold_pos_sina(
|
|
55
55
|
temp_df["比上交易增减"], errors="coerce"
|
56
56
|
)
|
57
57
|
return temp_df
|
58
|
+
else:
|
59
|
+
raise ValueError("请输入正确的 symbol 参数")
|
58
60
|
|
59
61
|
|
60
62
|
if __name__ == "__main__":
|
@@ -1,4 +1,4 @@
|
|
1
|
-
akshare/__init__.py,sha256=
|
1
|
+
akshare/__init__.py,sha256=0nKkoBzlF340MgMYFgSBYV8fmLvgWMDXYhA6G_cKozY,189642
|
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
|
@@ -103,7 +103,7 @@ akshare/fund/fund_scale_em.py,sha256=8XLZpz9DzsAnJCo1moBmzf3u7mfZNZHsb3cPKJ-gCJM
|
|
103
103
|
akshare/fund/fund_scale_sina.py,sha256=A0qIzWBQdE3IGS9-cxO9_FNpuH-BAG5HhPk5KzTFTFc,8167
|
104
104
|
akshare/fund/fund_xq.py,sha256=AxMZB-940bNY7-BatVLZiseHNxiWA17hQzTfuxGibPU,11306
|
105
105
|
akshare/futures/__init__.py,sha256=RMTf1bT5EOE3ttWpn3hGu1LtUmsVxDoa0W7W0gXHOy8,81
|
106
|
-
akshare/futures/cons.py,sha256=
|
106
|
+
akshare/futures/cons.py,sha256=SO11mUW9n0K3wVDwkUmqJepD4XL-1-MEBbsfdqrNnlA,17540
|
107
107
|
akshare/futures/cot.py,sha256=GptYlcw4lyHOhW8M5hW55sNMk_fz3swjikhaSJqAmYo,58624
|
108
108
|
akshare/futures/futures_basis.py,sha256=pmXNXdWnfvJCRs6xKJ0Ed9R2v92-NK2Sp3AjlwecErc,15691
|
109
109
|
akshare/futures/futures_comex_em.py,sha256=V-mkKQkH5N8PyaZWKdyggb2lTnY8DDDxiUPt-1leQu0,3171
|
@@ -111,13 +111,13 @@ akshare/futures/futures_comm_ctp.py,sha256=V8TEKO0R0i6LfE8DDFqrMA3JGwNlpmaQCvvMu
|
|
111
111
|
akshare/futures/futures_comm_qihuo.py,sha256=uQfabZ63qME8sTaxUbIUVQBVi8yTaPPDhD7voR9PEx0,10504
|
112
112
|
akshare/futures/futures_contract_detail.py,sha256=auwzNdaoFi5hoJY6rNkO54v5FD2gmEkQu7B90yEDtkc,1175
|
113
113
|
akshare/futures/futures_daily_bar.py,sha256=pultXs8digLfWT0dzyWs0AtFk3Fi2uZDT-zxbg_PcOM,25299
|
114
|
-
akshare/futures/futures_foreign.py,sha256=
|
115
|
-
akshare/futures/futures_hf_em.py,sha256=
|
114
|
+
akshare/futures/futures_foreign.py,sha256=2cbMA-eug_jriDFwKZWmA_TbPW2GQAjscpZHBrs287E,2131
|
115
|
+
akshare/futures/futures_hf_em.py,sha256=vEgJav-g_PNO_Jh4Xup27PIt-ARGqVk9TjNXK_3eC-E,7966
|
116
116
|
akshare/futures/futures_hist_em.py,sha256=Q8I20qRjp2ujiJMCCNBvTHXmrIth22p2k6KpvbkC3dk,6472
|
117
|
-
akshare/futures/futures_hq_sina.py,sha256=
|
117
|
+
akshare/futures/futures_hq_sina.py,sha256=HZBAve1yxp1fnwgEy_2CqVoniTXRkt8KI3REt0N0TiY,9575
|
118
118
|
akshare/futures/futures_index_ccidx.py,sha256=_kgWioCOpFNn8WUcL5qKHGb3rUHzrbrx2AszprKpBh4,4460
|
119
|
-
akshare/futures/futures_inventory_99.py,sha256=
|
120
|
-
akshare/futures/futures_inventory_em.py,sha256=
|
119
|
+
akshare/futures/futures_inventory_99.py,sha256=2KPoa0UQ3qQhR9hdIoEapc1TGZek5ojSY8qr6BUtopM,3354
|
120
|
+
akshare/futures/futures_inventory_em.py,sha256=xbWcILKJpwdC2629U5CZ8TF-xhxlYYhf6qgFyreton4,2680
|
121
121
|
akshare/futures/futures_news_shmet.py,sha256=1epZ3MwDc-T2n1ie4SSDfvUaBiMpSL0Q_xb2VoZ_llU,2465
|
122
122
|
akshare/futures/futures_roll_yield.py,sha256=RiwN0yYwzYy8zGhmTopBwJ37aUQ7Llwh3eQRzn0apaE,6135
|
123
123
|
akshare/futures/futures_rule.py,sha256=38fJnUTohGqbwE65ZR1id7Oy-0DS-ODrGYsmx2jtGZ8,1571
|
@@ -139,7 +139,7 @@ akshare/futures_derivative/futures_contract_info_dce.py,sha256=pzSy8w280imjla3x8
|
|
139
139
|
akshare/futures_derivative/futures_contract_info_gfex.py,sha256=uaAMVFeK9O1-BI7pYu94PHhkEX0FnakkvqjgEc5MVQE,2162
|
140
140
|
akshare/futures_derivative/futures_contract_info_ine.py,sha256=vwCPG-Vl8c_Wy3ydBZ11ghMM5gjuPN0x9QFvyWxewXI,2433
|
141
141
|
akshare/futures_derivative/futures_contract_info_shfe.py,sha256=2LtmACu_PcVlM9k5bEfMM44Vz5yDHXA7mE9alEZepgA,2462
|
142
|
-
akshare/futures_derivative/futures_cot_sina.py,sha256=
|
142
|
+
akshare/futures_derivative/futures_cot_sina.py,sha256=CmoZu_pItwqX0QNsJMpmEu9I84GBaQhq4dIUkP0Piyw,2815
|
143
143
|
akshare/futures_derivative/futures_hog.py,sha256=8VVd7w5LCUZWFdkffV7-dqihGcqdJlR1ks1evpcU9O0,11613
|
144
144
|
akshare/futures_derivative/futures_index_sina.py,sha256=G1dPeQcsHwMG81J4MqVjkHqFBM363ktzJmNI-EBsi3A,5902
|
145
145
|
akshare/futures_derivative/futures_spot_sys.py,sha256=Ufqh7S7UAeW_zkASap_DZGqwyW_Vgrf2UOhedYhe-BU,3351
|
@@ -383,8 +383,8 @@ akshare/utils/token_process.py,sha256=K4rGXjh_tgugbRcyOK2h2x0jP3PT65IIK7nxhUKhOe
|
|
383
383
|
akshare/utils/tqdm.py,sha256=MuPNwcswkOGjwWQOMWXi9ZvQ_RmW4obCWRj2i7HM7FE,847
|
384
384
|
tests/__init__.py,sha256=gNzhlO0UPjFq6Ieb38kaVIODXv4cTDByrdohAZnDYt4,82
|
385
385
|
tests/test_func.py,sha256=j1MGYbZI2if2j_LY1S4FLsf4qfq4NwVqD5wmRlv5Log,832
|
386
|
-
akshare-1.16.
|
387
|
-
akshare-1.16.
|
388
|
-
akshare-1.16.
|
389
|
-
akshare-1.16.
|
390
|
-
akshare-1.16.
|
386
|
+
akshare-1.16.29.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
|
387
|
+
akshare-1.16.29.dist-info/METADATA,sha256=RWyZ6eGQqJw6yAxLc7GyPWNLJYW6pjHFfbwRxsfjupE,13847
|
388
|
+
akshare-1.16.29.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
389
|
+
akshare-1.16.29.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
|
390
|
+
akshare-1.16.29.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|