akshare 1.15.86__py3-none-any.whl → 1.15.88__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
@@ -2996,9 +2996,11 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
2996
2996
  1.15.84 fix: fix option_dce_daily interface
2997
2997
  1.15.85 fix: fix stock_gddh_em interface
2998
2998
  1.15.86 fix: fix stock_zdhtmx_em interface
2999
+ 1.15.87 fix: fix futures_index_ccidx interface
3000
+ 1.15.88 fix: fix stock_zh_a_spot_em interface
2999
3001
  """
3000
3002
 
3001
- __version__ = "1.15.86"
3003
+ __version__ = "1.15.88"
3002
3004
  __author__ = "AKFamily"
3003
3005
 
3004
3006
  import sys
@@ -1,12 +1,12 @@
1
1
  # -*- coding:utf-8 -*-
2
2
  # !/usr/bin/env python
3
3
  """
4
- Date: 2023/11/9 14:00
4
+ Date: 2025/2/12 16:00
5
5
  Desc: 中证商品指数
6
6
  http://www.ccidx.com/
7
7
  """
8
8
 
9
- from io import BytesIO
9
+ import json
10
10
 
11
11
  import pandas as pd
12
12
  import requests
@@ -25,31 +25,28 @@ def futures_index_ccidx(symbol: str = "中证商品期货指数") -> pd.DataFram
25
25
  "中证商品期货指数": "100001.CCI",
26
26
  "中证商品期货价格指数": "000001.CCI",
27
27
  }
28
- url = "http://www.ccidx.com/front/ajax_downZSHQ.do"
29
- params = {"indexCode": futures_index_map[symbol]}
28
+ url = "http://www.ccidx.com/CCI-ZZZS/index/getDateLine"
29
+ params = {"indexId": futures_index_map[symbol]}
30
30
  r = requests.get(url, params=params)
31
- temp_df = pd.read_excel(BytesIO(r.content), header=1, engine="openpyxl")
32
- temp_df.columns = [
33
- "日期",
34
- "指数代码",
35
- "指数中文全称",
36
- "指数中文简称",
37
- "指数英文全称",
38
- "指数英文简称",
39
- "开盘",
40
- "最高",
41
- "最低",
42
- "收盘",
43
- "结算",
44
- "涨跌",
45
- "涨跌幅",
46
- ]
31
+ data_json = r.json()
32
+ temp_df = pd.DataFrame(
33
+ [json.loads(item) for item in data_json["data"]["dateLineJson"]]
34
+ )
35
+ temp_df.rename(
36
+ columns={
37
+ "tradeDate": "日期",
38
+ "indexId": "指数代码",
39
+ "closingPrice": "收盘点位",
40
+ "settlePrice": "结算点位",
41
+ "dailyIncreaseAndDecrease": "涨跌",
42
+ "dailyIncreaseAndDecreasePercentage": "涨跌幅",
43
+ },
44
+ inplace=True,
45
+ )
46
+
47
47
  temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
48
- temp_df["开盘"] = pd.to_numeric(temp_df["开盘"], errors="coerce")
49
- temp_df["最高"] = pd.to_numeric(temp_df["最高"], errors="coerce")
50
- temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce")
51
- temp_df["收盘"] = pd.to_numeric(temp_df["收盘"], errors="coerce")
52
- temp_df["结算"] = pd.to_numeric(temp_df["结算"], errors="coerce")
48
+ temp_df["收盘点位"] = pd.to_numeric(temp_df["收盘点位"], errors="coerce")
49
+ temp_df["结算点位"] = pd.to_numeric(temp_df["结算点位"], errors="coerce")
53
50
  temp_df["涨跌"] = pd.to_numeric(temp_df["涨跌"], errors="coerce")
54
51
  temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"], errors="coerce")
55
52
  temp_df.sort_values(by=["日期"], inplace=True)
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2024/7/13 18:00
4
+ Date: 2025/2/15 21:00
5
5
  Desc: 东方财富网-行情首页-沪深京 A 股
6
6
  https://quote.eastmoney.com/
7
7
  """
8
8
 
9
9
  from functools import lru_cache
10
-
10
+ import math
11
11
  import pandas as pd
12
12
  import requests
13
+ from akshare.utils.tqdm import get_tqdm
13
14
 
14
15
 
15
16
  def stock_zh_a_spot_em() -> pd.DataFrame:
@@ -22,7 +23,7 @@ def stock_zh_a_spot_em() -> pd.DataFrame:
22
23
  url = "https://82.push2.eastmoney.com/api/qt/clist/get"
23
24
  params = {
24
25
  "pn": "1",
25
- "pz": "50000",
26
+ "pz": "200",
26
27
  "po": "1",
27
28
  "np": "1",
28
29
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
@@ -34,11 +35,22 @@ def stock_zh_a_spot_em() -> pd.DataFrame:
34
35
  "f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
35
36
  "_": "1623833739532",
36
37
  }
