akshare 1.15.26__py3-none-any.whl → 1.15.28__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
@@ -2936,9 +2936,11 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
2936
2936
  1.15.24 fix: fix get_dce_daily interface
2937
2937
  1.15.25 fix: fix stock_news_main_cx interface
2938
2938
  1.15.26 fix: fix option_dce_daily interface
2939
+ 1.15.27 fix: fix stock_zh_index_spot_em interface
2940
+ 1.15.28 fix: fix stock_hk_valuation_baidu interface
2939
2941
  """
2940
2942
 
2941
- __version__ = "1.15.26"
2943
+ __version__ = "1.15.28"
2942
2944
  __author__ = "AKFamily"
2943
2945
 
2944
2946
  import sys
@@ -682,7 +682,7 @@ def get_futures_daily(
682
682
 
683
683
  if __name__ == "__main__":
684
684
  get_futures_daily_df = get_futures_daily(
685
- start_date="20240101", end_date="20240101", market="DCE"
685
+ start_date="20241118", end_date="20241118", market="DCE"
686
686
  )
687
687
  print(get_futures_daily_df)
688
688
 
@@ -125,15 +125,98 @@ def stock_zh_index_spot_sina() -> pd.DataFrame:
125
125
  return big_df
126
126
 
127
127
 
128
+ def __stock_zh_main_spot_em() -> pd.DataFrame:
129
+ """
130
+ 东方财富网-行情中心-沪深重要指数
131
+ https://quote.eastmoney.com/center/hszs.html
132
+ :return: 指数的实时行情数据
133
+ :rtype: pandas.DataFrame
134
+ """
135
+ url = "https://33.push2.eastmoney.com/api/qt/clist/get"
136
+ params = {
137
+ "pn": "1",
138
+ "pz": "5000",
139
+ "po": "1",
140
+ "np": "1",
141
+ "ut": "bd1d9ddb04089700cf9c27f6f7426281",
142
+ "fltt": "2",
143
+ "invt": "2",
144
+ "dect": "1",
145
+ "wbp2u": "|0|0|0|web",
146
+ "fid": "",
147
+ "fs": "b:MK0010",
148
+ "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,"
149
+ "f23,f24,f25,f26,f22,f11,f62,f128,f136,f115,f152",
150
+ "_": "1704327268532",
151
+ }
152
+ r = requests.get(url, params=params)
153
+ data_json = r.json()
154
+ temp_df = pd.DataFrame(data_json["data"]["diff"])
155
+ temp_df.reset_index(inplace=True)
156
+ temp_df["index"] = temp_df["index"] + 1
157
+ temp_df.rename(
158
+ columns={
159
+ "index": "序号",
160
+ "f2": "最新价",
161
+ "f3": "涨跌幅",
162
+ "f4": "涨跌额",
163
+ "f5": "成交量",
164
+ "f6": "成交额",
165
+ "f7": "振幅",
166
+ "f10": "量比",
167
+ "f12": "代码",
168
+ "f14": "名称",
169
+ "f15": "最高",
170
+ "f16": "最低",
171
+ "f17": "今开",
172
+ "f18": "昨收",
173
+ },
174
+ inplace=True,
175
+ )
176
+ temp_df = temp_df[
177
+ [
178
+ "序号",
179
+ "代码",
180
+ "名称",
181
+ "最新价",
182
+ "涨跌幅",
183
+ "涨跌额",
184
+ "成交量",
185
+ "成交额",
186
+ "振幅",
187
+ "最高",
188
+ "最低",
189
+ "今开",
190
+ "昨收",
191
+ "量比",
192
+ ]
193
+ ]
194
+ temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
195
+ temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"], errors="coerce")
196
+ temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"], errors="coerce")
197
+ temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
198
+ temp_df["成交额"] = pd.to_numeric(temp_df["成交额"], errors="coerce")
199
+ temp_df["振幅"] = pd.to_numeric(temp_df["振幅"], errors="coerce")
200
+ temp_df["最高"] = pd.to_numeric(temp_df["最高"], errors="coerce")
201
+ temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce")
202
+ temp_df["今开"] = pd.to_numeric(temp_df["今开"], errors="coerce")
203
+ temp_df["昨收"] = pd.to_numeric(temp_df["昨收"], errors="coerce")
204
+ temp_df["量比"] = pd.to_numeric(temp_df["量比"], errors="coerce")
205
+ return temp_df
206
+
207
+
128
208
  def stock_zh_index_spot_em(symbol: str = "上证系列指数") -> pd.DataFrame:
129
209
  """
130
210
  东方财富网-行情中心-沪深京指数
131
211
  https://quote.eastmoney.com/center/gridlist.html#index_sz
