akshare 1.12.95__py3-none-any.whl → 1.15.72__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.

Files changed (240) hide show
  1. akshare/__init__.py +446 -139
  2. akshare/air/air_hebei.py +79 -53
  3. akshare/air/air_zhenqi.py +29 -43
  4. akshare/air/sunrise_tad.py +32 -17
  5. akshare/bank/bank_cbirc_2020.py +12 -9
  6. akshare/bond/bond_cb_ths.py +17 -9
  7. akshare/bond/bond_china.py +38 -39
  8. akshare/bond/bond_china_money.py +75 -48
  9. akshare/bond/bond_convert.py +40 -16
  10. akshare/bond/bond_info_cm.py +28 -8
  11. akshare/bond/bond_issue_cninfo.py +73 -30
  12. akshare/bond/{bond_zh_cov_sina.py → bond_zh_cov.py} +41 -17
  13. akshare/bond/bond_zh_sina.py +57 -51
  14. akshare/cal/__init__.py +0 -0
  15. akshare/cal/rv.py +170 -0
  16. akshare/cost/cost_living.py +7 -5
  17. akshare/currency/currency_safe.py +7 -6
  18. akshare/data/cninfo.js +15 -0
  19. akshare/datasets.py +10 -21
  20. akshare/economic/macro_bank.py +95 -653
  21. akshare/economic/macro_china.py +772 -1024
  22. akshare/economic/macro_china_hk.py +65 -243
  23. akshare/economic/macro_china_nbs.py +24 -7
  24. akshare/economic/macro_constitute.py +17 -12
  25. akshare/economic/macro_euro.py +13 -6
  26. akshare/economic/macro_finance_ths.py +133 -0
  27. akshare/economic/macro_info_ws.py +100 -0
  28. akshare/economic/macro_japan.py +5 -4
  29. akshare/economic/macro_other.py +12 -9
  30. akshare/economic/macro_usa.py +376 -1940
  31. akshare/economic/marco_cnbs.py +11 -6
  32. akshare/energy/energy_carbon.py +94 -125
  33. akshare/event/migration.py +3 -2
  34. akshare/exceptions.py +43 -0
  35. akshare/file_fold/calendar.json +245 -2
  36. akshare/fortune/fortune_500.py +15 -48
  37. akshare/fund/fund_amac.py +157 -75
  38. akshare/fund/fund_em.py +191 -184
  39. akshare/fund/fund_etf_em.py +20 -19
  40. akshare/fund/fund_etf_sina.py +71 -23
  41. akshare/fund/fund_etf_ths.py +93 -0
  42. akshare/fund/fund_fee_em.py +98 -0
  43. akshare/fund/fund_lof_em.py +10 -8
  44. akshare/fund/fund_portfolio_em.py +60 -50
  45. akshare/fund/fund_rank_em.py +91 -82
  46. akshare/fund/fund_report_cninfo.py +63 -48
  47. akshare/fund/fund_scale_sina.py +20 -10
  48. akshare/fund/fund_xq.py +139 -109
  49. akshare/futures/cons.py +8 -31
  50. akshare/futures/cot.py +185 -137
  51. akshare/futures/futures_basis.py +97 -32
  52. akshare/futures/futures_comm_ctp.py +37 -0
  53. akshare/futures/futures_comm_qihuo.py +74 -45
  54. akshare/futures/futures_daily_bar.py +121 -184
  55. akshare/futures/futures_hf_em.py +66 -61
  56. akshare/futures/futures_hq_sina.py +79 -61
  57. akshare/futures/futures_index_ccidx.py +6 -3
  58. akshare/futures/futures_inventory_99.py +61 -272
  59. akshare/futures/futures_news_shmet.py +4 -2
  60. akshare/futures/futures_roll_yield.py +12 -25
  61. akshare/futures/futures_spot_stock_em.py +19 -13
  62. akshare/futures/futures_stock_js.py +14 -12
  63. akshare/futures/futures_to_spot.py +38 -33
  64. akshare/futures/futures_warehouse_receipt.py +75 -71
  65. akshare/futures/futures_zh_sina.py +73 -50
  66. akshare/futures/symbol_var.py +18 -13
  67. akshare/futures_derivative/futures_contract_info_czce.py +60 -52
  68. akshare/futures_derivative/futures_contract_info_ine.py +43 -34
  69. akshare/futures_derivative/futures_contract_info_shfe.py +46 -35
  70. akshare/futures_derivative/futures_cot_sina.py +26 -19
  71. akshare/futures_derivative/futures_spot_sys.py +21 -8
  72. akshare/fx/currency_investing.py +19 -285
  73. akshare/index/index_cflp.py +29 -26
  74. akshare/index/index_cni.py +86 -88
  75. akshare/index/index_cons.py +26 -10
  76. akshare/index/index_cx.py +248 -47
  77. akshare/index/index_drewry.py +17 -16
  78. akshare/index/index_hog.py +27 -26
  79. akshare/index/index_option_qvix.py +329 -0
  80. akshare/index/index_research_fund_sw.py +134 -0
  81. akshare/index/{index_sw_research.py → index_research_sw.py} +122 -58
  82. akshare/index/index_spot.py +9 -5
  83. akshare/index/index_stock_hk.py +35 -16
  84. akshare/index/index_stock_us_sina.py +1 -1
  85. akshare/index/index_stock_zh.py +180 -89
  86. akshare/index/index_stock_zh_csindex.py +15 -369
  87. akshare/index/index_sw.py +62 -34
  88. akshare/index/index_yw.py +46 -23
  89. akshare/index/index_zh_a_scope.py +48 -0
  90. akshare/index/index_zh_em.py +17 -14
  91. akshare/interest_rate/interbank_rate_em.py +14 -9
  92. akshare/movie/artist_yien.py +32 -5
  93. akshare/movie/movie_yien.py +92 -18
  94. akshare/movie/video_yien.py +28 -5
  95. akshare/news/news_baidu.py +78 -44
  96. akshare/news/news_cctv.py +38 -38
  97. akshare/news/news_stock.py +6 -3
  98. akshare/nlp/nlp_interface.py +7 -8
  99. akshare/option/cons.py +11 -11
  100. akshare/option/option_comm_qihuo.py +86 -0
  101. akshare/option/option_commodity.py +178 -51
  102. akshare/option/option_daily_stats_sse_szse.py +146 -0
  103. akshare/option/option_em.py +147 -138
  104. akshare/option/option_finance_sina.py +160 -137
  105. akshare/option/option_lhb_em.py +62 -56
  106. akshare/option/option_risk_indicator_sse.py +17 -14
  107. akshare/other/other_car_cpca.py +934 -0
  108. akshare/other/{other_car.py → other_car_gasgoo.py} +15 -54
  109. akshare/qdii/__init__.py +0 -0
  110. akshare/qdii/qdii_jsl.py +233 -0
  111. akshare/request.py +117 -0
  112. akshare/spot/spot_hog_soozhu.py +232 -0
  113. akshare/spot/spot_price_qh.py +121 -0
  114. akshare/spot/spot_sge.py +63 -10
  115. akshare/stock/stock_allotment_cninfo.py +10 -9
  116. akshare/stock/stock_ask_bid_em.py +27 -3
  117. akshare/stock/stock_board_concept_em.py +23 -14
  118. akshare/stock/stock_board_industry_em.py +40 -34
  119. akshare/stock/stock_cg_equity_mortgage.py +15 -11
  120. akshare/stock/stock_cg_guarantee.py +41 -51
  121. akshare/stock/stock_cg_lawsuit.py +36 -35
  122. akshare/stock/stock_dividend_cninfo.py +12 -6
  123. akshare/stock/stock_dzjy_em.py +347 -260
  124. akshare/stock/stock_fund_em.py +332 -84
  125. akshare/stock/stock_hk_famous.py +108 -0
  126. akshare/stock/stock_hk_sina.py +8 -7
  127. akshare/stock/stock_hold_control_cninfo.py +100 -15
  128. akshare/stock/stock_hold_control_em.py +4 -3
  129. akshare/stock/stock_hold_num_cninfo.py +18 -12
  130. akshare/stock/stock_hot_rank_em.py +2 -1
  131. akshare/stock/stock_hot_search_baidu.py +5 -2
  132. akshare/stock/stock_industry_cninfo.py +24 -18
  133. akshare/stock/stock_industry_pe_cninfo.py +45 -31
  134. akshare/stock/stock_industry_sw.py +9 -10
  135. akshare/stock/stock_info.py +25 -15
  136. akshare/stock/stock_info_em.py +5 -2
  137. akshare/stock/stock_intraday_em.py +5 -2
  138. akshare/stock/stock_intraday_sina.py +22 -18
  139. akshare/stock/stock_ipo_summary_cninfo.py +25 -10
  140. akshare/stock/stock_new_cninfo.py +32 -19
  141. akshare/stock/stock_news_cx.py +39 -0
  142. akshare/stock/stock_profile_cninfo.py +9 -8
  143. akshare/stock/stock_rank_forecast.py +8 -6
  144. akshare/stock/stock_share_changes_cninfo.py +18 -14
  145. akshare/stock/stock_share_hold.py +24 -19
  146. akshare/stock/stock_summary.py +54 -26
  147. akshare/stock/stock_us_famous.py +15 -6
  148. akshare/stock/stock_us_pink.py +7 -5
  149. akshare/stock/stock_us_sina.py +15 -12
  150. akshare/stock/stock_xq.py +38 -12
  151. akshare/stock/stock_zh_a_sina.py +53 -78
  152. akshare/stock/stock_zh_b_sina.py +32 -55
  153. akshare/stock/stock_zh_kcb_report.py +11 -9
  154. akshare/stock/stock_zh_kcb_sina.py +67 -64
  155. akshare/stock_feature/stock_a_below_net_asset_statistics.py +5 -2
  156. akshare/stock_feature/stock_a_high_low.py +5 -2
  157. akshare/stock_feature/stock_a_indicator.py +12 -9
  158. akshare/stock_feature/stock_a_pe_and_pb.py +27 -6
  159. akshare/stock_feature/stock_account_em.py +58 -40
  160. akshare/stock_feature/stock_analyst_em.py +36 -27
  161. akshare/stock_feature/stock_board_industry_ths.py +136 -400
  162. akshare/stock_feature/stock_comment_em.py +118 -85
  163. akshare/stock_feature/stock_concept_futu.py +183 -0
  164. akshare/stock_feature/stock_cyq_em.py +58 -54
  165. akshare/stock_feature/stock_disclosure_cninfo.py +147 -102
  166. akshare/stock_feature/stock_esg_sina.py +216 -11
  167. akshare/stock_feature/stock_fhps_em.py +60 -25
  168. akshare/stock_feature/stock_fhps_ths.py +25 -6
  169. akshare/stock_feature/stock_fund_flow.py +38 -25
  170. akshare/stock_feature/stock_gdfx_em.py +180 -95
  171. akshare/stock_feature/stock_gdhs.py +73 -49
  172. akshare/stock_feature/stock_gpzy_em.py +78 -46
  173. akshare/stock_feature/stock_hist_em.py +164 -111
  174. akshare/stock_feature/stock_hk_valuation_baidu.py +20 -8
  175. akshare/stock_feature/stock_hsgt_em.py +184 -452
  176. akshare/stock_feature/stock_info.py +52 -29
  177. akshare/stock_feature/stock_inner_trade_xq.py +39 -31
  178. akshare/stock_feature/stock_irm_cninfo.py +32 -9
  179. akshare/stock_feature/stock_jgdy_em.py +41 -38
  180. akshare/stock_feature/stock_lh_yybpm.py +36 -37
  181. akshare/stock_feature/stock_lhb_em.py +135 -71
  182. akshare/stock_feature/stock_lhb_sina.py +93 -46
  183. akshare/stock_feature/stock_margin_em.py +102 -0
  184. akshare/stock_feature/{stock_sse_margin.py → stock_margin_sse.py} +21 -15
  185. akshare/stock_feature/{stock_szse_margin.py → stock_margin_szse.py} +23 -19
  186. akshare/stock_feature/stock_market_legu.py +13 -8
  187. akshare/stock_feature/stock_pankou_em.py +72 -34
  188. akshare/stock_feature/stock_report_em.py +244 -54
  189. akshare/stock_feature/stock_research_report_em.py +48 -19
  190. akshare/stock_feature/stock_sns_sseinfo.py +15 -12
  191. akshare/stock_feature/stock_sy_em.py +86 -33
  192. akshare/stock_feature/stock_technology_ths.py +152 -120
  193. akshare/stock_feature/stock_tfp_em.py +35 -13
  194. akshare/stock_feature/stock_three_report_em.py +119 -77
  195. akshare/stock_feature/stock_ttm_lyr.py +4 -7
  196. akshare/stock_feature/stock_value_em.py +83 -0
  197. akshare/stock_feature/stock_wencai.py +21 -9
  198. akshare/stock_feature/stock_yjyg_em.py +63 -28
  199. akshare/stock_feature/stock_zf_pg.py +61 -38
  200. akshare/stock_feature/stock_zh_valuation_baidu.py +3 -2
  201. akshare/stock_feature/stock_ztb_em.py +62 -40
  202. akshare/stock_fundamental/stock_finance.py +150 -58
  203. akshare/stock_fundamental/stock_finance_ths.py +116 -31
  204. akshare/stock_fundamental/stock_mda_ym.py +5 -3
  205. akshare/stock_fundamental/stock_notice.py +29 -15
  206. akshare/stock_fundamental/stock_profit_forecast_em.py +31 -13
  207. akshare/stock_fundamental/stock_profit_forecast_ths.py +19 -10
  208. akshare/stock_fundamental/stock_register_em.py +448 -0
  209. akshare/stock_fundamental/stock_restricted_em.py +79 -32
  210. akshare/stock_fundamental/stock_zygc.py +10 -8
  211. akshare/stock_fundamental/stock_zyjs_ths.py +5 -3
  212. akshare/tool/trade_date_hist.py +4 -3
  213. akshare/utils/cons.py +10 -0
  214. akshare/utils/context.py +43 -0
  215. akshare/utils/demjson.py +2 -2
  216. akshare/utils/func.py +26 -0
  217. akshare/utils/tqdm.py +13 -3
  218. {akshare-1.12.95.dist-info → akshare-1.15.72.dist-info}/METADATA +52 -69
  219. akshare-1.15.72.dist-info/RECORD +385 -0
  220. {akshare-1.12.95.dist-info → akshare-1.15.72.dist-info}/WHEEL +1 -1
  221. tests/test_func.py +3 -5
  222. akshare/bond/bond_futures.py +0 -50
  223. akshare/bond/bond_investing.py +0 -139
  224. akshare/crypto/crypto_hist_investing.py +0 -249
  225. akshare/fortune/fortune_it_juzi.py +0 -123
  226. akshare/futures/futures_international.py +0 -170
  227. akshare/futures/futures_news_baidu.py +0 -54
  228. akshare/futures/inventory_data.py +0 -100
  229. akshare/futures_derivative/futures_index_price_nh.py +0 -61
  230. akshare/futures_derivative/futures_index_return_nh.py +0 -47
  231. akshare/futures_derivative/futures_index_volatility_nh.py +0 -51
  232. akshare/futures_derivative/futures_other_index_nh.py +0 -145
  233. akshare/index/index_fear_greed_funddb.py +0 -71
  234. akshare/index/index_investing.py +0 -232
  235. akshare/sport/sport_olympic_winter.py +0 -39
  236. akshare/stock_feature/stock_board_concept_ths.py +0 -422
  237. akshare/stock_fundamental/stock_register.py +0 -292
  238. akshare-1.12.95.dist-info/RECORD +0 -374
  239. {akshare-1.12.95.dist-info → akshare-1.15.72.dist-info}/LICENSE +0 -0
  240. {akshare-1.12.95.dist-info → akshare-1.15.72.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2024/3/13 21:30
4
+ Date: 2024/3/26 17:30
5
5
  Desc: 东方财富-ETF行情
6
6
  https://quote.eastmoney.com/sh513500.html
7
7
  """
@@ -35,7 +35,7 @@ def _fund_etf_code_id_map_em() -> dict:
35
35
  "fields": "f12,f13",
36
36
  "_": "1672806290972",
37
37
  }
38
- r = requests.get(url, params=params)
38
+ r = requests.get(url, timeout=15, params=params)
39
39
  data_json = r.json()
40
40
  temp_df = pd.DataFrame(data_json["data"]["diff"])
41
41
  temp_dict = dict(zip(temp_df["f12"], temp_df["f13"]))
@@ -60,7 +60,7 @@ def fund_etf_spot_em() -> pd.DataFrame:
60
60
  "invt": "2",
61
61
  "wbp2u": "|0|0|0|web",
62
62
  "fid": "f3",
63
- "fs": "b:MK0021,b:MK0022,b:MK0023,b:MK0024",
63
+ "fs": "b:MK0021,b:MK0022,b:MK0023,b:MK0024,b:MK0827",
64
64
  "fields": (
65
65
  "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,"
66
66
  "f12,f13,f14,f15,f16,f17,f18,f20,f21,"
@@ -71,7 +71,7 @@ def fund_etf_spot_em() -> pd.DataFrame:
71
71
  ),
72
72
  "_": "1672806290972",
73
73
  }
74
- r = requests.get(url, params=params)
74
+ r = requests.get(url, timeout=15, params=params)
75
75
  data_json = r.json()
76
76
  temp_df = pd.DataFrame(data_json["data"]["diff"])
77
77
  temp_df.rename(
@@ -110,7 +110,7 @@ def fund_etf_spot_em() -> pd.DataFrame:
110
110
  "f21": "流通市值",
111
111
  "f20": "总市值",
112
112
  "f402": "基金折价率",
113
- "f441": "实时估值",
113
+ "f441": "IOPV实时估值",
114
114
  "f297": "数据日期",
115
115
  "f124": "更新时间",
116
116
  },
@@ -121,7 +121,7 @@ def fund_etf_spot_em() -> pd.DataFrame:
121
121
  "代码",
122
122
  "名称",
123
123
  "最新价",
124
- "实时估值",
124
+ "IOPV实时估值",
125
125
  "基金折价率",
126
126
  "涨跌额",
127
127
  "涨跌幅",
@@ -158,7 +158,6 @@ def fund_etf_spot_em() -> pd.DataFrame:
158
158
  ]
159
159
  ]
160
160
  temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
161
- temp_df["实时估值"] = pd.to_numeric(temp_df["实时估值"], errors="coerce")
162
161
  temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"], errors="coerce")
163
162
  temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"], errors="coerce")
164
163
  temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
@@ -179,6 +178,7 @@ def fund_etf_spot_em() -> pd.DataFrame:
179
178
  temp_df["买一"] = pd.to_numeric(temp_df["买一"], errors="coerce")
180
179
  temp_df["卖一"] = pd.to_numeric(temp_df["卖一"], errors="coerce")
181
180
  temp_df["最新份额"] = pd.to_numeric(temp_df["最新份额"], errors="coerce")
181
+ temp_df["IOPV实时估值"] = pd.to_numeric(temp_df["IOPV实时估值"], errors="coerce")
182
182
  temp_df["基金折价率"] = pd.to_numeric(temp_df["基金折价率"], errors="coerce")
183
183
  temp_df["主力净流入-净额"] = pd.to_numeric(
184
184
  temp_df["主力净流入-净额"], errors="coerce"
@@ -262,17 +262,17 @@ def fund_etf_hist_em(
262
262
  try:
263
263
  market_id = code_id_dict[symbol]
264
264
  params.update({"secid": f"{market_id}.{symbol}"})
265
- r = requests.get(url, params=params)
265
+ r = requests.get(url, timeout=15, params=params)
266
266
  data_json = r.json()
267
267
  except KeyError:
268
268
  market_id = 1
269
269
  params.update({"secid": f"{market_id}.{symbol}"})
270
- r = requests.get(url, params=params)
270
+ r = requests.get(url, timeout=15, params=params)
271
271
  data_json = r.json()
272
272
  if not data_json["data"]:
273
273
  market_id = 0
274
274
  params.update({"secid": f"{market_id}.{symbol}"})
275
- r = requests.get(url, params=params)
275
+ r = requests.get(url, timeout=15, params=params)
276
276
  data_json = r.json()
277
277
  if not (data_json["data"] and data_json["data"]["klines"]):
278
278
  return pd.DataFrame()
@@ -337,6 +337,7 @@ def fund_etf_hist_min_em(
337
337
  "159985": "0",
338
338
  "511090": "1",
339
339
  "511220": "1",
340
+ "511380": "1",
340
341
  }
341
342
  )
342
343
  adjust_map = {
@@ -355,7 +356,7 @@ def fund_etf_hist_min_em(
355
356
  "secid": f"{code_id_dict[symbol]}.{symbol}",
356
357
  "_": "1623766962675",
357
358
  }
358
- r = requests.get(url, params=params)
359
+ r = requests.get(url, timeout=15, params=params)
359
360
  data_json = r.json()
360
361
  temp_df = pd.DataFrame(
361
362
  [item.split(",") for item in data_json["data"]["trends"]]
@@ -368,7 +369,7 @@ def fund_etf_hist_min_em(
368
369
  "最低",
369
370
  "成交量",
370
371
  "成交额",
371
- "最新价",
372
+ "均价",
372
373
  ]
373
374
  temp_df.index = pd.to_datetime(temp_df["时间"])
374
375
  temp_df = temp_df[start_date:end_date]
@@ -379,7 +380,7 @@ def fund_etf_hist_min_em(
379
380
  temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce")
380
381
  temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
381
382
  temp_df["成交额"] = pd.to_numeric(temp_df["成交额"], errors="coerce")
382
- temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
383
+ temp_df["均价"] = pd.to_numeric(temp_df["均价"], errors="coerce")
383
384
  temp_df["时间"] = pd.to_datetime(temp_df["时间"]).astype(str)
384
385
  return temp_df
385
386
  else:
@@ -395,7 +396,7 @@ def fund_etf_hist_min_em(
395
396
  "end": "20500000",
396
397
  "_": "1630930917857",
397
398
  }
398
- r = requests.get(url, params=params)
399
+ r = requests.get(url, timeout=15, params=params)
399
400
  data_json = r.json()
400
401
  temp_df = pd.DataFrame(
401
402
  [item.split(",") for item in data_json["data"]["klines"]]
@@ -477,10 +478,10 @@ if __name__ == "__main__":
477
478
  print(fund_etf_hist_em_df)
478
479
 
479
480
  fund_etf_hist_min_em_df = fund_etf_hist_min_em(
480
- symbol="511220",
481
- period="5",
482
- adjust="hfq",
483
- start_date="2024-03-11 09:32:00",
484
- end_date="2024-03-11 17:40:00",
481
+ symbol="511380",
482
+ period="1",
483
+ adjust="",
484
+ start_date="2024-09-04 09:30:00",
485
+ end_date="2024-09-04 17:40:00",
485
486
  )
486
487
  print(fund_etf_hist_min_em_df)
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2022/2/15 17:33
4
+ Date: 2025/1/5 19:00
5
5
  Desc: 新浪财经-基金行情
6
- http://vip.stock.finance.sina.com.cn/fund_center/index.html#jjhqetf
6
+ https://vip.stock.finance.sina.com.cn/fund_center/index.html#jjhqetf
7
7
  """
8
+
8
9
  import pandas as pd
10
+ import py_mini_racer
9
11
  import requests
10
- from py_mini_racer import py_mini_racer
11
12
 
12
13
  from akshare.stock.cons import hk_js_decode
13
14
  from akshare.utils import demjson
@@ -27,10 +28,13 @@ def fund_etf_category_sina(symbol: str = "LOF基金") -> pd.DataFrame:
27
28
  "ETF基金": "etf_hq_fund",
28
29
  "LOF基金": "lof_hq_fund",
29
30
  }
