akshare 1.14.67__py3-none-any.whl → 1.14.68__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
@@ -2878,9 +2878,10 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
2878
2878
  1.14.65 fix: fix option_dce_daily interface
2879
2879
  1.14.66 fix: fix stock_profit_forecast_ths interface
2880
2880
  1.14.67 fix: fix futures_foreign_commodity_realtime interface
2881
+ 1.14.68 fix: fix fund_scale_open_sina interface
2881
2882
  """
2882
2883
 
2883
- __version__ = "1.14.67"
2884
+ __version__ = "1.14.68"
2884
2885
  __author__ = "AKFamily"
2885
2886
 
2886
2887
  import sys
@@ -1,10 +1,11 @@
1
1
  # -*- coding:utf-8 -*-
2
2
  # !/usr/bin/env python
3
3
  """
4
- Date: 2023/11/7 18:30
4
+ Date: 2024/9/1 16:20
5
5
  Desc: 新浪财经-基金规模
6
6
  https://vip.stock.finance.sina.com.cn/fund_center/index.html#jjgmall
7
7
  """
8
+
8
9
  import pandas as pd
9
10
  import requests
10
11
 
@@ -27,7 +28,10 @@ def fund_scale_open_sina(symbol: str = "股票型基金") -> pd.DataFrame:
27
28
  "货币型基金": "5",
28
29
  "QDII基金": "6",
29
30
  }
30
- url = "http://vip.stock.finance.sina.com.cn/fund_center/data/jsonp.php/IO.XSRV2.CallbackList['J2cW8KXheoWKdSHc']/NetValueReturn_Service.NetValueReturnOpen"
31
+ url = (
32
+ "http://vip.stock.finance.sina.com.cn/fund_center/data/jsonp.php/IO.XSRV2."
33
+ "CallbackList['J2cW8KXheoWKdSHc']/NetValueReturn_Service.NetValueReturnOpen"
34
+ )
31
35
  params = {
32
36
  "page": "1",
33
37
  "num": "10000",
@@ -39,7 +43,7 @@ def fund_scale_open_sina(symbol: str = "股票型基金") -> pd.DataFrame:
39
43
  }
40
44
  r = requests.get(url, params=params)
41
45
  data_text = r.text
42
- data_json = demjson.decode(data_text[data_text.find("({") + 1: -2])
46
+ data_json = demjson.decode(data_text[data_text.find("({") + 1 : -2])
43
47
  temp_df = pd.DataFrame(data_json["data"])
44
48
  temp_df.reset_index(inplace=True)
45
49
  temp_df["index"] = range(1, len(temp_df) + 1)
@@ -95,19 +99,22 @@ def fund_scale_close_sina() -> pd.DataFrame:
95
99
  :return: 基金规模
96
100
  :rtype: pandas.DataFrame
97
101
  """
98
- url = "http://vip.stock.finance.sina.com.cn/fund_center/data/jsonp.php/IO.XSRV2.CallbackList['_bjN6KvXOkfPy2Bu']/NetValueReturn_Service.NetValueReturnClose"
102
+ url = (
103
+ "http://vip.stock.finance.sina.com.cn/fund_center/data/jsonp.php/IO.XSRV2."
104
+ "CallbackList['_bjN6KvXOkfPy2Bu']/NetValueReturn_Service.NetValueReturnClose"
105
+ )
99
106
  params = {
100
107
  "page": "1",
101
108
  "num": "1000",
102
109
  "sort": "zmjgm",
103
110
  "asc": "0",
104
111
  "ccode": "",
105
- "type2": '',
112
+ "type2": "",
106
113
  "type3": "",
107
114
  }
108
115
  r = requests.get(url, params=params)
109
116
  data_text = r.text
110
- data_json = demjson.decode(data_text[data_text.find("({") + 1: -2])
117
+ data_json = demjson.decode(data_text[data_text.find("({") + 1 : -2])
111
118
  temp_df = pd.DataFrame(data_json["data"])
112
119
  temp_df.reset_index(inplace=True)
113
120
  temp_df["index"] = range(1, len(temp_df) + 1)
@@ -163,19 +170,22 @@ def fund_scale_structured_sina() -> pd.DataFrame:
163
170
  :return: 基金规模
164
171
  :rtype: pandas.DataFrame
