akshare 1.15.34__py3-none-any.whl → 1.15.36__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 CHANGED
@@ -2944,9 +2944,11 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
2944
2944
  1.15.32 fix: fix stock_info_global_cls interface
2945
2945
  1.15.33 add: add stock_value_em interface
2946
2946
  1.15.34 fix: fix fund_open_fund_rank_em interface
2947
+ 1.15.35 fix: fix futures_spot_price_daily interface
2948
+ 1.15.36 fix: fix futures_global_em interface
2947
2949
  """
2948
2950
 
2949
- __version__ = "1.15.34"
2951
+ __version__ = "1.15.36"
2950
2952
  __author__ = "AKFamily"
2951
2953
 
2952
2954
  import sys
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2024/5/3 16:30
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.loc[:, "date"] = date.strftime("%Y%m%d")
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["商品"] = values["商品"].tolist()
305
+ basis.index = values.index
293
306
  basis = pd.merge(
294
- values[["商品", "现货价格", "主力合约代码", "主力合约价格"]], basis
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="20240415", end_day="20240418", vars_list=["CU", "RB"]
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="20240430")
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="20240430")
348
+ futures_spot_price_previous_df = futures_spot_price_previous(date="20241128")
332
349
  print(futures_spot_price_previous_df)
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2024/1/18 17:40
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
@@ -13,7 +14,7 @@ import requests
13
14
  from akshare.utils.tqdm import get_tqdm
14
15
 
15
16
 
16
- def futures_global_em():
17
+ def futures_global_em() -> pd.DataFrame:
17
18
  """
18
19
  东方财富网-行情中心-期货市场-国际期货
19
20
  https://quote.eastmoney.com/center/gridlist.html#futures_global
@@ -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
- 'orderBy': 'zdf',
26
- 'sort': 'desc',
27
- 'pageSize': '20',
28
- 'pageIndex': '0',
29
- 'token': '58b2fa8f54638b60b87d69b31969089c',
30
- 'field': 'dm,sc,name,p,zsjd,zde,zdf,f152,o,h,l,zjsj,vol,wp,np,ccl',
31
- 'blockName': 'callback',
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['total']
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({'pageIndex': page})
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['list'])
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['index'] = big_df['index'] + 1
48
- big_df.rename(columns={
49
- 'index': "序号",
50
- 'np': "卖盘",
51
- 'h': "最新价",
52
- 'dm': "代码",
53
- 'zsjd': "-",
54
- 'l': "最低",
55
- 'ccl': "持仓量",
56
- 'o': "今开",
57
- 'p': "最高",
58
- 'sc': "-",
59
- 'vol': "成交量",
60
- 'name': "名称",
61
- 'wp': "买盘",
62
- 'zde': "涨跌额",
63
- 'zdf': "涨跌幅",
64
- 'zjsj': "昨结"
65
- }, inplace=True)
66
- big_df = big_df[[
67
- "序号",
68
- "代码",
69
- "名称",
70
- "最新价",
71
- "涨跌额",
72
- "涨跌幅",
73
- "今开",
74
- "最高",
75
- "最低",
76
- "昨结",
77
- "成交量",
78
- "买盘",
79
- "卖盘",
80
- "持仓量",
81
- ]]
82
- big_df['最新价'] = pd.to_numeric(big_df['最新价'], errors="coerce")
83
- big_df['涨跌额'] = pd.to_numeric(big_df['涨跌额'], errors="coerce")
84
- big_df['涨跌幅'] = pd.to_numeric(big_df['涨跌幅'], errors="coerce")
85
- big_df['今开'] = pd.to_numeric(big_df['今开'], errors="coerce")
86
- big_df['最高'] = pd.to_numeric(big_df['最高'], errors="coerce")
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")
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__ == '__main__':
101
+ if __name__ == "__main__":
97
102
  futures_global_em_df = futures_global_em()
98
103
  print(futures_global_em_df)
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2023/8/8 20:58
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: akshare
3
- Version: 1.15.34
3
+ Version: 1.15.36
4
4
  Summary: AKShare is an elegant and simple financial data interface library for Python, built for human beings!
5
5
  Home-page: https://github.com/akfamily/akshare
6
6
  Author: AKFamily
@@ -1,4 +1,4 @@
1
- akshare/__init__.py,sha256=TIvsy-58dhzMEmUrg3Fiip7I8pzQehul6K5Ruq6Ho9M,184396
1
+ akshare/__init__.py,sha256=QIcsNfNwGUb5rAjWaBaqnq6cu9bZd9FoKoxM4gXRDps,184493
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
@@ -105,14 +105,14 @@ akshare/fund/fund_xq.py,sha256=AxMZB-940bNY7-BatVLZiseHNxiWA17hQzTfuxGibPU,11306
105
105
  akshare/futures/__init__.py,sha256=RMTf1bT5EOE3ttWpn3hGu1LtUmsVxDoa0W7W0gXHOy8,81