30
- url = "http://vip.stock.finance.sina.com.cn/quotes_service/api/jsonp.php/IO.XSRV2.CallbackList['da_yPT46_Ll7K6WD']/Market_Center.getHQNodeDataSimple"
31
+ url = (
32
+ "https://vip.stock.finance.sina.com.cn/quotes_service/api/jsonp.php/"
33
+ "IO.XSRV2.CallbackList['da_yPT46_Ll7K6WD']/Market_Center.getHQNodeDataSimple"
34
+ )
31
35
  params = {
32
36
  "page": "1",
33
- "num": "1000",
37
+ "num": "5000",
34
38
  "sort": "symbol",
35
39
  "asc": "0",
36
40
  "node": fund_map[symbol],
@@ -95,21 +99,21 @@ def fund_etf_category_sina(symbol: str = "LOF基金") -> pd.DataFrame:
95
99
  "成交额",
96
100
  ]
97
101
  ]
98
- temp_df["最新价"] = pd.to_numeric(temp_df["最新价"])
99
- temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"])
100
- temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"])
101
- temp_df["买入"] = pd.to_numeric(temp_df["买入"])
102
- temp_df["卖出"] = pd.to_numeric(temp_df["卖出"])
103
- temp_df["昨收"] = pd.to_numeric(temp_df["昨收"])
104
- temp_df["今开"] = pd.to_numeric(temp_df["今开"])
105
- temp_df["最高"] = pd.to_numeric(temp_df["最高"])
106
- temp_df["最低"] = pd.to_numeric(temp_df["最低"])
107
- temp_df["成交量"] = pd.to_numeric(temp_df["成交量"])
108
- temp_df["成交额"] = pd.to_numeric(temp_df["成交额"])
102
+ temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
103
+ temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"], errors="coerce")
104
+ temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"], errors="coerce")
105
+ temp_df["买入"] = pd.to_numeric(temp_df["买入"], errors="coerce")
106
+ temp_df["卖出"] = pd.to_numeric(temp_df["卖出"], errors="coerce")
107
+ temp_df["昨收"] = pd.to_numeric(temp_df["昨收"], errors="coerce")
108
+ temp_df["今开"] = pd.to_numeric(temp_df["今开"], errors="coerce")
109
+ temp_df["最高"] = pd.to_numeric(temp_df["最高"], errors="coerce")
110
+ temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce")
111
+ temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
112
+ temp_df["成交额"] = pd.to_numeric(temp_df["成交额"], errors="coerce")
109
113
  return temp_df
