akshare 1.17.71__py3-none-any.whl → 1.17.72__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
@@ -3178,9 +3178,10 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
3178
3178
  1.17.69 fix: fix fund_etf_hist_sina interface
3179
3179
  1.17.70 fix: fix macro_stock_finance interface
3180
3180
  1.17.71 fix: fix futures_inventory_99 interface
3181
+ 1.17.72 fix: fix futures_warehouse_receipt_dce interface
3181
3182
  """
3182
3183
 
3183
- __version__ = "1.17.71"
3184
+ __version__ = "1.17.72"
3184
3185
  __author__ = "AKFamily"
3185
3186
 
3186
3187
  import sys
@@ -4868,7 +4869,7 @@ futures-warehouse-receipt
4868
4869
  """
4869
4870
  from akshare.futures.futures_warehouse_receipt import (
4870
4871
  futures_czce_warehouse_receipt,
4871
- futures_dce_warehouse_receipt,
4872
+ futures_warehouse_receipt_dce,
4872
4873
  futures_shfe_warehouse_receipt,
4873
4874
  futures_gfex_warehouse_receipt,
4874
4875
  )
@@ -524,7 +524,7 @@ def get_shfe_daily(date: str = "20220415") -> pd.DataFrame:
524
524
  return df
525
525
 
526
526
 
