akshare 1.15.65__py3-none-any.whl → 1.15.66__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
@@ -2975,9 +2975,10 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
2975
2975
  1.15.63 fix: fix stock_financial_abstract interface
2976
2976
  1.15.64 fix: fix stock_zh_index_value_csindex interface
2977
2977
  1.15.65 fix: fix option_czce_daily interface
2978
+ 1.15.66 fix: fix fund_etf_dividend_sina interface
2978
2979
  """
2979
2980
 
2980
- __version__ = "1.15.65"
2981
+ __version__ = "1.15.66"
2981
2982
  __author__ = "AKFamily"
2982
2983
 
2983
2984
  import sys
@@ -4485,6 +4486,7 @@ from akshare.stock_feature.stock_yjyg_cninfo import stock_report_disclosure
4485
4486
  from akshare.fund.fund_etf_sina import (
4486
4487
  fund_etf_hist_sina,
4487
4488
  fund_etf_category_sina,
4489
+ fund_etf_dividend_sina,
4488
4490
  )
4489
4491
 
4490
4492
  """
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2024/11/22 14:00
4
+ Date: 2025/1/5 19:00
5
5
  Desc: 新浪财经-基金行情
6
6
  https://vip.stock.finance.sina.com.cn/fund_center/index.html#jjhqetf