110
114
 
111
115
 
112
- def fund_etf_hist_sina(symbol: str = "sz159996") -> pd.DataFrame:
116
+ def fund_etf_hist_sina(symbol: str = "sh510050") -> pd.DataFrame:
113
117
  """
114
118
  新浪财经-基金-ETF 基金-日行情数据
115
119
  https://finance.sina.com.cn/fund/quotes/159996/bc.shtml
@@ -128,15 +132,56 @@ def fund_etf_hist_sina(symbol: str = "sz159996") -> pd.DataFrame:
128
132
  temp_df = pd.DataFrame(dict_list)
129
133
  if temp_df.empty: # 处理获取数据为空的问题
130
134
  return pd.DataFrame()
131
- temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
132
- temp_df["open"] = pd.to_numeric(temp_df["open"])
133
- temp_df["high"] = pd.to_numeric(temp_df["high"])
134
- temp_df["low"] = pd.to_numeric(temp_df["low"])
135
- temp_df["close"] = pd.to_numeric(temp_df["close"])
136
- temp_df["volume"] = pd.to_numeric(temp_df["volume"])
135
+ temp_df["date"] = pd.to_datetime(temp_df["date"], errors="coerce").dt.tz_localize(
136
+ None
137
+ )
138
+ temp_df["open"] = pd.to_numeric(temp_df["open"], errors="coerce")
139
+ temp_df["high"] = pd.to_numeric(temp_df["high"], errors="coerce")
140
+ temp_df["low"] = pd.to_numeric(temp_df["low"], errors="coerce")
141
+ temp_df["close"] = pd.to_numeric(temp_df["close"], errors="coerce")
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)
137
147
  return temp_df
138
148
 
139
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
+
140
185
  if __name__ == "__main__":
141
186
  fund_etf_category_sina_df = fund_etf_category_sina(symbol="封闭式基金")
142
187
  print(fund_etf_category_sina_df)
@@ -152,3 +197,6 @@ if __name__ == "__main__":
152
197
 
153
198
  fund_etf_hist_sina_df = fund_etf_hist_sina(symbol="sh510300")
154
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)
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding:utf-8 -*-
3
+ """
4
+ Date: 2024/6/21 17:00
5
+ Desc: 同花顺理财-基金数据-每日净值-ETF
6
+ https://fund.10jqka.com.cn/datacenter/jz/kfs/etf/
7
+ """
8
+
9
+ import json
10
+
11
+ import pandas as pd
12
+ import requests
13
+
14
+
15
+ def fund_etf_spot_ths(date: str = "") -> pd.DataFrame:
16
+ """
17
+ 同花顺理财-基金数据-每日净值-ETF-实时行情
18
+ https://fund.10jqka.com.cn/datacenter/jz/kfs/etf/
19
+ :return: ETF 实时行情
20
+ :rtype: pandas.DataFrame
21
+ """
22
+ inner_date = "-".join([date[:4], date[4:6], date[6:]]) if date != "" else 0
23
+ url = f"https://fund.10jqka.com.cn/data/Net/info/ETF_rate_desc_{inner_date}_0_1_9999_0_0_0_jsonp_g.html"
24
+ r = requests.get(url, timeout=15)
25
+ data_text = r.text[2:-1]
26
+ data_json = json.loads(data_text)
27
+ temp_df = pd.DataFrame(data_json["data"]["data"]).T
28
+ temp_df.reset_index(inplace=True, drop=True)
29
+ temp_df.reset_index(inplace=True)
30
+ temp_df["index"] = temp_df["index"] + 1
31
+ temp_df.rename(
32
+ columns={
33
+ "index": "序号",
34
+ "code": "基金代码",
35
+ "typename": "基金类型",
36
+ "net": "当前-单位净值",
37
+ "name": "基金名称",
38
+ "totalnet": "当前-累计净值",
39
+ "newnet": "最新-单位净值",
40
+ "newtotalnet": "最新-累计净值",
41
+ "newdate": "最新-交易日",
42
+ "net1": "前一日-单位净值",
43
+ "totalnet1": "前一日-累计净值",
44
+ "ranges": "增长值",
45
+ "rate": "增长率",
46
+ "shstat": "赎回状态",
47
+ "sgstat": "申购状态",
48
+ },
49
+ inplace=True,
50
+ )
51
+ temp_df = temp_df[
52
+ [
53
+ "序号",
54
+ "基金代码",
55
+ "基金名称",
56
+ "当前-单位净值",
57
+ "当前-累计净值",
58
+ "前一日-单位净值",
59
+ "前一日-累计净值",
60
+ "增长值",
61
+ "增长率",
62
+ "赎回状态",
63
+ "申购状态",
64
+ "最新-交易日",
65
+ "最新-单位净值",
66
+ "最新-累计净值",
67
+ "基金类型",
68
+ ]
69
+ ]
70
+ query_date = inner_date if inner_date != 0 else temp_df["最新-交易日"][0]
71
+ temp_df["查询日期"] = query_date
72
+ temp_df["查询日期"] = pd.to_datetime(temp_df["查询日期"], errors="coerce").dt.date
73
+ temp_df["当前-单位净值"] = pd.to_numeric(temp_df["当前-单位净值"], errors="coerce")
74
+ temp_df["当前-累计净值"] = pd.to_numeric(temp_df["当前-累计净值"], errors="coerce")
75
+ temp_df["前一日-单位净值"] = pd.to_numeric(
76
+ temp_df["前一日-单位净值"], errors="coerce"
77
+ )
78
+ temp_df["前一日-累计净值"] = pd.to_numeric(
79
+ temp_df["前一日-累计净值"], errors="coerce"
80
+ )
81
+ temp_df["增长值"] = pd.to_numeric(temp_df["增长值"], errors="coerce")
82
+ temp_df["增长率"] = pd.to_numeric(temp_df["增长率"], errors="coerce")
83
+ temp_df["最新-单位净值"] = pd.to_numeric(temp_df["最新-单位净值"], errors="coerce")
84
+ temp_df["最新-累计净值"] = pd.to_numeric(temp_df["最新-累计净值"], errors="coerce")
85
+ temp_df["最新-交易日"] = pd.to_datetime(
86
+ temp_df["最新-交易日"], errors="coerce"
87
+ ).dt.date
88
+ return temp_df
89
+
90
+
91
+ if __name__ == "__main__":
92
+ fund_etf_spot_ths_df = fund_etf_spot_ths(date="20240620")
93
+ print(fund_etf_spot_ths_df)
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding:utf-8 -*-
3
+ """
4
+ Date: 2025/1/4 17:00
5
+ Desc: 天天基金-基金档案
6
+ https://fundf10.eastmoney.com/jjfl_015641.html
7
+ """
8
+
9
+ import requests
10
+ import pandas as pd
11
+ from io import StringIO
12
+
13
+
14
+ def fund_fee_em(symbol: str = "015641", indicator: str = "认购费率") -> pd.DataFrame:
15
+ """
16
+ 天天基金-基金档案-购买信息
17
+ https://fundf10.eastmoney.com/jjfl_015641.html
18
+ :param symbol: 基金代码
19
+ :type symbol: str
20
+ :param indicator: choice of {"交易状态", "申购与赎回金额", "交易确认日", "运作费用", "认购费率", "申购费率", "赎回费率"}
21
+ :type indicator: str
22
+ :return: 交易规则
23
+ :rtype: pandas.DataFrame
24
+ """
25
+ url = f"https://fundf10.eastmoney.com/jjfl_{symbol}.html"
26
+ r = requests.get(url)
27
+
28
+ if indicator == "交易状态":
29
+ temp_df = pd.read_html(StringIO(r.text))[1]
30
+ elif indicator == "申购与赎回金额":
31
+ temp_df_1 = pd.read_html(StringIO(r.text))[2]
32
+ temp_df_2 = pd.read_html(StringIO(r.text))[3]
33
+ temp_df = pd.concat(objs=[temp_df_1, temp_df_2], ignore_index=True)
34
+ elif indicator == "交易确认日":
35
+ temp_df = pd.read_html(StringIO(r.text))[4]
36
+ elif indicator == "运作费用":
37
+ temp_df = pd.read_html(StringIO(r.text))[5]
38
+ elif indicator == "认购费率":
39
+ temp_df = pd.read_html(StringIO(r.text))[6]
40
+ temp_df["原费率"] = temp_df["原费率|天天基金优惠费率"].str.split(
41
+ "|", expand=True
42
+ )[0]
43
+ temp_df["天天基金优惠费率"] = temp_df["原费率|天天基金优惠费率"].str.split(
44
+ "|", expand=True
45
+ )[1]
46
+ del temp_df["原费率|天天基金优惠费率"]
47
+ temp_df.loc[3, "天天基金优惠费率"] = temp_df.loc[3, "原费率"]
48
+ temp_df["原费率"] = temp_df["原费率"].str.strip()
49
+ temp_df["天天基金优惠费率"] = temp_df["天天基金优惠费率"].str.strip()
50
+ elif indicator == "申购费率":
51
+ temp_df = pd.read_html(StringIO(r.text))[7]
52
+ temp_df["原费率"] = temp_df[
53
+ "原费率|天天基金优惠费率 银行卡购买|活期宝购买"
54
+ ].str.split("|", expand=True)[0]
55
+ temp_df["天天基金优惠费率-银行卡购买"] = temp_df[
56
+ "原费率|天天基金优惠费率 银行卡购买|活期宝购买"
57
+ ].str.split("|", expand=True)[1]
58
+ temp_df["天天基金优惠费率-活期宝购买"] = temp_df[
59
+ "原费率|天天基金优惠费率 银行卡购买|活期宝购买"
60
+ ].str.split("|", expand=True)[2]
61
+ del temp_df["原费率|天天基金优惠费率 银行卡购买|活期宝购买"]
62
+ temp_df.loc[3, "天天基金优惠费率-银行卡购买"] = temp_df.loc[3, "原费率"]
63
+ temp_df.loc[3, "天天基金优惠费率-活期宝购买"] = temp_df.loc[3, "原费率"]
64
+ temp_df["原费率"] = temp_df["原费率"].str.strip()
65
+ temp_df["天天基金优惠费率-银行卡购买"] = temp_df[
66
+ "天天基金优惠费率-银行卡购买"
67
+ ].str.strip()
68
+ temp_df["天天基金优惠费率-活期宝购买"] = temp_df[
69
+ "天天基金优惠费率-活期宝购买"
70
+ ].str.strip()
71
+ elif indicator == "赎回费率":
72
+ temp_df = pd.read_html(StringIO(r.text))[8]
73
+ else:
74
+ temp_df = pd.DataFrame([])
75
+ return temp_df
76
+
77
+
78
+ if __name__ == "__main__":
79
+ fund_fee_em_df = fund_fee_em(symbol="015641", indicator="交易状态")
80
+ print(fund_fee_em_df)
81
+
82
+ fund_fee_em_df = fund_fee_em(symbol="015641", indicator="申购与赎回金额")
83
+ print(fund_fee_em_df)
84
+
85
+ fund_fee_em_df = fund_fee_em(symbol="015641", indicator="交易确认日")
86
+ print(fund_fee_em_df)
87
+
88
+ fund_fee_em_df = fund_fee_em(symbol="015641", indicator="运作费用")
89
+ print(fund_fee_em_df)
90
+
91
+ fund_fee_em_df = fund_fee_em(symbol="015641", indicator="认购费率")
92
+ print(fund_fee_em_df)
93
+
94
+ fund_fee_em_df = fund_fee_em(symbol="015641", indicator="申购费率")
95
+ print(fund_fee_em_df)
96
+
97
+ fund_fee_em_df = fund_fee_em(symbol="015641", indicator="赎回费率")
98
+ print(fund_fee_em_df)
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2023/7/3 20:18
4
+ Date: 2024/3/20 15:00
5
5
  Desc: 东方财富-LOF 行情
6
6
  https://quote.eastmoney.com/center/gridlist.html#fund_lof
7
7
  https://quote.eastmoney.com/sz166009.html
8
8
  """