106
106
  akshare/futures/cons.py,sha256=zD2uRQK3v-mywcDZfL28sDdRl6WIeWthHTfu8nrcQAo,16252
107
107
  akshare/futures/cot.py,sha256=Kkza2slS7JQpXndKrQEEykzIjZIT3vhvtZHVJ7P1yac,58573
108
- akshare/futures/futures_basis.py,sha256=ixaucu9loaPUwa2BOhRek0bI6VhdXY_ScyQ2EOZEPBA,13884
108
+ akshare/futures/futures_basis.py,sha256=I5PSlZRq1zE9lPDvunQ0bLutX8FjfYSadXWCVX9lIZ0,14539
109
109
  akshare/futures/futures_comex_em.py,sha256=V-mkKQkH5N8PyaZWKdyggb2lTnY8DDDxiUPt-1leQu0,3171
110
110
  akshare/futures/futures_comm_ctp.py,sha256=V8TEKO0R0i6LfE8DDFqrMA3JGwNlpmaQCvvMugKZ1I8,1004
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=E1zx4VswHra2Gh30wKgWuHRO36tsTvKYfjC0dOMTBPY,25281
114
114
  akshare/futures/futures_foreign.py,sha256=oSIoAg5oy-CIlPWHkQffcvZGu02Y2GWOrt-6aPA53Xg,2059
115
- akshare/futures/futures_hf_em.py,sha256=OEUltaq1LKabl9eTQoNxswnl1BLKpB27eiIHwbu_Rh4,3178
115
+ akshare/futures/futures_hf_em.py,sha256=jne-wUYr2QTUkDq3qAxYKE0Hm90L3H8qUDu3JavKiUg,3338
116
116
  akshare/futures/futures_hq_sina.py,sha256=eK1gEan4DPvpYmln8-tNnzh_J_733s95DBr--NqNYVA,9576
117
117
  akshare/futures/futures_index_ccidx.py,sha256=9Rhk3ps-H69tU-NIV0W2NdLFUDTSUx0bwtePA6gLMZA,4566
118
118
  akshare/futures/futures_international.py,sha256=EE_JTjQKekx8_FU8M12wHSd1DSlfMXYFiBJ6_wmThfc,6946
@@ -131,7 +131,7 @@ akshare/futures/futures_zh_sina.py,sha256=NMzqFbLkrUaeO1AouZUFqgekYBAm7j5ew2LTlr
131
131
  akshare/futures/inventory_data.py,sha256=m1DCzClDudj4qQLjgl5i6Lbazu0wIm9R3RerHCPcp38,4097
132
132
  akshare/futures/receipt.py,sha256=CGk0HKSJLeWSahkXmep8LVceAbN3wooTjMqGlQkegAY,22054
133
133
  akshare/futures/requests_fun.py,sha256=s31tnP2qUwEux43RX_t3K1uToJiSQ7xHYYQ_0bp16O0,2832
134
- akshare/futures/symbol_var.py,sha256=UQMHo9nA0a3-qtx0iGS9H5wGAdLywUU2ibcbV33ufqY,5526
134
+ akshare/futures/symbol_var.py,sha256=HnKKQ8waVW6sjlqh4F9vsloKY1NVs2s_-M4DB5hb7cA,5589
135
135
  akshare/futures_derivative/__init__.py,sha256=COFyP01gIUhWs4EBr6hwL73B7IWePIzg7vP7oEY3G3I,82
136
136
  akshare/futures_derivative/cons.py,sha256=Zdrfsln3ie3FXxu2YfMF1AxHSB0wAhQS5bM-nygJ_aM,5927
137
137
  akshare/futures_derivative/futures_contract_info_cffex.py,sha256=f1n8_2G67sscHUatDP1ZqxwrKXiqPwSFMCa4pk8Colo,3248
@@ -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.15.34.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
387
- akshare-1.15.34.dist-info/METADATA,sha256=l0ykGsvmO36Z0SFp4KJzemkml4Vk40I0A7fYrYTwXbc,13423
388
- akshare-1.15.34.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
389
- akshare-1.15.34.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
390
- akshare-1.15.34.dist-info/RECORD,,
386
+ akshare-1.15.36.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
387
+ akshare-1.15.36.dist-info/METADATA,sha256=RyY4pEUMw6iaThaQk8CsRz1L6MRNm3blsNJYmA3VRyw,13423
388
+ akshare-1.15.36.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
389
+ akshare-1.15.36.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
390
+ akshare-1.15.36.dist-info/RECORD,,