165
172
  """
166
- url = "http://vip.stock.finance.sina.com.cn/fund_center/data/jsonp.php/IO.XSRV2.CallbackList['cRrwseM7NWX68rDa']/NetValueReturn_Service.NetValueReturnCX"
173
+ url = (
174
+ "http://vip.stock.finance.sina.com.cn/fund_center/data/jsonp.php/IO.XSRV2."
175
+ "CallbackList['cRrwseM7NWX68rDa']/NetValueReturn_Service.NetValueReturnCX"
176
+ )
167
177
  params = {
168
178
  "page": "1",
169
179
  "num": "1000",
170
180
  "sort": "zmjgm",
171
181
  "asc": "0",
172
182
  "ccode": "",
173
- "type2": '',
183
+ "type2": "",
174
184
  "type3": "",
175
185
  }
176
186
  r = requests.get(url, params=params)
177
187
  data_text = r.text
178
- data_json = demjson.decode(data_text[data_text.find("({") + 1: -2])
188
+ data_json = demjson.decode(data_text[data_text.find("({") + 1 : -2])
179
189
  temp_df = pd.DataFrame(data_json["data"])
180
190
  temp_df.reset_index(inplace=True)
181
191
  temp_df["index"] = range(1, len(temp_df) + 1)
@@ -234,5 +244,5 @@ if __name__ == "__main__":
234
244
  fund_scale_structured_sina_df = fund_scale_structured_sina()
235
245
  print(fund_scale_structured_sina_df)
236
246
 
237
- fund_scale_open_sina_df = fund_scale_open_sina(symbol='股票型基金')
247
+ fund_scale_open_sina_df = fund_scale_open_sina(symbol="股票型基金")
238
248
  print(fund_scale_open_sina_df)
@@ -1,21 +1,22 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2023/5/3 17:00
4
+ Date: 2024/9/1 16:00
5
5
  Desc: 股票数据-总貌-市场总貌
6
6
  股票数据-总貌-成交概括
7
7
  https://www.szse.cn/market/overview/index.html
8
8
  https://www.sse.com.cn/market/stockdata/statistic/
9
9
  """
10
+
10
11
  import warnings
11
- from io import BytesIO
12
+ from io import BytesIO, StringIO
12
13
 
13
14
  import pandas as pd
14
15
  import requests
15
16
  from bs4 import BeautifulSoup
16
17
 
17
18
 
18
- def stock_szse_summary(date: str = "20200619") -> pd.DataFrame:
19
+ def stock_szse_summary(date: str = "20240830") -> pd.DataFrame:
19
20
  """
20
21
  深证证券交易所-总貌-证券类别统计
21
22
  https://www.szse.cn/market/overview/index.html
@@ -37,10 +38,10 @@ def stock_szse_summary(date: str = "20200619") -> pd.DataFrame:
37
38
  warnings.simplefilter("always")
38
39
  temp_df = pd.read_excel(BytesIO(r.content), engine="openpyxl")
39
40
  temp_df["证券类别"] = temp_df["证券类别"].str.strip()
40
- temp_df.iloc[:, 2:] = temp_df.iloc[:, 2:].applymap(lambda x: x.replace(",", ""))
41
+ temp_df.iloc[:, 2:] = temp_df.iloc[:, 2:].map(lambda x: x.replace(",", ""))
41
42
  temp_df.columns = ["证券类别", "数量", "成交金额", "总市值", "流通市值"]
42
- temp_df["数量"] = pd.to_numeric(temp_df["数量"])
43
- temp_df["成交金额"] = pd.to_numeric(temp_df["成交金额"])
43
+ temp_df["数量"] = pd.to_numeric(temp_df["数量"], errors="coerce")
44
+ temp_df["成交金额"] = pd.to_numeric(temp_df["成交金额"], errors="coerce")
44
45
  temp_df["总市值"] = pd.to_numeric(temp_df["总市值"], errors="coerce")
45
46
  temp_df["流通市值"] = pd.to_numeric(temp_df["流通市值"], errors="coerce")
46
47
  return temp_df
@@ -67,7 +68,15 @@ def stock_szse_area_summary(date: str = "202203") -> pd.DataFrame:
67
68
  with warnings.catch_warnings(record=True):
68
69
  warnings.simplefilter("always")
69
70
  temp_df = pd.read_excel(BytesIO(r.content), engine="openpyxl")
70
- temp_df.columns = ["序号", "地区", "总交易额", "占市场", "股票交易额", "基金交易额", "债券交易额"]
71
+ temp_df.columns = [
72
+ "序号",
73
+ "地区",
74
+ "总交易额",
75
+ "占市场",
76
+ "股票交易额",
77
+ "基金交易额",
78
+ "债券交易额",
79
+ ]
71
80
  temp_df["总交易额"] = temp_df["总交易额"].str.replace(",", "")
72
81
  temp_df["总交易额"] = pd.to_numeric(temp_df["总交易额"])
73
82
  temp_df["占市场"] = pd.to_numeric(temp_df["占市场"])
@@ -80,7 +89,9 @@ def stock_szse_area_summary(date: str = "202203") -> pd.DataFrame:
80
89
  return temp_df
81
90
 
82
91
 
83
- def stock_szse_sector_summary(symbol: str = "当月", date: str = "202303") -> pd.DataFrame:
92
+ def stock_szse_sector_summary(
93
+ symbol: str = "当月", date: str = "202303"
94
+ ) -> pd.DataFrame:
84
95
  """
