akshare 1.15.21__py3-none-any.whl → 1.15.23__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
@@ -2920,20 +2920,22 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
2920
2920
  1.15.8 fix: fix fund_individual_basic_info_xq interface
2921
2921
  1.15.9 fix: fix index_analysis_weekly_sw interface
2922
2922
  1.15.10 add: add volatility_yz_rv indicator
2923
- 1.15.11 fix: fix stock_individual_spot_xq indicator
2924
- 1.15.12 fix: fix stock_shareholder_change_ths indicator
2925
- 1.15.13 fix: fix stock_inner_trade_xq indicator
2926
- 1.15.14 fix: fix macro_bank_usa_interest_rate indicator
2927
- 1.15.15 add: add macro_bank_china_interest_rate indicator
2928
- 1.15.16 fix: fix macro_bank_usa_interest_rate indicator
2929
- 1.15.17 fix: fix news_trade_notify_dividend_baidu indicator
2930
- 1.15.18 fix: fix stock_share_hold_change_sse indicator
2931
- 1.15.19 fix: fix stock_share_hold_change_szse indicator
2932
- 1.15.20 fix: fix rv_from_stock_zh_a_hist_min_em indicator
2933
- 1.15.21 fix: fix get_futures_daily indicator
2934
- """
2935
-
2936
- __version__ = "1.15.21"
2923
+ 1.15.11 fix: fix stock_individual_spot_xq interface
2924
+ 1.15.12 fix: fix stock_shareholder_change_ths interface
2925
+ 1.15.13 fix: fix stock_inner_trade_xq interface
2926
+ 1.15.14 fix: fix macro_bank_usa_interest_rate interface
2927
+ 1.15.15 add: add macro_bank_china_interest_rate interface
2928
+ 1.15.16 fix: fix macro_bank_usa_interest_rate interface
2929
+ 1.15.17 fix: fix news_trade_notify_dividend_baidu interface
2930
+ 1.15.18 fix: fix stock_share_hold_change_sse interface
2931
+ 1.15.19 fix: fix stock_share_hold_change_szse interface
2932
+ 1.15.20 fix: fix rv_from_stock_zh_a_hist_min_em interface
2933
+ 1.15.21 fix: fix get_futures_daily interface
2934
+ 1.15.22 fix: fix air_quality_hebei interface
2935
+ 1.15.23 fix: fix stock_sector_fund_flow_summary interface
2936
+ """
2937
+
2938
+ __version__ = "1.15.23"
2937
2939
  __author__ = "AKFamily"
2938
2940
 
2939
2941
  import sys
akshare/air/air_hebei.py CHANGED
@@ -15,70 +15,93 @@ https://110.249.223.67/publish
15
15
  发布单位:河北省环境应急与重污染天气预警中心 技术支持:中国科学院大气物理研究所 中科三清科技有限公司
16
16
  """
17
17
 
18
- from datetime import datetime
19
-
20
18
  import pandas as pd
21
19
  import requests
22
- from tqdm import tqdm
20
+ from bs4 import BeautifulSoup
23
21
 
24
22
 
25
- def air_quality_hebei(symbol: str = "唐山市") -> pd.DataFrame:
23
+ def air_quality_hebei() -> pd.DataFrame:
26
24
  """
27
25
  河北省空气质量预报信息发布系统-空气质量预报, 未来 6 天
28
- https://110.249.223.67/publish/
29
- :param symbol: choice of {'石家庄市', '唐山市', '秦皇岛市', '邯郸市', '邢台市', '保定市', '张家口市', '承德市', '沧州市', '廊坊市', '衡水市', '辛集市', '定州市'}
30
- :type symbol: str
26
+ http://218.11.10.130:8080/#/application/home
31
27
  :return: city = "", 返回所有地区的数据; city="唐山市", 返回唐山市的数据
32
28
  :rtype: pandas.DataFrame
