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,19 +1,22 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2023/11/20 13:20
4
+ Date: 2024/11/2 15:20
5
5
  Desc: 同花顺-财务指标-主要指标
6
6
  https://basic.10jqka.com.cn/new/000063/finance.html
7
7
  """
8
+
8
9
  import json
9
10
 
10
11
  import pandas as pd
11
12
  import requests
12
13
  from bs4 import BeautifulSoup
13
14
 
15
+ from akshare.utils.cons import headers
16
+
14
17
 
15
18
  def stock_financial_abstract_ths(
16
- symbol: str = "000063", indicator: str = "按报告期"
19
+ symbol: str = "000063", indicator: str = "按报告期"
17
20
  ) -> pd.DataFrame:
18
21
  """
19
22
  同花顺-财务指标-主要指标
@@ -26,14 +29,9 @@ def stock_financial_abstract_ths(
26
29
  :rtype: pandas.DataFrame
27
30
  """
28
31
  url = f"https://basic.10jqka.com.cn/new/{symbol}/finance.html"
29
- headers = {
30
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
31
- "AppleWebKit/537.36 (KHTML, like Gecko) "
32
- "Chrome/89.0.4389.90 Safari/537.36",
33
- }
34
32
  r = requests.get(url, headers=headers)
35
- soup = BeautifulSoup(r.text, "lxml")
36
- data_text = soup.find("p", attrs={"id": "main"}).string
33
+ soup = BeautifulSoup(r.text, features="lxml")
34
+ data_text = soup.find(name="p", attrs={"id": "main"}).string
37
35
  data_json = json.loads(data_text)
38
36
  df_index = [
39
37
  item[0] if isinstance(item, list) else item for item in data_json["title"]
@@ -57,7 +55,7 @@ def stock_financial_abstract_ths(
57
55
 
58
56
 
59
57
  def stock_financial_debt_ths(
60
- symbol: str = "000063", indicator: str = "按报告期"
58
+ symbol: str = "000063", indicator: str = "按报告期"
61
59
  ) -> pd.DataFrame:
62
60
  """
63
61
  同花顺-财务指标-资产负债表
@@ -71,13 +69,8 @@ def stock_financial_debt_ths(
71
69
  :rtype: pandas.DataFrame
72
70
  """
73
71
  url = f"https://basic.10jqka.com.cn/api/stock/finance/{symbol}_debt.json"
74
- headers = {
75
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
76
- "AppleWebKit/537.36 (KHTML, like Gecko) "
77
- "Chrome/89.0.4389.90 Safari/537.36",
78
- }
79
72
  r = requests.get(url, headers=headers)
80
- data_json = json.loads(json.loads(r.text)['flashData'])
73
+ data_json = json.loads(json.loads(r.text)["flashData"])
81
74
  df_index = [
82
75
  item[0] if isinstance(item, list) else item for item in data_json["title"]
83
76
  ]
@@ -96,7 +89,7 @@ def stock_financial_debt_ths(
96
89
 
97
90
 
98
91
  def stock_financial_benefit_ths(
99
- symbol: str = "000063", indicator: str = "按报告期"
92
+ symbol: str = "000063", indicator: str = "按报告期"
100
93
  ) -> pd.DataFrame:
101
94
  """
102
95
  同花顺-财务指标-利润表
@@ -110,13 +103,8 @@ def stock_financial_benefit_ths(
110
103
  :rtype: pandas.DataFrame
111
104
  """
112
105
  url = f"https://basic.10jqka.com.cn/api/stock/finance/{symbol}_benefit.json"
113
- headers = {
114
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
115
- "AppleWebKit/537.36 (KHTML, like Gecko) "
116
- "Chrome/89.0.4389.90 Safari/537.36",
117
- }
118
106
  r = requests.get(url, headers=headers)
119
- data_json = json.loads(json.loads(r.text)['flashData'])
107
+ data_json = json.loads(json.loads(r.text)["flashData"])
120
108
  df_index = [
121
109
  item[0] if isinstance(item, list) else item for item in data_json["title"]
122
110
  ]
@@ -139,7 +127,7 @@ def stock_financial_benefit_ths(
139
127
 
140
128
 
141
129
  def stock_financial_cash_ths(
142
- symbol: str = "000063", indicator: str = "按报告期"
130
+ symbol: str = "000063", indicator: str = "按报告期"
143
131
  ) -> pd.DataFrame:
144
132
  """
145
133
  同花顺-财务指标-现金流量表
@@ -153,13 +141,8 @@ def stock_financial_cash_ths(
153
141
  :rtype: pandas.DataFrame
154
142
  """
155
143
  url = f"https://basic.10jqka.com.cn/api/stock/finance/{symbol}_cash.json"
156
- headers = {
157
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
158
- "AppleWebKit/537.36 (KHTML, like Gecko) "
159
- "Chrome/89.0.4389.90 Safari/537.36",
160
- }
161
144
  r = requests.get(url, headers=headers)
162
- data_json = json.loads(json.loads(r.text)['flashData'])
145
+ data_json = json.loads(json.loads(r.text)["flashData"])
163
146
  df_index = [
164
147
  item[0] if isinstance(item, list) else item for item in data_json["title"]
165
148
  ]
@@ -181,6 +164,102 @@ def stock_financial_cash_ths(
181
164
  return temp_df
182
165
 
183
166
 
167
+ def stock_management_change_ths(symbol: str = "688981") -> pd.DataFrame:
168
+ """
169
+ 同花顺-公司大事-高管持股变动
170
+ https://basic.10jqka.com.cn/new/688981/event.html
171
+ :param symbol: 股票代码
172
+ :type symbol: str
173
+ :return: 同花顺-公司大事-高管持股变动
174
+ :rtype: pandas.DataFrame
175
+ """
176
+ url = f"https://basic.10jqka.com.cn/new/{symbol}/event.html"
177
+ r = requests.get(url, headers=headers)
178
+ r.encoding = "gb2312"
179
+ soup = BeautifulSoup(r.text, features="lxml")
180
+ soup_find = soup.find(name="table", attrs={"class": "data_table_1 m_table m_hl"})
181
+ if soup_find is not None:
182
+ content_list = [item.text.strip() for item in soup_find]
183
+ column_names = content_list[1].split("\n")
184
+ row = (
185
+ content_list[3]
186
+ .replace(" ", "")
187
+ .replace("\t", "")
188
+ .replace("\n\n", "")
189
+ .replace(" ", "\n")
190
+ .replace("\n\n", "\n")
191
+ .split("\n")
192
+ )
193
+ row = [item for item in row if item != ""]
194
+ new_rows = []
195
+ step = len(column_names)
196
+ for i in range(0, len(row), step):
197
+ new_rows.append(row[i : i + step])
198
+ temp_df = pd.DataFrame(new_rows, columns=column_names)
199
+ temp_df.sort_values(by="变动日期", ignore_index=True, inplace=True)
200
+ temp_df["变动日期"] = pd.to_datetime(
201
+ temp_df["变动日期"], errors="coerce"
202
+ ).dt.date
203
+ temp_df.rename(
204
+ columns={
205
+ "变动数量(股)": "变动数量",
206
+ "交易均价(元)": "交易均价",
207
+ "剩余股数(股)": "剩余股数",
208
+ },
209
+ inplace=True,
210
+ )
211
+ return temp_df
212
+ return pd.DataFrame()
213
+
214
+
215
+ def stock_shareholder_change_ths(symbol: str = "688981") -> pd.DataFrame:
216
+ """
217
+ 同花顺-公司大事-股东持股变动
218
+ https://basic.10jqka.com.cn/new/688981/event.html
219
+ :param symbol: 股票代码
220
+ :type symbol: str
221
+ :return: 同花顺-公司大事-股东持股变动
222
+ :rtype: pandas.DataFrame
223
+ """
224
+ url = f"https://basic.10jqka.com.cn/new/{symbol}/event.html"
225
+ r = requests.get(url, headers=headers)
226
+ r.encoding = "gb2312"
227
+ soup = BeautifulSoup(r.text, features="lxml")
228
+ soup_find = soup.find(name="table", attrs={"class": "m_table data_table_1 m_hl"})
229
+ if soup_find is not None:
230
+ content_list = [item.text.strip() for item in soup_find]
231
+ column_names = content_list[1].split("\n")
232
+ row = (
233
+ content_list[3]
234
+ .replace("\t", "")
235
+ .replace("\n\n", "")
236
+ .replace(" ", "\n")
237
+ .replace(" ", "")
238
+ .replace("\n\n", "\n")
239
+ .split("\n")
240
+ )
241
+ row = [item for item in row if item != ""]
242
+ new_rows = []
243
+ step = len(column_names)
244
+ for i in range(0, len(row), step):
245
+ new_rows.append(row[i : i + step])
246
+ temp_df = pd.DataFrame(new_rows, columns=column_names)
247
+ temp_df.sort_values(by="公告日期", ignore_index=True, inplace=True)
248
+ temp_df["公告日期"] = pd.to_datetime(
249
+ temp_df["公告日期"], errors="coerce"
250
+ ).dt.date
251
+ temp_df.rename(
252
+ columns={
253
+ "变动数量(股)": "变动数量",
254
+ "交易均价(元)": "交易均价",
255
+ "剩余股份总数(股)": "剩余股份总数",
256
+ },
257
+ inplace=True,
258
+ )
259
+ return temp_df
260
+ return pd.DataFrame()
261
+
262
+
184
263
  if __name__ == "__main__":
185
264
  stock_financial_abstract_ths_df = stock_financial_abstract_ths(
186
265
  symbol="000063", indicator="按报告期"
@@ -198,7 +277,7 @@ if __name__ == "__main__":
198
277
  print(stock_financial_abstract_ths_df)
199
278
 
200
279
  stock_financial_debt_ths_df = stock_financial_debt_ths(
201
- symbol="000063", indicator="按报告期"
280
+ symbol="002004", indicator="按报告期"
202
281
  )
203
282
  print(stock_financial_debt_ths_df)
204
283
 
@@ -236,3 +315,9 @@ if __name__ == "__main__":
236
315
  symbol="000063", indicator="按单季度"
237
316
  )
238
317
  print(stock_financial_cash_ths_df)
318
+
319
+ stock_management_change_ths_df = stock_management_change_ths(symbol="688981")
320
+ print(stock_management_change_ths_df)
321
+
322
+ stock_shareholder_change_ths_df = stock_shareholder_change_ths(symbol="688981")
323
+ print(stock_shareholder_change_ths_df)
@@ -1,10 +1,11 @@
1
1
  # -*- coding:utf-8 -*-
2
2
  # !/usr/bin/env python
3
3
  """
4
- Date: 2024/2/14 12:30
4
+ Date: 2024/9/3 21:00
5
5
  Desc: 益盟-F10-管理层讨论与分析
6
6
  https://f10.emoney.cn/f10/zbyz/1000001
7
7
  """
8
+
8
9
  import pandas as pd
9
10
  import requests
10
11
  from bs4 import BeautifulSoup
@@ -21,7 +22,7 @@ def stock_mda_ym(symbol: str = "000001") -> pd.DataFrame:
21
22
  """
22
23
  url = f"http://f10.emoney.cn/f10/zygc/{symbol}"
23
24
  r = requests.get(url)
24
- soup = BeautifulSoup(r.text, "lxml")
25
+ soup = BeautifulSoup(r.text, features="lxml")
25
26
  year_list = [
26
27
  item.text.strip()
27
28
  for item in soup.find(attrs={"class": "swlab_t"}).find_all("li")
@@ -32,9 +33,10 @@ def stock_mda_ym(symbol: str = "000001") -> pd.DataFrame:
32
33
  ]
33
34
  big_df = pd.DataFrame([year_list, talk_list]).T
34
35
  big_df.columns = ["报告期", "内容"]
36
+ big_df.sort_values(by=["报告期"], ignore_index=True, inplace=True)
35
37
  return big_df
36
38
 
37
39
 
38
40
  if __name__ == "__main__":
39
- stock_mda_ym_df = stock_mda_ym(symbol="000002")
41
+ stock_mda_ym_df = stock_mda_ym(symbol="000001")
40
42
  print(stock_mda_ym_df)
@@ -1,19 +1,23 @@
1
1
  # -*- coding:utf-8 -*-
2
2
  # !/usr/bin/env python
3
3
  """
4
- Date: 2022/5/13 19:25
4
+ Date: 2024/6/13 13:00
5
5
  Desc: 东方财富网-数据中心-公告大全-沪深 A 股公告
6
- http://data.eastmoney.com/notices/hsa/5.html
6
+ https://data.eastmoney.com/notices/hsa/5.html
7
7
  """
8
+
9
+ import math
10
+
8
11
  import pandas as pd
9
12
  import requests
10
- from tqdm import tqdm
13
+
14
+ from akshare.utils.tqdm import get_tqdm
11
15
 
12
16
 
13
17
  def stock_notice_report(symbol: str = "全部", date: str = "20220511") -> pd.DataFrame:
14
18
  """
15
19
  东方财富网-数据中心-公告大全-沪深京 A 股公告
16
- http://data.eastmoney.com/notices/hsa/5.html
20
+ https://data.eastmoney.com/notices/hsa/5.html
17
21
  :param symbol: 报告类型; choice of {"全部", "重大事项", "财务报告", "融资公告", "风险提示", "资产重组", "信息变更", "持股变动"}
18
22
  :type symbol: str
19
23
  :param date: 制定日期
@@ -21,7 +25,7 @@ def stock_notice_report(symbol: str = "全部", date: str = "20220511") -> pd.Da
21
25
  :return: 沪深京 A 股公告
22
26
  :rtype: pandas.DataFrame
23
27
  """
24
- url = "http://np-anotice-stock.eastmoney.com/api/security/ann"
28
+ url = "https://np-anotice-stock.eastmoney.com/api/security/ann"
25
29
  report_map = {
26
30
  "全部": "0",
27
31
  "财务报告": "1",
@@ -45,11 +49,9 @@ def stock_notice_report(symbol: str = "全部", date: str = "20220511") -> pd.Da
45
49
  }
46
50
  r = requests.get(url, params=params)
47
51
  data_json = r.json()
48
- import math
49
-
50
52
  total_page = math.ceil(data_json["data"]["total_hits"] / 100)
51
-
52
53
  big_df = pd.DataFrame()
54
+ tqdm = get_tqdm()
53
55
  for page in tqdm(range(1, int(total_page) + 1), leave=False):
54
56
  params.update(
55
57
  {
@@ -66,16 +68,16 @@ def stock_notice_report(symbol: str = "全部", date: str = "20220511") -> pd.Da
66
68
  temp_columns_df = pd.DataFrame(
67
69
  [item["columns"][0] for item in data_json["data"]["list"]]
68
70
  )
69
- except:
71
+ except: # noqa: E722
70
72
  continue
71
73
  del temp_df["codes"]
72
74
  del temp_df["columns"]
73
- temp_df = pd.concat([temp_df, temp_columns_df, temp_codes_df], axis=1)
74
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
75
+ temp_df = pd.concat(objs=[temp_df, temp_columns_df, temp_codes_df], axis=1)
76
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
75
77
 
76
78
  big_df.rename(
77
79
  columns={
78
- "art_code": "_",
80
+ "art_code": "编码",
79
81
  "display_time": "-",
80
82
  "eiTime": "-",
81
83
  "notice_date": "公告日期",
@@ -90,6 +92,8 @@ def stock_notice_report(symbol: str = "全部", date: str = "20220511") -> pd.Da
90
92
  },
91
93
  inplace=True,
92
94
  )
95
+ url = "https://data.eastmoney.com/notices/detail/"
96
+ big_df["网址"] = url + big_df["代码"] + "/" + big_df["编码"] + ".html"
93
97
  big_df = big_df[
94
98
  [
95
99
  "代码",
@@ -97,17 +101,27 @@ def stock_notice_report(symbol: str = "全部", date: str = "20220511") -> pd.Da
97
101
  "公告标题",
98
102
  "公告类型",
99
103
  "公告日期",
104
+ "网址",
100
105
  ]
101
106
  ]
102
- big_df["公告日期"] = pd.to_datetime(big_df["公告日期"]).dt.date
107
+ big_df["公告日期"] = pd.to_datetime(big_df["公告日期"], errors="coerce").dt.date
103
108
  return big_df
104
109
 
105
110
 
106
111
  if __name__ == "__main__":
107
- stock_notice_report_df = stock_notice_report(symbol='财务报告', date="20220511")
112
+ stock_notice_report_df = stock_notice_report(symbol="财务报告", date="20240612")
108
113
  print(stock_notice_report_df)
109
114
 
110
- item_list = ["全部", "财务报告", "融资公告", "风险提示", "信息变更", "重大事项", "资产重组", "持股变动"]
115
+ item_list = [
116
+ "全部",
117
+ "财务报告",
118
+ "融资公告",
119
+ "风险提示",
120
+ "信息变更",
121
+ "重大事项",
122
+ "资产重组",
123
+ "持股变动",
124
+ ]
111
125
  for temp_item in item_list:
112
126
  stock_notice_report_df = stock_notice_report(symbol=temp_item, date="20220511")
113
127
  print(stock_notice_report_df)
@@ -5,6 +5,7 @@ Date: 2024/1/6 15:00
5
5
  Desc: 东方财富网-数据中心-研究报告-盈利预测
6
6
  https://data.eastmoney.com/report/profitforecast.jshtml
7
7
  """
8
+
8
9
  import pandas as pd
9
10
  import requests
10
11
 
@@ -15,7 +16,8 @@ def stock_profit_forecast_em(symbol: str = "") -> pd.DataFrame:
15
16
  """
16
17
  东方财富网-数据中心-研究报告-盈利预测
17
18
  https://data.eastmoney.com/report/profitforecast.jshtml
18
- :param symbol: "", 默认为获取全部数据; symbol="船舶制造", 则获取具体行业板块的数据; 行业板块可以通过 ak.stock_board_industry_name_em() 接口获取
19
+ :param symbol: "", 默认为获取全部数据; symbol="船舶制造", 则获取具体行业板块的数据;
20
+ 行业板块可以通过 ak.stock_board_industry_name_em() 接口获取
19
21
  :type symbol: str
20
22
  :return: 盈利预测
21
23
  :rtype: pandas.DataFrame
@@ -34,7 +36,6 @@ def stock_profit_forecast_em(symbol: str = "") -> pd.DataFrame:
34
36
  }
35
37
  if symbol:
36
38
  params.update({"filter": f'(INDUSTRY_BOARD="{symbol}")'})
37
-
38
39
  r = requests.get(url, params=params)
39
40
  data_json = r.json()
40
41
  page_num = int(data_json["result"]["pages"])
@@ -52,7 +53,7 @@ def stock_profit_forecast_em(symbol: str = "") -> pd.DataFrame:
52
53
  r = requests.get(url, params=params)
53
54
  data_json = r.json()
54
55
  temp_df = pd.DataFrame(data_json["result"]["data"])
55
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
56
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
56
57
 
57
58
  big_df.reset_index(inplace=True)
58
59
  big_df["index"] = big_df.index + 1
@@ -94,7 +95,6 @@ def stock_profit_forecast_em(symbol: str = "") -> pd.DataFrame:
94
95
  "_",
95
96
  "_",
96
97
  ]
97
-
98
98
  big_df = big_df[
99
99
  [
100
100
  "序号",
@@ -112,11 +112,12 @@ def stock_profit_forecast_em(symbol: str = "") -> pd.DataFrame:
112
112
  f"{year4}预测每股收益",
113
113
  ]
114
114
  ]
115
- big_df["机构投资评级(近六个月)-买入"].fillna(0, inplace=True)
116
- big_df["机构投资评级(近六个月)-增持"].fillna(0, inplace=True)
117
- big_df["机构投资评级(近六个月)-中性"].fillna(0, inplace=True)
118
- big_df["机构投资评级(近六个月)-减持"].fillna(0, inplace=True)
119
- big_df["机构投资评级(近六个月)-卖出"].fillna(0, inplace=True)
115
+ big_df["机构投资评级(近六个月)-买入"] = big_df[
116
+ "机构投资评级(近六个月)-买入"
117
+ ].fillna(0)
118
+ big_df["机构投资评级(近六个月)-增持"] = big_df[
119
+ "机构投资评级(近六个月)-增持"
120
+ ].fillna(0)
120
121
  big_df["研报数"] = pd.to_numeric(big_df["研报数"], errors="coerce")
121
122
  big_df["机构投资评级(近六个月)-买入"] = pd.to_numeric(
122
123
  big_df["机构投资评级(近六个月)-买入"], errors="coerce"
@@ -133,10 +134,27 @@ def stock_profit_forecast_em(symbol: str = "") -> pd.DataFrame:
133
134
  big_df["机构投资评级(近六个月)-卖出"] = pd.to_numeric(
134
135
  big_df["机构投资评级(近六个月)-卖出"], errors="coerce"
135
136
  )
136
- big_df[f"{year1}预测每股收益"] = pd.to_numeric(big_df[f"{year1}预测每股收益"], errors="coerce")
137
- big_df[f"{year2}预测每股收益"] = pd.to_numeric(big_df[f"{year2}预测每股收益"], errors="coerce")
138
- big_df[f"{year3}预测每股收益"] = pd.to_numeric(big_df[f"{year3}预测每股收益"], errors="coerce")
139
- big_df[f"{year4}预测每股收益"] = pd.to_numeric(big_df[f"{year4}预测每股收益"], errors="coerce")
137
+ big_df["机构投资评级(近六个月)-中性"] = big_df[
138
+ "机构投资评级(近六个月)-中性"
139
+ ].fillna(0)
140
+ big_df["机构投资评级(近六个月)-减持"] = big_df[
141
+ "机构投资评级(近六个月)-减持"
142
+ ].fillna(0)
143
+ big_df["机构投资评级(近六个月)-卖出"] = big_df[
144
+ "机构投资评级(近六个月)-卖出"
145
+ ].fillna(0)
146
+ big_df[f"{year1}预测每股收益"] = pd.to_numeric(
147
+ big_df[f"{year1}预测每股收益"], errors="coerce"
148
+ )
149
+ big_df[f"{year2}预测每股收益"] = pd.to_numeric(
150
+ big_df[f"{year2}预测每股收益"], errors="coerce"
151
+ )
152
+ big_df[f"{year3}预测每股收益"] = pd.to_numeric(
153
+ big_df[f"{year3}预测每股收益"], errors="coerce"
154
+ )
155
+ big_df[f"{year4}预测每股收益"] = pd.to_numeric(
156
+ big_df[f"{year4}预测每股收益"], errors="coerce"
157
+ )
140
158
  big_df.sort_values(["研报数"], ascending=False, inplace=True, ignore_index=True)
141
159
  big_df["序号"] = range(1, len(big_df) + 1)
142
160
  return big_df
@@ -1,13 +1,18 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2023/4/9 21:44
4
+ Date: 2024/8/28 15:00
5
5
  Desc: 同花顺-盈利预测
6
6
  https://basic.10jqka.com.cn/new/600519/worth.html
7
7
  """
8
+
9
+ from io import StringIO
10
+
8
11
  import pandas as pd
9
12
  import requests
10
13
 
14
+ from akshare.utils.cons import headers
15
+
11
16
 
12
17
  def stock_profit_forecast_ths(
13
18
  symbol: str = "600519", indicator: str = "预测年报每股收益"
@@ -23,21 +28,18 @@ def stock_profit_forecast_ths(
23
28
  :rtype: pandas.DataFrame
24
29
  """
25
30
  url = f"https://basic.10jqka.com.cn/new/{symbol}/worth.html"
26
- headers = {
27
- "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",
28
- }
29
31
  r = requests.get(url, headers=headers)
30
32
  r.encoding = "gbk"
31
33
  if indicator == "预测年报每股收益":
32
- temp_df = pd.read_html(r.text)[0]
34
+ temp_df = pd.read_html(StringIO(r.text))[0]
33
35
  temp_df["年度"] = temp_df["年度"].astype(str)
34
36
  return temp_df
35
37
  if indicator == "预测年报净利润":
36
- temp_df = pd.read_html(r.text)[1]
38
+ temp_df = pd.read_html(StringIO(r.text))[1]
37
39
  temp_df["年度"] = temp_df["年度"].astype(str)
38
40
  return temp_df
39
41
  if indicator == "业绩预测详表-机构":
40
- temp_df = pd.read_html(r.text)[2]
42
+ temp_df = pd.read_html(StringIO(r.text))[2]
41
43
  columns_list = []
42
44
  for item in temp_df.columns:
43
45
  columns_list.append(item[1])
@@ -51,7 +53,7 @@ def stock_profit_forecast_ths(
51
53
  temp_df["报告日期"] = pd.to_datetime(temp_df["报告日期"]).dt.date
52
54
  return temp_df
53
55
  if indicator == "业绩预测详表-详细指标预测":
54
- temp_df = pd.read_html(r.text)[3]
56
+ temp_df = pd.read_html(StringIO(r.text))[3]
55
57
  temp_df.columns = [
56
58
  item.replace("(", "-").replace(")", "") for item in temp_df.columns
57
59
  ]
@@ -59,6 +61,13 @@ def stock_profit_forecast_ths(
59
61
 
60
62
 
61
63
  if __name__ == "__main__":
62
- for item in ["预测年报每股收益", "预测年报净利润", "业绩预测详表-机构", "业绩预测详表-详细指标预测"]:
63
- stock_profit_forecast_ths_df = stock_profit_forecast_ths(symbol="600519", indicator=item)
64
+ for _item in [
65
+ "预测年报每股收益",
66
+ "预测年报净利润",
67
+ "业绩预测详表-机构",
68
+ "业绩预测详表-详细指标预测",
69
+ ]:
70
+ stock_profit_forecast_ths_df = stock_profit_forecast_ths(
71
+ symbol="600519", indicator=_item
72
+ )
64
73
  print(stock_profit_forecast_ths_df)