9
+
9
10
  from functools import lru_cache
10
11
 
11
12
  import pandas as pd
@@ -61,7 +62,8 @@ def fund_lof_spot_em() -> pd.DataFrame:
61
62
  "wbp2u": "|0|0|0|web",
62
63
  "fid": "f3",
63
64
  "fs": "b:MK0404,b:MK0405,b:MK0406,b:MK0407",
64
- "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
65
+ "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,"
66
+ "f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
65
67
  "_": "1672806290972",
66
68
  }
67
69
  r = requests.get(url, params=params)
@@ -243,7 +245,7 @@ def fund_lof_hist_min_em(
243
245
  "最低",
244
246
  "成交量",
245
247
  "成交额",
246
- "最新价",
248
+ "均价",
247
249
  ]
248
250
  temp_df.index = pd.to_datetime(temp_df["时间"])
249
251
  temp_df = temp_df[start_date:end_date]
@@ -254,7 +256,7 @@ def fund_lof_hist_min_em(
254
256
  temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce")
255
257
  temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
256
258
  temp_df["成交额"] = pd.to_numeric(temp_df["成交额"], errors="coerce")
257
- temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
259
+ temp_df["均价"] = pd.to_numeric(temp_df["均价"], errors="coerce")
258
260
  temp_df["时间"] = pd.to_datetime(temp_df["时间"]).astype(str)
259
261
  return temp_df
260
262
  else:
@@ -353,9 +355,9 @@ if __name__ == "__main__":
353
355
 
354
356
  fund_lof_hist_min_em_df = fund_lof_hist_min_em(
355
357
  symbol="166009",
356
- period="5",
357
- adjust="hfq",
358
- start_date="2023-07-01 09:32:00",
359
- end_date="2023-07-04 14:40:00",
358
+ period="1",
359
+ adjust="",
360
+ start_date="2024-03-20 09:30:00",
361
+ end_date="2024-03-20 14:40:00",
360
362
  )
361
363
  print(fund_lof_hist_min_em_df)