85
96
  深圳证券交易所-统计资料-股票行业成交数据
86
97
  https://docs.static.szse.cn/www/market/periodical/month/W020220511355248518608.html
@@ -94,8 +105,8 @@ def stock_szse_sector_summary(symbol: str = "当月", date: str = "202303") -> p
94
105
  url = "https://www.szse.cn/market/periodical/month/index.html"
95
106
  r = requests.get(url)
96
107
  r.encoding = "utf8"
97
- soup = BeautifulSoup(r.text, "lxml")
98
- tags_list = soup.find_all("div", attrs={"class": "g-container"})[1].find_all(
108
+ soup = BeautifulSoup(r.text, features="lxml")
109
+ tags_list = soup.find_all(name="div", attrs={"class": "g-container"})[1].find_all(
99
110
  "script"
100
111
  )
101
112
  tags_dict = [
@@ -118,11 +129,14 @@ def stock_szse_sector_summary(symbol: str = "当月", date: str = "202303") -> p
118
129
  url = f"http://www.szse.cn/market/periodical/month/{date_url_dict[date_format]}"
119
130
  r = requests.get(url)
120
131
  r.encoding = "utf8"
121
- soup = BeautifulSoup(r.text, "lxml")
122
- url = [item for item in soup.find_all("a") if item.get_text() == "股票行业成交数据"][0]["href"]
132
+ soup = BeautifulSoup(r.text, features="lxml")
133
+ url = [
134
+ item for item in soup.find_all("a") if item.get_text() == "股票行业成交数据"
135
+ ][0]["href"]
123
136
 
124
137
  if symbol == "当月":
125
- temp_df = pd.read_html(url, encoding="gbk")[0]
138
+ r = requests.get(url)
139
+ temp_df = pd.read_html(StringIO(r.text), encoding="gbk")[0]
126
140
  temp_df.columns = [
127
141
  "项目名称",
128
142
  "项目名称-英文",
@@ -149,12 +163,20 @@ def stock_szse_sector_summary(symbol: str = "当月", date: str = "202303") -> p
149
163
  ]
150
164
 
151
165
  temp_df["交易天数"] = pd.to_numeric(temp_df["交易天数"], errors="coerce")
152
- temp_df["成交金额-人民币元"] = pd.to_numeric(temp_df["成交金额-人民币元"], errors="coerce")
153
- temp_df["成交金额-占总计"] = pd.to_numeric(temp_df["成交金额-占总计"], errors="coerce")
166
+ temp_df["成交金额-人民币元"] = pd.to_numeric(
167
+ temp_df["成交金额-人民币元"], errors="coerce"
168
+ )
169
+ temp_df["成交金额-占总计"] = pd.to_numeric(
170
+ temp_df["成交金额-占总计"], errors="coerce"
171
+ )
154
172
  temp_df["成交股数-股数"] = pd.to_numeric(temp_df["成交股数-股数"], errors="coerce")
155
- temp_df["成交股数-占总计"] = pd.to_numeric(temp_df["成交股数-占总计"], errors="coerce")
173
+ temp_df["成交股数-占总计"] = pd.to_numeric(
174
+ temp_df["成交股数-占总计"], errors="coerce"
175
+ )
156
176
  temp_df["成交笔数-笔"] = pd.to_numeric(temp_df["成交笔数-笔"], errors="coerce")
157
- temp_df["成交笔数-占总计"] = pd.to_numeric(temp_df["成交笔数-占总计"], errors="coerce")
177
+ temp_df["成交笔数-占总计"] = pd.to_numeric(
178
+ temp_df["成交笔数-占总计"], errors="coerce"
179
+ )
158
180
  return temp_df
159
181
 
160
182
 
@@ -174,7 +196,8 @@ def stock_sse_summary() -> pd.DataFrame:
174
196
  }
175
197
  headers = {
176
198
  "Referer": "http://www.sse.com.cn/",
177
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
199
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
200
+ "Chrome/89.0.4389.90 Safari/537.36",
178
201
  }
179
202
  r = requests.get(url, params=params, headers=headers)
180
203
  data_json = r.json()
@@ -279,9 +302,9 @@ def stock_sse_deal_daily(date: str = "20180117") -> pd.DataFrame:
279
302
  temp_df.sort_values("单日情况", ascending=True, inplace=True)
280
303
  temp_df.reset_index(drop=True, inplace=True)
281
304
  # 构建空
282
- temp_df['股票'] = "-"
283
- temp_df['科创板'] = "-"
284
- temp_df['股票回购'] = "-"
305
+ temp_df["股票"] = "-"
306
+ temp_df["科创板"] = "-"
307
+ temp_df["股票回购"] = "-"
285
308
  temp_df["股票"] = pd.to_numeric(temp_df["股票"], errors="coerce")
286
309
  temp_df["主板A"] = pd.to_numeric(temp_df["主板A"], errors="coerce")
287
310
  temp_df["主板B"] = pd.to_numeric(temp_df["主板B"], errors="coerce")
@@ -308,7 +331,8 @@ def stock_sse_deal_daily(date: str = "20180117") -> pd.DataFrame:
308
331
  }