132
- :param symbol: "上证系列指数"; choice of {"上证系列指数", "深证系列指数", "指数成份", "中证系列指数"}
212
+ :param symbol: "上证系列指数"; choice of {"沪深重要指数", "上证系列指数", "深证系列指数", "指数成份", "中证系列指数"}
133
213
  :type symbol: str
134
214
  :return: 指数的实时行情数据
135
215
  :rtype: pandas.DataFrame
136
216
  """
217
+ if symbol == "沪深重要指数":
218
+ return __stock_zh_main_spot_em()
219
+
137
220
  url = "https://48.push2.eastmoney.com/api/qt/clist/get"
138
221
  symbol_map = {
139
222
  "上证系列指数": "m:1 s:2",
@@ -386,7 +469,7 @@ if __name__ == "__main__":
386
469
  stock_zh_index_spot_sina_df = stock_zh_index_spot_sina()
387
470
  print(stock_zh_index_spot_sina_df)
388
471
 
389
- stock_zh_index_spot_em_df = stock_zh_index_spot_em(symbol="中证系列指数")
472
+ stock_zh_index_spot_em_df = stock_zh_index_spot_em(symbol="沪深重要指数")
390
473
  print(stock_zh_index_spot_em_df)
391
474
 
392
475
  stock_zh_index_daily_tx_df = stock_zh_index_daily_tx(symbol="sh000919")
akshare/index/index_sw.py CHANGED
@@ -95,6 +95,9 @@ def sw_index_second_info() -> pd.DataFrame:
95
95
  )
96
96
  code = [item.get_text() for item in code_raw]
97
97
  name = [item.get_text().split("(")[0] for item in name_raw]
98
+ parent_name = [
99
+ item.find("span").get_text().split("(")[0][1:-1] for item in name_raw
100
+ ]
98
101
  num = [item.get_text().split("(")[1].split(")")[0] for item in name_raw]
99
102
  num_1 = [
100
103
  item.find_all("span", attrs={"class": "value"})[0].get_text().strip()
@@ -112,10 +115,11 @@ def sw_index_second_info() -> pd.DataFrame:
112
115
  item.find_all("span", attrs={"class": "value"})[3].get_text().strip()
113
116
  for item in value_raw
114
117
  ]
115
- temp_df = pd.DataFrame([code, name, num, num_1, num_2, num_3, num_4]).T
118
+ temp_df = pd.DataFrame([code, name, parent_name, num, num_1, num_2, num_3, num_4]).T
116
119
  temp_df.columns = [
117
120
  "行业代码",
118
121
  "行业名称",
122
+ "上级行业",
119
123
  "成份个数",
120
124
  "静态市盈率",
121
125
  "TTM(滚动)市盈率",
@@ -153,6 +157,9 @@ def sw_index_third_info() -> pd.DataFrame:
153
157
  )
154
158
  code = [item.get_text() for item in code_raw]
155
159
  name = [item.get_text().split("(")[0] for item in name_raw]
160
+ parent_name = [
161
+ item.find("span").get_text().split("(")[0][1:-1] for item in name_raw
162
+ ]
156
163
  num = [item.get_text().split("(")[1].split(")")[0] for item in name_raw]
157
164
  num_1 = [
158
165
  item.find_all("span", attrs={"class": "value"})[0].get_text().strip()
@@ -170,10 +177,11 @@ def sw_index_third_info() -> pd.DataFrame:
170
177
  item.find_all("span", attrs={"class": "value"})[3].get_text().strip()
171
178
  for item in value_raw
172
179
  ]
173
- temp_df = pd.DataFrame([code, name, num, num_1, num_2, num_3, num_4]).T
180
+ temp_df = pd.DataFrame([code, name, parent_name, num, num_1, num_2, num_3, num_4]).T
174
181
  temp_df.columns = [
175
182
  "行业代码",
176
183
  "行业名称",
184
+ "上级行业",
177
185
  "成份个数",
178
186
  "静态市盈率",
179
187
  "TTM(滚动)市盈率",
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2023/3/9 20:26
4
+ Date: 2024/11/21 18:26
5
5
  Desc: 百度股市通-港股-财务报表-估值数据
6
6
  https://gushitong.baidu.com/stock/hk-06969
7
7
  """
8
+
8
9
  import http.client
9
10
  import json
10
11
  import urllib