527
- def get_dce_daily(date: str = "20220308") -> pd.DataFrame:
527
+ def get_dce_daily(date: str = "20251027") -> pd.DataFrame:
528
528
  """
529
529
  大连商品交易所日交易数据
530
530
  http://www.dce.com.cn/dalianshangpin/xqsj/tjsj26/rtj/rxq/index.html
@@ -537,41 +537,42 @@ def get_dce_daily(date: str = "20220308") -> pd.DataFrame:
537
537
  if day.strftime("%Y%m%d") not in calendar:
538
538
  # warnings.warn("%s非交易日" % day.strftime("%Y%m%d"))
539
539
  return pd.DataFrame()
540
- url = "http://portal.dce.com.cn/publicweb/quotesdata/exportDayQuotesChData.html"
541
- headers = {
542
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,"
543
- "application/signed-exchange;v=b3;q=0.9",
544
- "Accept-Encoding": "gzip, deflate",
545
- "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
546
- "Cache-Control": "no-cache",
547
- "Connection": "keep-alive",
548
- "Content-Length": "86",
549
- "Content-Type": "application/x-www-form-urlencoded",
550
- "Host": "www.dce.com.cn",
551
- "Origin": "http://portal.dce.com.cn",
552
- "Pragma": "no-cache",
553
- "Referer": "http://portal.dce.com.cn/publicweb/quotesdata/dayQuotesCh.html",
554
- "Upgrade-Insecure-Requests": "1",
555
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
556
- "Chrome/84.0.4147.105 Safari/537.36",
540
+ url = "http://www.dce.com.cn/dcereport/publicweb/dailystat/dayQuotes"
541
+ payload = {
542
+ "contractId": "",
543
+ "lang": "zh",
544
+ "optionSeries": "",
545
+ "statisticsType": "0",
546
+ "tradeDate": date,
547
+ "tradeType": "1",
548
+ "varietyId": "all",
557
549
  }
558
- params = {
559
- "dayQuotes.variety": "all",
560
- "dayQuotes.trade_type": "0",
561
- "year": date[:4],
562
- "month": str(int(date[4:6]) - 1),
563
- "day": date[6:],
564
- "exportFlag": "excel",
565
- }
566
- r = requests.post(url, data=params, headers=headers)
567
- data_df = pd.read_excel(BytesIO(r.content), header=1)
568
- data_df = data_df[~data_df["商品名称"].str.contains("小计")]
569
- data_df = data_df[~data_df["商品名称"].str.contains("总计")]
570
- data_df["variety"] = data_df["商品名称"].map(lambda x: cons.DCE_MAP[x])
571
- data_df["symbol"] = data_df["合约名称"]
572
- del data_df["商品名称"]
573
- del data_df["合约名称"]
574
- data_df.columns = [
550
+ r = requests.post(url, json=payload)
551
+ data_json = r.json()
552
+ temp_df = pd.DataFrame(data_json['data'])
553
+ temp_df.rename(columns={
554
+ "variety": "品种名称",
555
+ "contractId": "合约",
556
+ "open": "开盘价",
557
+ "high": "最高价",
558
+ "low": "最低价",
559
+ "close": "收盘价",
560
+ "lastClear": "前结算价",
561
+ "clearPrice": "结算价",
562
+ "diff": "涨跌",
563
+ "diff1": "涨跌1",
564
+ "volumn": "成交量",
565
+ "openInterest": "持仓量",
566
+ "diffI": "持仓量变化",
567
+ "turnover": "成交额",
568
+ }, inplace=True)
569
+ temp_df = temp_df[~temp_df["品种名称"].str.contains("小计")]
570
+ temp_df = temp_df[~temp_df["品种名称"].str.contains("总计")]
571
+ temp_df["variety"] = temp_df["品种名称"].map(lambda x: cons.DCE_MAP[x])
572
+ temp_df["symbol"] = temp_df["合约"]
573
+ del temp_df["品种名称"]
574
+ del temp_df["合约"]
575
+ temp_df.columns = [
575
576
  "open",
576
577
  "high",
577
578
  "low",
@@ -580,15 +581,24 @@ def get_dce_daily(date: str = "20220308") -> pd.DataFrame:
580
581
  "settle",
581
582
  "_",
582
583
  "_",
584
+ "_",
583
585
  "volume",
584
586
  "open_interest",
585
587
  "_",
586
588
  "turnover",
589
+ "_",
590
+ "_",
591
+ "_",
592
+ "_",
593
+ "_",
594
+ "_",
595
+ "_",
596
+ "_",
587
597
  "variety",
588
598
  "symbol",
589
599
  ]
590
- data_df["date"] = date
591
- data_df = data_df[
600
+ temp_df["date"] = date
601
+ temp_df = temp_df[
592
602
  [
593
603
  "symbol",
594
604
  "date",
@@ -604,8 +614,7 @@ def get_dce_daily(date: str = "20220308") -> pd.DataFrame:
604
614
  "variety",
605
615
  ]
606
616
  ]
607
- data_df = data_df.map(lambda x: x.replace(",", ""))
608
- data_df = data_df.astype(
617
+ temp_df = temp_df.astype(
609
618
  {
610
619
  "open": "float",
611
620
  "high": "float",
@@ -618,8 +627,8 @@ def get_dce_daily(date: str = "20220308") -> pd.DataFrame:
618
627
  "pre_settle": "float",
619
628
  }
620
629
  )
621
- data_df.reset_index(inplace=True, drop=True)
622
- return data_df
630
+ temp_df.reset_index(inplace=True, drop=True)
631
+ return temp_df
623
632
 
624
633
 
625
634
  def get_futures_daily(
@@ -32,7 +32,7 @@ def futures_czce_warehouse_receipt(date: str = "20200702") -> dict:
32
32
  url = f"http://www.czce.com.cn/cn/DFSStaticFiles/Future/{date[:4]}/{date}/FutureDataWhsheet.xls"
33
33
  headers = {
34
34
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
35
- "Chrome/83.0.4103.116 Safari/537.36"
35
+ "Chrome/83.0.4103.116 Safari/537.36"
36
36
  }
37
37
  r = requests.get(url, verify=False, headers=headers)
38
38
  temp_df = pd.read_excel(BytesIO(r.content))
@@ -40,7 +40,7 @@ def futures_czce_warehouse_receipt(date: str = "20200702") -> dict:
40
40
  index_list.append(len(temp_df))
41
41
  big_dict = {}
42
42
  for inner_index in range(len(index_list) - 1):
43
- inner_df = temp_df[index_list[inner_index] : index_list[inner_index + 1]]
43
+ inner_df = temp_df[index_list[inner_index]: index_list[inner_index + 1]]
44
44
  inner_key = re.findall(r"[a-zA-Z]+", inner_df.iloc[0, 0])[0]
45
45
  inner_df = inner_df.iloc[1:, :]
46
46
  inner_df.dropna(axis=0, how="all", inplace=True)
@@ -52,7 +52,7 @@ def futures_czce_warehouse_receipt(date: str = "20200702") -> dict:
52
52
  return big_dict
53
53
 
54
54
 
55
- def futures_dce_warehouse_receipt(date: str = "20250929") -> dict:
55
+ def futures_warehouse_receipt_dce(date: str = "20251027") -> pd.DataFrame:
56
56
  """