33
29
  """
34
- url = (
35
- "http://110.249.223.67/server/api/CityPublishInfo/GetProvinceAndCityPublishData"
36
- )
37
- params = {"publishDate": f"{datetime.today().strftime('%Y-%m-%d')} 16:00:00"}
38
- r = requests.get(url, params=params)
39
- json_data = r.json()
40
- city_list = pd.DataFrame.from_dict(json_data["cityPublishDatas"], orient="columns")[
41
- "CityName"
42
- ].tolist()
43
- outer_df = pd.DataFrame()
44
- for i in tqdm(range(1, 7), leave=False):
45
- inner_df = pd.DataFrame(
46
- [item[f"Date{i}"] for item in json_data["cityPublishDatas"]],
47
- index=city_list,
48
- )
49
- outer_df = pd.concat([outer_df, inner_df])
50
- if symbol == "":
51
- temp_df = outer_df.reset_index()
52
- temp_df.columns = [
53
- "city",
54
- "date",
55
- "pollutant",
56
- "minAQI",
57
- "maxAQI",
58
- "level",
59
- ]
60
- temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
61
- temp_df["minaqi"] = pd.to_numeric(temp_df["minaqi"])
62
- temp_df["maxaqi"] = pd.to_numeric(temp_df["maxaqi"])
63
- return temp_df
64
- else:
65
- temp_df = outer_df.reset_index()
66
- temp_df.columns = [
67
- "city",
68
- "date",
69
- "pollutant",
70
- "minaqi",
71
- "maxaqi",
72
- "level",
73
- ]
74
- temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
75
- temp_df["minaqi"] = pd.to_numeric(temp_df["minaqi"])
76
- temp_df["maxaqi"] = pd.to_numeric(temp_df["maxaqi"])
77
- temp_df = temp_df[temp_df["city"] == symbol]
78
- temp_df.reset_index(inplace=True, drop=True)
79
- return temp_df
30
+ url = "http://218.11.10.130:8080/api/hour/130000.xml"
31
+ r = requests.get(url)
32
+ soup = BeautifulSoup(r.content, features="xml")
33
+ data = []
34
+ cities = soup.find_all("City")
35
+ for city in cities:
36
+ pointers = city.find_all("Pointer")
37
+ for pointer in pointers:
38
+ row = {
39
+ "City": city.Name.text if city.Name else None,
40
+ "Region": pointer.Region.text if pointer.Region else None,
41
+ "Station": pointer.Name.text if pointer.Name else None,
42
+ "DateTime": pointer.DataTime.text if pointer.DataTime else None,
43
+ "AQI": pointer.AQI.text if pointer.AQI else None,
44
+ "Level": pointer.Level.text if pointer.Level else None,
45
+ "MaxPoll": pointer.MaxPoll.text if pointer.MaxPoll else None,
46
+ "Longitude": pointer.CLng.text if pointer.CLng else None,
47
+ "Latitude": pointer.CLat.text if pointer.CLat else None,
48
+ }
49
+ polls = pointer.find_all("Poll")
50
+ for poll in polls:
51
+ poll_name = poll.Name.text if poll.Name else None
52
+ poll_value = poll.Value.text if poll.Value else None
53
+ row[f"{poll_name}_Value"] = poll_value
54
+ row[f"{poll_name}_IAQI"] = poll.IAQI.text if poll.IAQI else None
55
+ data.append(row)
56
+
57
+ df = pd.DataFrame(data)
58
+ numeric_columns = ["AQI", "Longitude", "Latitude"] + [
59
+ col for col in df.columns if col.endswith("_Value") or col.endswith("_IAQI")
60
+ ]
61
+ for col in numeric_columns:
62
+ df[col] = pd.to_numeric(df[col], errors="coerce")
63
+
64
+ column_names = {
65
+ "City": "城市",
66
+ "Region": "区域",
67
+ "Station": "监测点",
68
+ "DateTime": "时间",
69
+ "Level": "空气质量等级",
70
+ "MaxPoll": "首要污染物",
71
+ "Longitude": "经度",
72
+ "Latitude": "纬度",
73
+ "SO2_Value": "二氧化硫_浓度",
74
+ "SO2_IAQI": "二氧化硫_IAQI",
75
+ "CO_Value": "一氧化碳_浓度",
76
+ "CO_IAQI": "一氧化碳_IAQI",
77
+ "NO2_Value": "二氧化氮_浓度",
78
+ "NO2_IAQI": "二氧化氮_IAQI",
79
+ "O3-1H_Value": "臭氧1小时_浓度",
80
+ "O3-1H_IAQI": "臭氧1小时_IAQI",
81
+ "O3-8H_Value": "臭氧8小时_浓度",
82
+ "O3-8H_IAQI": "臭氧8小时_IAQI",
83
+ "PM2.5_Value": "PM2.5_浓度",
84
+ "PM2.5_IAQI": "PM2.5_IAQI",
85
+ "PM10_Value": "PM10_浓度",
86
+ "PM10_IAQI": "PM10_IAQI",
87
+ }
88
+ df = df.rename(columns=column_names)
89
+ basic_columns = [
90
+ "城市",
91
+ "区域",
92
+ "监测点",
93
+ "时间",
94
+ "AQI",
95
+ "空气质量等级",
96
+ "首要污染物",
97
+ "经度",
98
+ "纬度",
99
+ ]
100
+ pollutant_columns = [col for col in df.columns if col not in basic_columns]
101
+ df = df[basic_columns + sorted(pollutant_columns)]
102
+ return df
80
103
 
81
104
 
82
105
  if __name__ == "__main__":
83
- air_quality_hebei_df = air_quality_hebei(symbol="定州市")
106
+ air_quality_hebei_df = air_quality_hebei()
84
107
  print(air_quality_hebei_df)
@@ -353,7 +353,7 @@ def stock_market_fund_flow() -> pd.DataFrame:
353
353
  }
354
354
  r = requests.get(url, params=params, headers=headers)
355
355
  text_data = r.text
356
- json_data = json.loads(text_data[text_data.find("{"): -2])
356
+ json_data = json.loads(text_data[text_data.find("{") : -2])
357
357
  content_list = json_data["data"]["klines"]
358
358
  temp_df = pd.DataFrame([item.split(",") for item in content_list])
359
359
  temp_df.columns = [
@@ -484,7 +484,7 @@ def stock_sector_fund_flow_rank(
484
484
  }
485
485
  r = requests.get(url, params=params, headers=headers)
486
486
  text_data = r.text
487
- json_data = json.loads(text_data[text_data.find("{"): -2])
487
+ json_data = json.loads(text_data[text_data.find("{") : -2])
488
488
  temp_df = pd.DataFrame(json_data["data"]["diff"])
489
489
  if indicator == "今日":
490
490
  temp_df.columns = [
@@ -675,7 +675,7 @@ def stock_sector_fund_flow_summary(
675
675
  params = {
676
676
  "fid": "f62",
677
677
  "po": "1",
678
- "pz": "50",
678
+ "pz": "500",
679
679
  "pn": "1",
680
680
  "np": "1",
681
681
  "fltt": "2",
@@ -764,7 +764,7 @@ def stock_sector_fund_flow_summary(
764
764
  params = {
765
765
  "fid": "f164",
766
766
  "po": "1",
767
- "pz": "50",
767
+ "pz": "500",
768
768
  "pn": "1",
769
769
  "np": "1",
770
770
  "fltt": "2",
@@ -853,7 +853,7 @@ def stock_sector_fund_flow_summary(
853
853
  params = {
854
854
  "fid": "f174",
855
855
  "po": "1",
856
- "pz": "50",
856
+ "pz": "500",
857
857
  "pn": "1",
858
858
  "np": "1",
859
859
  "fltt": "2",
@@ -1296,7 +1296,7 @@ if __name__ == "__main__":
1296
1296
  print(stock_sector_fund_flow_rank_df)
1297
1297
 
1298
1298
  stock_sector_fund_flow_summary_df = stock_sector_fund_flow_summary(
1299
- symbol="电源设备", indicator="今日"
1299
+ symbol="文化传媒", indicator="今日"
1300
1300
  )
1301
1301
  print(stock_sector_fund_flow_summary_df)
1302
1302
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: akshare
3
- Version: 1.15.21
3
+ Version: 1.15.23
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,9 +1,9 @@
1
- akshare/__init__.py,sha256=kZ1m2-OHKCI5xXz2lfc0MLGiOtR71Y2pnlCEve0WsUA,183752
1
+ akshare/__init__.py,sha256=esnbioSee-xPIEkExyh3X3uOI92OJ81gidK_wjOixfE,183855
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
5
5
  akshare/air/__init__.py,sha256=RMTf1bT5EOE3ttWpn3hGu1LtUmsVxDoa0W7W0gXHOy8,81
6
- akshare/air/air_hebei.py,sha256=xIXNGLK7IGYqrkteM9fxnHAwWqk6PCQs6D9-ggZ7byY,4442
6
+ akshare/air/air_hebei.py,sha256=jFhsi41EfSGYpRUo98bvJ1oer1FPiQgw1grSrb_q5Yg,5415
7
7
  akshare/air/air_zhenqi.py,sha256=FurRxuYyoZpTa2lsP6BgUJfbfMgOO26_VPuc-ekKZXs,9636
8
8
  akshare/air/cons.py,sha256=v4TGVepsboZUpKgeuBdoSGlf7KVZPq783FfaXqtJNDA,9771
9
9
  akshare/air/crypto.js,sha256=0V4nL8-myB3vu9J-P3YEEg67Lw9ht-q9cS0odAuJsD0,8443
@@ -242,7 +242,7 @@ akshare/stock/stock_cg_guarantee.py,sha256=ts7qcQhhyN1PHB7Q4XlMn38HhfVvubOvky9RZ
242
242
  akshare/stock/stock_cg_lawsuit.py,sha256=6Y92pPw0JgyrInteqHuU07G1jwmdX2wjaDtrJN8y6Hg,4129
243
243
  akshare/stock/stock_dividend_cninfo.py,sha256=_vipLQu94qBDoPkaIWZKRFA0mFfgroUMnn5EdLcjAc4,3195
244
244
  akshare/stock/stock_dzjy_em.py,sha256=AOgZTThw3kr_0N0y6-ujthaVg-OK0EYGGeetD58XqmQ,20519
245
- akshare/stock/stock_fund_em.py,sha256=wTpPCOh6PcwHK8iL8iWBgzIGXLGn5vDo-PLzHVM21xY,48849
245
+ akshare/stock/stock_fund_em.py,sha256=Dnn72I85snGaMHCEmbXNANCfiHCuh7EkWn8t5EwO-HQ,48854
246
246
  akshare/stock/stock_fund_hold.py,sha256=iFEmRFber7MF6aPi0QOJxpvYjO7I26KouUvC-xTQdCk,6056
247
247
  akshare/stock/stock_gsrl_em.py,sha256=oy5vO681ZPTEehZgz10T8jgIQ8dNm_E7MXGr1PGoHqI,1951
248
248
  akshare/stock/stock_hk_famous.py,sha256=g-p1cdRibei9fw2HEMPyarLP-wT4bFwIK7Mxi77jH9E,3015
@@ -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.21.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
387
- akshare-1.15.21.dist-info/METADATA,sha256=ro5R5nJrKj_SNlSQOtbWvo3aIvftW0Z-GLLJu-Jo4UU,14259
388
- akshare-1.15.21.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
389
- akshare-1.15.21.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
390
- akshare-1.15.21.dist-info/RECORD,,
386
+ akshare-1.15.23.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
387
+ akshare-1.15.23.dist-info/METADATA,sha256=0kcABUk8XOdxJRS6un15HoVO_B8aDt_FkolY7hRA-8Y,14259
388
+ akshare-1.15.23.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
389
+ akshare-1.15.23.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
390
+ akshare-1.15.23.dist-info/RECORD,,