@@ -22,25 +23,36 @@ def stock_hk_valuation_baidu(
22
23
  :type symbol: str
23
24
  :param indicator: choice of {"总市值", "市盈率(TTM)", "市盈率(静)", "市净率", "市现率"}
24
25
  :type indicator: str
25
- :param period: choice of {"近一年", "近三年", "近五年", "近十年", "全部"}
26
+ :param period: choice of {"近一年", "近三年", "全部"}
26
27
  :type period: str
27
28
  :return: 估值数据
28
29
  :rtype: pandas.DataFrame
29
30
  """
30
31
  params = {
31
- "srcid": "51171",
32
+ "openapi": "1",
33
+ "dspName": "iphone",
34
+ "tn": "tangram",
35
+ "client": "app",
36
+ "query": indicator,
32
37
  "code": symbol,
38
+ "word": "",
39
+ "resource_id": "51171",
33
40
  "market": "hk",
34
41
  "tag": indicator,
35
42
  "chart_select": period,
36
- "skip_industry": "0",
43
+ "industry_select": "",
44
+ "skip_industry": "1",
37
45
  "finClientType": "pc",
38
46
  }
39
- conn = http.client.HTTPSConnection("finance.pae.baidu.com")
40
- conn.request("GET", f"/selfselect/openapi?{urllib.parse.urlencode(params)}")
47
+ conn = http.client.HTTPSConnection("gushitong.baidu.com")
48
+ conn.request(method="GET", url=f"/opendata?{urllib.parse.urlencode(params)}")
41
49
  r = conn.getresponse()
42
50
  data_json = json.loads(r.read())
43
- temp_df = pd.DataFrame(data_json["Result"]["chartInfo"][0]["body"])
51
+ temp_df = pd.DataFrame(
52
+ data_json["Result"][0]["DisplayData"]["resultData"]["tplData"]["result"][
53
+ "chartInfo"
54
+ ][0]["body"]
55
+ )
44
56
  temp_df.columns = ["date", "value"]
45
57
  temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
46
58
  temp_df["value"] = pd.to_numeric(temp_df["value"])
@@ -49,6 +61,6 @@ def stock_hk_valuation_baidu(
49
61
 
50
62
  if __name__ == "__main__":
51
63
  stock_hk_valuation_baidu_df = stock_hk_valuation_baidu(
52
- symbol="00700", indicator="总市值", period="近五年"
64
+ symbol="06969", indicator="总市值", period="近三年"
53
65
  )
54
66
  print(stock_hk_valuation_baidu_df)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: akshare
3
- Version: 1.15.26
3
+ Version: 1.15.28
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
@@ -40,7 +40,7 @@ Requires-Dist: akqmt; extra == "qmt"
40
40
 
41
41
  **欢迎加入专注于财经数据和量化投资的知识社区,请点击[了解更多](https://akshare.akfamily.xyz/learn.html)**
42
42
 
43
- **首门量化投资教程:《PyBroker-入门及实战》已经录制完成,目前已经上架!**
43
+ **量化投研视频课程:《PyBroker-入门及实战》已经上架!**
44
44
 
45
45
  **更多视频教程已经发布:《AKShare-初阶-使用教学》、《AKShare-初阶-实战应用》、《AKShare-源码解析》、《开源项目巡礼》**,
46
46
  详情请关注【数据科学实战】公众号,查看更多课程信息!
@@ -1,4 +1,4 @@
1
- akshare/__init__.py,sha256=3OjA_N1Ftt4-7aH6Fa3L2cGqy2iqjxuyzJy3WfOENv0,183986
1
+ akshare/__init__.py,sha256=8i1-bF44iMG9EqOv0Dfa2TsKHf8wo-1DQzOm1pqlphE,184088
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
@@ -111,7 +111,7 @@ akshare/futures/futures_comex_em.py,sha256=V-mkKQkH5N8PyaZWKdyggb2lTnY8DDDxiUPt-
111
111
  akshare/futures/futures_comm_ctp.py,sha256=V8TEKO0R0i6LfE8DDFqrMA3JGwNlpmaQCvvMugKZ1I8,1004
112
112
  akshare/futures/futures_comm_qihuo.py,sha256=uQfabZ63qME8sTaxUbIUVQBVi8yTaPPDhD7voR9PEx0,10504
113
113
  akshare/futures/futures_contract_detail.py,sha256=auwzNdaoFi5hoJY6rNkO54v5FD2gmEkQu7B90yEDtkc,1175
114
- akshare/futures/futures_daily_bar.py,sha256=i_wRExBVHzM6SVlDZSaFj0aI2uf77HwQmTUPOCfGrnM,25281
114
+ akshare/futures/futures_daily_bar.py,sha256=E1zx4VswHra2Gh30wKgWuHRO36tsTvKYfjC0dOMTBPY,25281
115
115
  akshare/futures/futures_foreign.py,sha256=oSIoAg5oy-CIlPWHkQffcvZGu02Y2GWOrt-6aPA53Xg,2059
116
116
  akshare/futures/futures_hf_em.py,sha256=OEUltaq1LKabl9eTQoNxswnl1BLKpB27eiIHwbu_Rh4,3178
117
117
  akshare/futures/futures_hq_sina.py,sha256=eK1gEan4DPvpYmln8-tNnzh_J_733s95DBr--NqNYVA,9576
@@ -171,10 +171,10 @@ akshare/index/index_research_sw.py,sha256=Mm1YtiP-PXhDysJwmFidX3RZSZZ92AyXpjl_tV
171
171
  akshare/index/index_spot.py,sha256=HrXt2QC9i1pYEh7wyJPKjtexctzSIUyMjEzk5BQq_K8,1696
172
172
  akshare/index/index_stock_hk.py,sha256=nPFzRrjyiUpRK-OSDsdi5AFCKHNKqOVji6WJcQxOvNo,9781
173
173
  akshare/index/index_stock_us_sina.py,sha256=IxOk4G49oasv7EfEQenL9-GLuelyUus6c4JPyRlaOzY,1551
174
- akshare/index/index_stock_zh.py,sha256=WkXd3A8gc1hgPJPR4znRbLfrqMeTivLS7L449TlOBdE,14873
174
+ akshare/index/index_stock_zh.py,sha256=A-tfbz6KHTLmBJimSzvaINrdmkWJ8V-mUkjcy7ly258,17669
175
175
  akshare/index/index_stock_zh_csindex.py,sha256=jVF29Byn2guaZ4QsXwwL1C5qtqk_m1ja-dgDnKnfz8s,13267
176
176
  akshare/index/index_sugar.py,sha256=B_Nj9Q6JP-Y_d7myZ0C79izTxxrbuZIp1Vv_CilVMOc,5006
177
- akshare/index/index_sw.py,sha256=n757dUfNEsaZGk_eCxeetZi3pktBBYLVEMM7f9U_XjM,10174
177
+ akshare/index/index_sw.py,sha256=hETMmFszQb7JDY8UHjLK8szfwkr7Ui_6QcseOoEfxaI,10456
178
178
  akshare/index/index_yw.py,sha256=6FF38kooLQulnMTqAd1__TNWip4XC1VA72k3T049xYc,4319
179
179
  akshare/index/index_zh_a_scope.py,sha256=4Ej2Gnqtd66EBiI67sQZKhblcIJXdD5CoMIJYD_KwYU,1367
180
180
  akshare/index/index_zh_em.py,sha256=RrwtUPjzV9DmWZ6J1XY1Ri1AmZFoXpQOdV21PrGrVtg,16356
@@ -317,7 +317,7 @@ akshare/stock_feature/stock_gpzy_em.py,sha256=8NvLfWbLLQyjTlg6iSpg1LxlIAKLv534JZ
317
317
  akshare/stock_feature/stock_gxl_lg.py,sha256=I8TpDEpFzadZSSyZisyIk6163mJlRxup91dmlBH4t4U,2641
318
318
  akshare/stock_feature/stock_hist_em.py,sha256=H8bbC0LJBvDTRnrhZvFtrMM8Y6H4LZk-C0KIPar1aQs,69201
319
319
  akshare/stock_feature/stock_hist_tx.py,sha256=WpLsbkG2didSx7lYNkSbTWNTrLhUKbcopfD18WO2Rlc,3397
320
- akshare/stock_feature/stock_hk_valuation_baidu.py,sha256=i3bPliFkPZcfXvuxuefSWFLC_DoF9ILdPBEyM0A9Lg4,1715
320
+ akshare/stock_feature/stock_hk_valuation_baidu.py,sha256=_sErx4UhNsSXJgXyPfrL0aPxkW53Mg1zH9gEKoziaCA,1968
321
321
  akshare/stock_feature/stock_hot_xq.py,sha256=NmoH4x-0hiDztj-YwzMFVIyOICQ2wUUBbhjt91q-tq4,9112
322
322
  akshare/stock_feature/stock_hsgt_em.py,sha256=1S18-GB9RvDP7tTvKR_W-BFSoKOPbpBTrbK67wbf-Uw,56688
323
323
  akshare/stock_feature/stock_hsgt_exchange_rate.py,sha256=YvhvdGx1nBJ_1swos1YNOtzy0GMFYo8MgNBh5QKphtE,6838
@@ -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.26.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
387
- akshare-1.15.26.dist-info/METADATA,sha256=XkNTYEhjtO_FHIQ6Op9jL9D1qyNbe0kk42zwP0yT9Vo,14259
388
- akshare-1.15.26.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
389
- akshare-1.15.26.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
390
- akshare-1.15.26.dist-info/RECORD,,
386
+ akshare-1.15.28.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
387
+ akshare-1.15.28.dist-info/METADATA,sha256=rxPymXOcNH6roYEJGJCKgBlt59BTmPoEkqhOzgA5zP0,14232
388
+ akshare-1.15.28.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
389
+ akshare-1.15.28.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
390
+ akshare-1.15.28.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.5.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5