57
57
  大连商品交易所-行情数据-统计数据-日统计-仓单日报
58
58
  http://www.dce.com.cn/dce/channel/list/187.html
@@ -61,35 +61,33 @@ def futures_dce_warehouse_receipt(date: str = "20250929") -> dict:
61
61
  :return: 指定日期的仓单日报数据
62
62
  :rtype: dict
63
63
  """
64
- url = "http://portal.dce.com.cn/publicweb/quotesdata/wbillWeeklyQuotes.html"
65
- headers = {
66
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
67
- "Chrome/83.0.4103.116 Safari/537.36"
68
- }
69
- params = {
64
+ url = "http://www.dce.com.cn/dcereport/publicweb/dailystat/wbillWeeklyQuotes"
65
+ payload = {
70
66
  "tradeDate": date,
71
67
  "varietyId": "all",
72
68
  }
73
- r = requests.post(url, params=params, headers=headers)
74
- temp_df = pd.read_html(StringIO(r.text))[0]
75
- index_list = temp_df[temp_df.iloc[:, 0].str.contains("小计") == 1].index.to_list()
76
- index_list.insert(0, 0)
77
- big_dict = {}
78
- for inner_index in range(len(index_list) - 1):
79
- if inner_index == 0:
80
- temp_index = 0
81
- else:
82
- temp_index = index_list[inner_index] + 1
83
- inner_df = temp_df[temp_index : index_list[inner_index + 1] + 1].copy()
84
- inner_key = inner_df.iloc[0, 0]
85
- inner_df.reset_index(inplace=True, drop=True)
86
- inner_df.ffill(inplace=True)
87
- # 填补 20240401 中开头没有品种的情况
88
- if date == "20240401":
89
- inner_df["品种"] = inner_df["品种"].fillna("玉米")
90
- inner_key = inner_df.iloc[0, 0]
91
- big_dict[inner_key] = inner_df
92
- return big_dict
69
+ r = requests.post(url, json=payload)
70
+ data_json = r.json()
71
+ temp_df = pd.DataFrame(data_json['data']['entityList'])
72
+ temp_df.rename(columns={
73
+ "variety": "品种名称",
74
+ "whAbbr": "仓库/分库",
75
+ "deliveryAbbr": "可选提货地点/分库-数量",
76
+ "lastWbillQty": "昨日仓单量(手)",
77
+ "wbillQty": "今日仓单量(手)",
78
+ "diff": "增减(手)",
79
+ "varietyOrder": "品种代码",
80
+ }, inplace=True)
81
+ temp_df = temp_df[[
82
+ "品种代码",
83
+ "品种名称",
84
+ "仓库/分库",
85
+ "可选提货地点/分库-数量",
86
+ "昨日仓单量(手)",
87
+ "今日仓单量(手)",
88
+ "增减(手)",
89
+ ]]
90
+ return temp_df
93
91
 
94
92
 
95
93
  def futures_shfe_warehouse_receipt(date: str = "20200702") -> dict:
@@ -103,7 +101,7 @@ def futures_shfe_warehouse_receipt(date: str = "20200702") -> dict:
103
101
  """