309
332
  headers = {
310
333
  "Referer": "http://www.sse.com.cn/",
311
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
334
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
335
+ "Chrome/89.0.4389.90 Safari/537.36",
312
336
  }
313
337
  r = requests.get(url, params=params, headers=headers)
314
338
  data_json = r.json()
@@ -462,7 +486,8 @@ def stock_sse_deal_daily(date: str = "20180117") -> pd.DataFrame:
462
486
  }
463
487
  headers = {
464
488
  "Referer": "http://www.sse.com.cn/",
465
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
489
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
490
+ "Chrome/89.0.4389.90 Safari/537.36",
466
491
  }
467
492
  r = requests.get(url, params=params, headers=headers)
468
493
  data_json = r.json()
@@ -531,7 +556,8 @@ def stock_sse_deal_daily(date: str = "20180117") -> pd.DataFrame:
531
556
  }
532
557
  headers = {
533
558
  "Referer": "http://www.sse.com.cn/",
534
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36",
559
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
560
+ "Chrome/89.0.4389.90 Safari/537.36",
535
561
  }
536
562
  r = requests.get(url, params=params, headers=headers)
537
563
  data_json = r.json()
@@ -603,13 +629,15 @@ def stock_sse_deal_daily(date: str = "20180117") -> pd.DataFrame:
603
629
 
604
630
 
605
631
  if __name__ == "__main__":
606
- stock_szse_summary_df = stock_szse_summary(date="20070511")
632
+ stock_szse_summary_df = stock_szse_summary(date="20240901")
607
633
  print(stock_szse_summary_df)
608
634
 
609
635
  stock_szse_area_summary_df = stock_szse_area_summary(date="202203")
610
636
  print(stock_szse_area_summary_df)
611
637
 
612
- stock_szse_sector_summary_df = stock_szse_sector_summary(symbol="当月", date="202303")
638
+ stock_szse_sector_summary_df = stock_szse_sector_summary(
639
+ symbol="当月", date="202303"
640
+ )
613
641
  print(stock_szse_sector_summary_df)
614
642
 
615
643
  stock_sse_summary_df = stock_sse_summary()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: akshare
3
- Version: 1.14.67
3
+ Version: 1.14.68
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=yW8MnZvK9KBycyLgQuK7W7sVrc3kdHHdQc7PMN8ml1Y,181213
1
+ akshare/__init__.py,sha256=sI9wMWeuOVe3fXi07QfD7EvoEAtkPKSjfz4gLjjb294,181261
2
2
  akshare/datasets.py,sha256=oIu1zC7o_LMHY22lQmdM7vCnryHibKrJLBqJwQiitlI,1167