7
7
  """
@@ -132,15 +132,56 @@ def fund_etf_hist_sina(symbol: str = "sh510050") -> pd.DataFrame:
132
132
  temp_df = pd.DataFrame(dict_list)
133
133
  if temp_df.empty: # 处理获取数据为空的问题
134
134
  return pd.DataFrame()
135
- temp_df["date"] = pd.to_datetime(temp_df["date"], errors="coerce").dt.date
135
+ temp_df["date"] = pd.to_datetime(temp_df["date"], errors="coerce").dt.tz_localize(
136
+ None
137
+ )
136
138
  temp_df["open"] = pd.to_numeric(temp_df["open"], errors="coerce")
137
139
  temp_df["high"] = pd.to_numeric(temp_df["high"], errors="coerce")
138
140
  temp_df["low"] = pd.to_numeric(temp_df["low"], errors="coerce")
139
141
  temp_df["close"] = pd.to_numeric(temp_df["close"], errors="coerce")
140
142
  temp_df["volume"] = pd.to_numeric(temp_df["volume"], errors="coerce")
143
+
144
+ # 转换日期列为日期类型
145
+ temp_df["date"] = temp_df["date"].dt.date
146
+ temp_df = temp_df.sort_values(by="date", ascending=True)
141
147
  return temp_df
142
148
 
143
149
 
150
+ def fund_etf_dividend_sina(symbol: str = "sh510050") -> pd.DataFrame:
151
+ """
152
+ 新浪财经-基金-ETF 基金-累计分红
153
+ https://finance.sina.com.cn/fund/quotes/510050/bc.shtml
154
+ :param symbol: 基金名称, 可以通过 ak.fund_etf_category_sina() 函数获取
155
+ :type symbol: str
156
+ :return: 累计分红
157
+ :rtype: pandas.DataFrame
158
+ """
159
+ # 构建复权数据URL
160
+ factor_url = f"https://finance.sina.com.cn/realstock/company/{symbol}/hfq.js"
161
+ r = requests.get(factor_url)
162
+ text = r.text
163
+ if text.startswith("var"):
164
+ json_str = text.split("=")[1].strip().rsplit("}", maxsplit=1)[0].strip()
165
+ data = eval(json_str + "}") # 这里使用eval而不是json.loads因为数据格式特殊
166
+
167
+ if isinstance(data, dict) and "data" in data:
168
+ df = pd.DataFrame(data["data"])
169
+ # 重命名列
170
+ df.columns = ["date", "f", "s", "u"] if len(df.columns) == 4 else df.columns
171
+ # 移除1900-01-01的数据
172
+ df = df[df["date"] != "1900-01-01"]
173
+ # 转换日期
174
+ df["date"] = pd.to_datetime(df["date"])
175
+ # 转换数值类型
176
+ df[["f", "s", "u"]] = df[["f", "s", "u"]].astype(float)
177
+ # 按日期排序
178
+ df = df.sort_values("date", ascending=True, ignore_index=True)
179
+ temp_df = df[["date", "u"]].copy()
180
+ temp_df.columns = ["日期", "累计分红"]
181
+ temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
182
+ return temp_df
183
+
184
+
144
185
  if __name__ == "__main__":
145
186
  fund_etf_category_sina_df = fund_etf_category_sina(symbol="封闭式基金")
146
187
  print(fund_etf_category_sina_df)
@@ -156,3 +197,6 @@ if __name__ == "__main__":
156
197
 
157
198
  fund_etf_hist_sina_df = fund_etf_hist_sina(symbol="sh510300")
158
199
  print(fund_etf_hist_sina_df)
200
+
201
+ fund_etf_dividend_sina_df = fund_etf_dividend_sina(symbol="sh510050")
202
+ print(fund_etf_dividend_sina_df)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: akshare
3
- Version: 1.15.65
3
+ Version: 1.15.66
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=2qstXg3C_yb_TtnipqCfJFipnBWoBe2gFA32K-N7LWQ,185559
1
+ akshare/__init__.py,sha256=W-0PqOedEFTzY7utCqr6lS4ENUQq4SA6SaYtQtJ9-5o,185637
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
@@ -87,7 +87,7 @@ akshare/fund/fund_announcement.py,sha256=g5rcIC9vQ4HapZd0b7cDbFYzHu9V6bOKhwxRHVf
87
87
  akshare/fund/fund_aum_em.py,sha256=dy1R1-0X48H8S-LPiuggNA5M-6MvQ08fnp5bytvCGPQ,3518
88
88
  akshare/fund/fund_em.py,sha256=nX0VA5JeiF-zRr1J10X-U9-pJj5KFDUAbovN1DWjvTo,40450
89
89
  akshare/fund/fund_etf_em.py,sha256=oEPVCg-CQvOfLS7bt69yshqPiUPbxDpWa-FnMF7GqIQ,17386
90
- akshare/fund/fund_etf_sina.py,sha256=3eYnpug02oSZfR6fuWsT5mZRMRNm39VYCLHKnWdvonM,5218
90
+ akshare/fund/fund_etf_sina.py,sha256=YV2KrqKMF_h8kgrywvWvRJx2oy62lhgizvHFk40E4Rk,7042
91
91
  akshare/fund/fund_etf_ths.py,sha256=vb_jy0h2-Kz2dNWUrwBYxPB0MAotv0KZgnFhE98ohSM,3432
92
92
  akshare/fund/fund_fee_em.py,sha256=rkA2qVEhuWBUTFlvEP-zY_4Fw7_vL9cDx9hR-P38yDk,4157
93
93
  akshare/fund/fund_fhsp_em.py,sha256=-zSwwveiCB4HHRxwAuaLDTQHmNe3FxwxxeoPeiG8JbM,5546
@@ -378,8 +378,8 @@ akshare/utils/token_process.py,sha256=K4rGXjh_tgugbRcyOK2h2x0jP3PT65IIK7nxhUKhOe
378
378
  akshare/utils/tqdm.py,sha256=MuPNwcswkOGjwWQOMWXi9ZvQ_RmW4obCWRj2i7HM7FE,847
379
379
  tests/__init__.py,sha256=gNzhlO0UPjFq6Ieb38kaVIODXv4cTDByrdohAZnDYt4,82
380
380
  tests/test_func.py,sha256=j1MGYbZI2if2j_LY1S4FLsf4qfq4NwVqD5wmRlv5Log,832
381
- akshare-1.15.65.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
382
- akshare-1.15.65.dist-info/METADATA,sha256=Ny5RQMqJZ7-zwbDQqyJD8VpfNAy9YGK9grHwgk0g3_k,13423
383
- akshare-1.15.65.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
384
- akshare-1.15.65.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
385
- akshare-1.15.65.dist-info/RECORD,,
381
+ akshare-1.15.66.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
382
+ akshare-1.15.66.dist-info/METADATA,sha256=_KY49PPY1WCkGJIqVLl35Brda6xP5cSjQmQZGvcTlY8,13423
383
+ akshare-1.15.66.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
384
+ akshare-1.15.66.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
385
+ akshare-1.15.66.dist-info/RECORD,,