104
102
  headers = {
105
103
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
106
- "Chrome/83.0.4103.116 Safari/537.36"
104
+ "Chrome/83.0.4103.116 Safari/537.36"
107
105
  }
108
106
  url = f"https://www.shfe.com.cn/data/tradedata/future/dailydata/{date}dailystock.dat"
109
107
  if date >= "20140519":
@@ -124,7 +122,7 @@ def futures_shfe_warehouse_receipt(date: str = "20200702") -> dict:
124
122
  temp_df = pd.read_html(StringIO(r.text))[0]
125
123
  index_list = temp_df[
126
124
  temp_df.iloc[:, 3].str.contains("单位:") == 1
127
- ].index.to_list()
125
+ ].index.to_list()
128
126
  big_dict = {}
129
127
  for inner_index in range(len(index_list)):
130
128
  temp_index_start = index_list[inner_index]
@@ -157,7 +155,7 @@ def futures_gfex_warehouse_receipt(date: str = "20240122") -> dict:
157
155
  url = "http://www.gfex.com.cn/u/interfacesWebTdWbillWeeklyQuotes/loadList"
158
156
  headers = {
159
157
  "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
160
- "Chrome/83.0.4103.116 Safari/537.36"
158
+ "Chrome/83.0.4103.116 Safari/537.36"
161
159
  }
162
160
  payload = {"gen_date": date}
163
161
  r = requests.post(url=url, data=payload, headers=headers)
@@ -220,8 +218,8 @@ if __name__ == "__main__":
220
218
  czce_warehouse_receipt_df = futures_czce_warehouse_receipt(date="20151019")
221
219
  print(czce_warehouse_receipt_df)
222
220
 
223
- futures_dce_warehouse_receipt_df = futures_dce_warehouse_receipt(date="20251014")
224
- print(futures_dce_warehouse_receipt_df)
221
+ futures_warehouse_receipt_dce_df = futures_warehouse_receipt_dce(date="20251014")
222
+ print(futures_warehouse_receipt_dce_df)
225
223
 
226
224
  futures_shfe_warehouse_receipt_df = futures_shfe_warehouse_receipt(date="20200702")
227
225
  print(futures_shfe_warehouse_receipt_df)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: akshare
3
- Version: 1.17.71
3
+ Version: 1.17.72
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=TVaTAi74ngc9bFz8f9sshS2fvHdLnrMI2VduS6TtC78,199531
1
+ akshare/__init__.py,sha256=n4zAYkZ4DTiFpgb4lSOMkJVSClS_xkeNi9Wbvh6vKNc,199588
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
@@ -115,7 +115,7 @@ akshare/futures/futures_comex_em.py,sha256=NPwOCD6lZUDL4wlGxvbmmJIFkQlW427ERO0vT
115
115
  akshare/futures/futures_comm_ctp.py,sha256=IyVRCUvhLTFzmcUVvlIaYZ1e38ll7AF8ExhgtXKuzrI,1003
116
116
  akshare/futures/futures_comm_qihuo.py,sha256=uQfabZ63qME8sTaxUbIUVQBVi8yTaPPDhD7voR9PEx0,10504
117
117
  akshare/futures/futures_contract_detail.py,sha256=Glm1x72WBwF4G-f_ZYzHsbNhlQ6Ti1HeF0Rzhx-pfFg,1190
118
- akshare/futures/futures_daily_bar.py,sha256=QWeHNxFMtwY2IGEK6ZlPJ9wax4Jl8pcGinqtkIVj0KQ,25366
118
+ akshare/futures/futures_daily_bar.py,sha256=gbBW9SphkOrDMzrnetiXA-224ahqOrgc0jVmk8Ay4aA,25057
119
119
  akshare/futures/futures_foreign.py,sha256=2cbMA-eug_jriDFwKZWmA_TbPW2GQAjscpZHBrs287E,2131