37
- r = requests.get(url, timeout=15, params=params)
38
+ r = requests.get(url, params=params, timeout=15)
38
39
  data_json = r.json()
39
- if not data_json["data"]["diff"]:
40
- return pd.DataFrame()
41
- temp_df = pd.DataFrame(data_json["data"]["diff"])
40
+ total_page = math.ceil(data_json["data"]["total"] / 200)
41
+ temp_list = []
42
+ tqdm = get_tqdm()
43
+ for page in tqdm(range(1, total_page + 1), leave=False):
44
+ params.update(
45
+ {
46
+ "pn": page,
47
+ }
48
+ )
49
+ r = requests.get(url, params=params, timeout=15)
50
+ data_json = r.json()
51
+ inner_temp_df = pd.DataFrame(data_json["data"]["diff"])
52
+ temp_list.append(inner_temp_df)
53
+ temp_df = pd.concat(temp_list, ignore_index=True)
42
54
  temp_df.columns = [
43
55
  "_",
44
56
  "最新价",
@@ -950,7 +962,7 @@ def code_id_map_em() -> dict:
950
962
  url = "https://80.push2.eastmoney.com/api/qt/clist/get"
951
963
  params = {
952
964
  "pn": "1",
953
- "pz": "50000",
965
+ "pz": "200",
954
966
  "po": "1",
955
967
  "np": "1",
956
968
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
@@ -963,15 +975,27 @@ def code_id_map_em() -> dict:
963
975
  }
964
976
  r = requests.get(url, timeout=15, params=params)
965
977
  data_json = r.json()
966
- if not data_json["data"]["diff"]:
967
- return dict()
968
- temp_df = pd.DataFrame(data_json["data"]["diff"])
978
+ total_page = math.ceil(data_json["data"]["total"] / 200)
979
+ temp_list = []
980
+ tqdm = get_tqdm()
981
+ for page in tqdm(range(1, total_page + 1), leave=False):
982
+ params.update(
983
+ {
984
+ "pn": page,
985
+ }
986
+ )
987
+ r = requests.get(url, params=params, timeout=15)
988
+ data_json = r.json()
989
+ inner_temp_df = pd.DataFrame(data_json["data"]["diff"])
990
+ temp_list.append(inner_temp_df)
991
+ temp_df = pd.concat(temp_list, ignore_index=True)
969
992
  temp_df["market_id"] = 1
970
993
  temp_df.columns = ["sh_code", "sh_id"]
971
994
  code_id_dict = dict(zip(temp_df["sh_code"], temp_df["sh_id"]))
995
+
972
996
  params = {
973
997
  "pn": "1",
974
- "pz": "50000",
998
+ "pz": "200",
975
999
  "po": "1",
976
1000
  "np": "1",
977
1001
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
@@ -984,14 +1008,26 @@ def code_id_map_em() -> dict:
984
1008
  }
985
1009
  r = requests.get(url, timeout=15, params=params)
986
1010
  data_json = r.json()
987
- if not data_json["data"]["diff"]:
988
- return dict()
989
- temp_df_sz = pd.DataFrame(data_json["data"]["diff"])
1011
+ total_page = math.ceil(data_json["data"]["total"] / 200)
1012
+ temp_list = []
1013
+ tqdm = get_tqdm()
1014
+ for page in tqdm(range(1, total_page + 1), leave=False):
1015
+ params.update(
1016
+ {
1017
+ "pn": page,
1018
+ }
1019
+ )
1020
+ r = requests.get(url, params=params, timeout=15)
1021
+ data_json = r.json()
1022
+ inner_temp_df = pd.DataFrame(data_json["data"]["diff"])
1023
+ temp_list.append(inner_temp_df)
1024
+ temp_df_sz = pd.concat(temp_list, ignore_index=True)
990
1025
  temp_df_sz["sz_id"] = 0
991
1026
  code_id_dict.update(dict(zip(temp_df_sz["f12"], temp_df_sz["sz_id"])))
1027
+
992
1028
  params = {
993
1029
  "pn": "1",
994
- "pz": "50000",
1030
+ "pz": "200",
995
1031
  "po": "1",
996
1032
  "np": "1",
997
1033
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
@@ -1004,9 +1040,20 @@ def code_id_map_em() -> dict:
1004
1040
  }
1005
1041
  r = requests.get(url, timeout=15, params=params)
1006
1042
  data_json = r.json()
1007
- if not data_json["data"]["diff"]:
1008
- return dict()
1009
- temp_df_sz = pd.DataFrame(data_json["data"]["diff"])
1043
+ total_page = math.ceil(data_json["data"]["total"] / 200)
1044
+ temp_list = []
1045
+ tqdm = get_tqdm()
1046
+ for page in tqdm(range(1, total_page + 1), leave=False):
1047
+ params.update(
1048
+ {
1049
+ "pn": page,
1050
+ }
1051
+ )
1052
+ r = requests.get(url, params=params, timeout=15)
1053
+ data_json = r.json()
1054
+ inner_temp_df = pd.DataFrame(data_json["data"]["diff"])
1055
+ temp_list.append(inner_temp_df)
1056
+ temp_df_sz = pd.concat(temp_list, ignore_index=True)
1010
1057
  temp_df_sz["bj_id"] = 0
1011
1058
  code_id_dict.update(dict(zip(temp_df_sz["f12"], temp_df_sz["bj_id"])))
1012
1059
  return code_id_dict
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: akshare
3
- Version: 1.15.86
3
+ Version: 1.15.88
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=fW5bZMjmcN526kpsUiiaSP97n1auQPoQ0yaNTexZUZs,186883
1
+ akshare/__init__.py,sha256=gEpUq0f70kCddphXfN8QdsdQ6egav-PGL6ViQngJquw,186976
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_foreign.py,sha256=oSIoAg5oy-CIlPWHkQffcvZGu02Y2GWOrt-6aP
115
115
  akshare/futures/futures_hf_em.py,sha256=jne-wUYr2QTUkDq3qAxYKE0Hm90L3H8qUDu3JavKiUg,3338
116
116
  akshare/futures/futures_hist_em.py,sha256=23poFID_GE2mWf9NnkJBE3N7FgxNYiqrbTKO0VciS_A,6441
117
117
  akshare/futures/futures_hq_sina.py,sha256=eK1gEan4DPvpYmln8-tNnzh_J_733s95DBr--NqNYVA,9576
118
- akshare/futures/futures_index_ccidx.py,sha256=Ni5GICleqcHrmLatOE_Bs4i1DS3bn0lEm_RyrjlucB0,4581
118
+ akshare/futures/futures_index_ccidx.py,sha256=_kgWioCOpFNn8WUcL5qKHGb3rUHzrbrx2AszprKpBh4,4460
119
119
  akshare/futures/futures_inventory_99.py,sha256=xdX8GSCEcRWYnbw0XS22rcblXOvlzUvfUltv7oyRh3Y,2990
120
120
  akshare/futures/futures_inventory_em.py,sha256=C5nt4F51WB-oc8o3GrMvEGo0SO2mIq_H1vHVl42vzT0,2340
121
121
  akshare/futures/futures_news_shmet.py,sha256=1epZ3MwDc-T2n1ie4SSDfvUaBiMpSL0Q_xb2VoZ_llU,2465
@@ -311,7 +311,7 @@ akshare/stock_feature/stock_gdhs.py,sha256=Z6ZMy1A03BqMu9TghcIu2Sd_wwEtpIH7qawHu
311
311
  akshare/stock_feature/stock_gdzjc_em.py,sha256=SHJH5iS3_NhvjTqRXF0vPooZl0s_ASeyZmNCC50ZYqs,4426
312
312
  akshare/stock_feature/stock_gpzy_em.py,sha256=FgyjVgdoxrtMM7WwxdQJxK0mYGJklIHaT9KmMCFmEPM,17869
313
313
  akshare/stock_feature/stock_gxl_lg.py,sha256=I8TpDEpFzadZSSyZisyIk6163mJlRxup91dmlBH4t4U,2641
314
- akshare/stock_feature/stock_hist_em.py,sha256=H8bbC0LJBvDTRnrhZvFtrMM8Y6H4LZk-C0KIPar1aQs,69201
314
+ akshare/stock_feature/stock_hist_em.py,sha256=ibI1uQvI-UwkQ9dvSWLMmGdOLbr9u_e083SUxbV20_8,70766
315
315
  akshare/stock_feature/stock_hist_tx.py,sha256=WpLsbkG2didSx7lYNkSbTWNTrLhUKbcopfD18WO2Rlc,3397
316
316
  akshare/stock_feature/stock_hk_valuation_baidu.py,sha256=_sErx4UhNsSXJgXyPfrL0aPxkW53Mg1zH9gEKoziaCA,1968
317
317
  akshare/stock_feature/stock_hot_xq.py,sha256=NmoH4x-0hiDztj-YwzMFVIyOICQ2wUUBbhjt91q-tq4,9112
@@ -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=j1MGYbZI2if2j_LY1S4FLsf4qfq4NwVqD5wmRlv5Log,832
383
- akshare-1.15.86.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
384
- akshare-1.15.86.dist-info/METADATA,sha256=--Ircg6PIKICrg10sE11cIplNQZkcZe2Mc86LOI650A,13679
385
- akshare-1.15.86.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
386
- akshare-1.15.86.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
387
- akshare-1.15.86.dist-info/RECORD,,
383
+ akshare-1.15.88.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
384
+ akshare-1.15.88.dist-info/METADATA,sha256=lYsezcOpQVLyZNgUWutwHRctWoEeUAUUXrQA2CUEtrM,13679
385
+ akshare-1.15.88.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
386
+ akshare-1.15.88.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
387
+ akshare-1.15.88.dist-info/RECORD,,