3
3
  akshare/air/__init__.py,sha256=RMTf1bT5EOE3ttWpn3hGu1LtUmsVxDoa0W7W0gXHOy8,81
4
4
  akshare/air/air_hebei.py,sha256=xIXNGLK7IGYqrkteM9fxnHAwWqk6PCQs6D9-ggZ7byY,4442
@@ -97,7 +97,7 @@ akshare/fund/fund_rank_em.py,sha256=FZX5YxoGAaRWlqKJDp1CLWORjxzvHMFCnoKp2yx-K4k,
97
97
  akshare/fund/fund_rating.py,sha256=oBZTOBaiC9RMfTK2XGKIMY58sPxc7M6GlMJ3_M3i0lQ,11680
98
98
  akshare/fund/fund_report_cninfo.py,sha256=rhztaa3J48VdnCEXFAl8wMg-P7MI2iQa0HculkvL8CI,8785
99
99
  akshare/fund/fund_scale_em.py,sha256=8XLZpz9DzsAnJCo1moBmzf3u7mfZNZHsb3cPKJ-gCJM,4237
100
- akshare/fund/fund_scale_sina.py,sha256=cQ39Pt6ia3GrVCFWv0GhLMqxyedX3qRrvkDLee7N9R0,8083
100
+ akshare/fund/fund_scale_sina.py,sha256=A0qIzWBQdE3IGS9-cxO9_FNpuH-BAG5HhPk5KzTFTFc,8167
101
101
  akshare/fund/fund_xq.py,sha256=qGMKYC0Vi2AXfnjsS0P9B2ITfpkQ85i4ayXA6kJ6a7o,11295
102
102
  akshare/futures/__init__.py,sha256=RMTf1bT5EOE3ttWpn3hGu1LtUmsVxDoa0W7W0gXHOy8,81
103
103
  akshare/futures/cons.py,sha256=sc0LW_k_Poc3V3r_Mz8DiKfLy7aisda28pK0u8ffMus,16193
@@ -270,7 +270,7 @@ akshare/stock/stock_repurchase_em.py,sha256=XVAUD_yd48wqxbMbfU0Ne2SNFOSG9NBklUhf
270
270
  akshare/stock/stock_share_changes_cninfo.py,sha256=zg-1KHPbxdMRMr4wYY8LA30D-u47YesbEDt_MgCMk_k,4846
271
271
  akshare/stock/stock_share_hold.py,sha256=uToDxxnaD9nVtsidq0kVK-LzWU4XZdZBdzJnJvywAfI,10959
272
272
  akshare/stock/stock_stop.py,sha256=8HyazJAFj-s12ujUtrxO8VPXyA5bF9-3eNEj0qzGwMg,1185
273
- akshare/stock/stock_summary.py,sha256=g6BKqQRT3VAtirMaPJcIdA4itARq5NhTXKSIJaxA5KA,22524
273
+ akshare/stock/stock_summary.py,sha256=tfyTgc-a_VZV6K4uMcTKySDkrBPQOvCTB0th7tpUCRc,22839
274
274
  akshare/stock/stock_us_famous.py,sha256=enx_-EzEJWAhrMVQZaN83ETY_YEWO2xEStRm6z3upO0,3655
275
275
  akshare/stock/stock_us_js.py,sha256=wwZpRvVHqjxwd0cb2O5vtRW8Zw90Kdl5O4XNwoevN64,2502
276
276
  akshare/stock/stock_us_pink.py,sha256=jgkEjPm_qa4zSN1MH0unHJopSkcF-8Rqlp5Kus2KaQ8,3062
@@ -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.14.67.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
384
- akshare-1.14.67.dist-info/METADATA,sha256=InuyRC-Gi3_ULtvB2OyYh6ughdk6SPaahsWdohd9bNc,13961
385
- akshare-1.14.67.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
386
- akshare-1.14.67.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
387
- akshare-1.14.67.dist-info/RECORD,,
383
+ akshare-1.14.68.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
384
+ akshare-1.14.68.dist-info/METADATA,sha256=kuTDxIEegv9P5_hEnw7bpKMewRf80s-J2PsdS5Oi-W4,13961
385
+ akshare-1.14.68.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
386
+ akshare-1.14.68.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
387
+ akshare-1.14.68.dist-info/RECORD,,