120
120
  akshare/futures/futures_hf_em.py,sha256=juiJauO7T6YTHXIS--ZDW-Idk73KMOrXgRBi1xEiBqA,8195
121
121
  akshare/futures/futures_hist_em.py,sha256=TuHdpcfVxdqoHzg5-JwppLUQgwuaz_LG2UZBlgf73i4,6509
@@ -131,7 +131,7 @@ akshare/futures/futures_settlement_price_sgx.py,sha256=SJxAGNuNxNEGDk7EF2odRPrWK
131
131
  akshare/futures/futures_spot_stock_em.py,sha256=43CPkAouDu691M6aCMdO1SGKglTak2aba2Np7ftkAdg,3523
132
132
  akshare/futures/futures_stock_js.py,sha256=sAao7ZcqBovdEo4wrVt2K6kXK2rf1_kT_StQdzhm9og,1635
133
133
  akshare/futures/futures_to_spot.py,sha256=fDsnmwUDUWQSF11MBvGEKn_c69fJmaGnRigWzvQMaZc,12898
134
- akshare/futures/futures_warehouse_receipt.py,sha256=koiyOO6HmpgwPapyVyFHHK_yJeU7oAzfJArVmo19_hk,9047
134
+ akshare/futures/futures_warehouse_receipt.py,sha256=XuCPGumcQIBOJf5XzDsU5NbViXqf0Erqv9u-3c36VFc,8789
135
135
  akshare/futures/futures_zh_sina.py,sha256=wFFiPdud7a6HUHxohlQmN0FsnrvsadTYhbq0cZT4dpo,26191
136
136
  akshare/futures/receipt.py,sha256=6KFgO6BJcQ0S5ZlRIQfPwXOuMLuncn7pcFCPOp1QJGI,23588
137
137
  akshare/futures/requests_fun.py,sha256=w4inzqYjrAiRx_E3oszbcJwrRJR3MKpm5Rkropdusoo,2893
@@ -399,10 +399,10 @@ akshare/utils/func.py,sha256=4cwmXFztU86yJNONJ40KJLvsIEQHBbct4iMm3zT2v30,2315
399
399
  akshare/utils/multi_decrypt.py,sha256=aWoL2iEPeuXHJg8-n7OtMKixLnIhfzepACgxfrfmQB4,1657
400
400
  akshare/utils/token_process.py,sha256=nGtgnZGRprXJkhLXH8mcUH4TgIFwzsTOb0EaEPa0Euo,667
401
401
  akshare/utils/tqdm.py,sha256=MuPNwcswkOGjwWQOMWXi9ZvQ_RmW4obCWRj2i7HM7FE,847
402
- akshare-1.17.71.dist-info/licenses/LICENSE,sha256=s18q7gS2g1F9-Cnk5eqrJG4OGWSwSxVEMzIuT6HyYNY,1073
402
+ akshare-1.17.72.dist-info/licenses/LICENSE,sha256=s18q7gS2g1F9-Cnk5eqrJG4OGWSwSxVEMzIuT6HyYNY,1073
403
403
  tests/__init__.py,sha256=gNzhlO0UPjFq6Ieb38kaVIODXv4cTDByrdohAZnDYt4,82
404
404
  tests/test_func.py,sha256=j1MGYbZI2if2j_LY1S4FLsf4qfq4NwVqD5wmRlv5Log,832
405
- akshare-1.17.71.dist-info/METADATA,sha256=gvVGTjrecSSbxLsshOClDTWEyA-K3I07RIdwADEVH0U,12593
406
- akshare-1.17.71.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
407
- akshare-1.17.71.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
408
- akshare-1.17.71.dist-info/RECORD,,
405
+ akshare-1.17.72.dist-info/METADATA,sha256=zIoezhJiwM7AzUc4l4qHU7CCkgx4obt4XvGKWetehCg,12593
406
+ akshare-1.17.72.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
407
+ akshare-1.17.72.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
408
+ akshare-1.17.72.dist-info/RECORD,,