akshare 1.12.99__py3-none-any.whl → 1.15.73__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 (236) hide show
  1. akshare/__init__.py +442 -138
  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_info_cm.py +28 -8
  10. akshare/bond/bond_issue_cninfo.py +73 -30
  11. akshare/bond/bond_zh_cov.py +1 -1
  12. akshare/bond/bond_zh_sina.py +57 -51
  13. akshare/cal/__init__.py +0 -0
  14. akshare/cal/rv.py +170 -0
  15. akshare/cost/cost_living.py +7 -5
  16. akshare/currency/currency_safe.py +7 -6
  17. akshare/data/cninfo.js +15 -0
  18. akshare/datasets.py +10 -21
  19. akshare/economic/macro_bank.py +95 -653
  20. akshare/economic/macro_china.py +772 -1024
  21. akshare/economic/macro_china_hk.py +65 -243
  22. akshare/economic/macro_china_nbs.py +24 -7
  23. akshare/economic/macro_constitute.py +17 -12
  24. akshare/economic/macro_euro.py +13 -6
  25. akshare/economic/macro_finance_ths.py +133 -0
  26. akshare/economic/macro_info_ws.py +100 -0
  27. akshare/economic/macro_japan.py +5 -4
  28. akshare/economic/macro_other.py +12 -9
  29. akshare/economic/macro_usa.py +376 -1940
  30. akshare/economic/marco_cnbs.py +11 -6
  31. akshare/energy/energy_carbon.py +94 -125
  32. akshare/event/migration.py +3 -2
  33. akshare/exceptions.py +43 -0
  34. akshare/file_fold/calendar.json +245 -2
  35. akshare/fortune/fortune_500.py +15 -48
  36. akshare/fund/fund_amac.py +157 -75
  37. akshare/fund/fund_em.py +191 -184
  38. akshare/fund/fund_etf_em.py +16 -15
  39. akshare/fund/fund_etf_sina.py +71 -23
  40. akshare/fund/fund_etf_ths.py +93 -0
  41. akshare/fund/fund_fee_em.py +98 -0
  42. akshare/fund/fund_portfolio_em.py +60 -50
  43. akshare/fund/fund_rank_em.py +91 -82
  44. akshare/fund/fund_report_cninfo.py +63 -48
  45. akshare/fund/fund_scale_sina.py +20 -10
  46. akshare/fund/fund_xq.py +139 -109
  47. akshare/futures/cons.py +8 -31
  48. akshare/futures/cot.py +185 -137
  49. akshare/futures/futures_basis.py +97 -32
  50. akshare/futures/futures_comm_ctp.py +37 -0
  51. akshare/futures/futures_comm_qihuo.py +74 -45
  52. akshare/futures/futures_daily_bar.py +121 -184
  53. akshare/futures/futures_hf_em.py +66 -61
  54. akshare/futures/futures_hq_sina.py +79 -61
  55. akshare/futures/futures_index_ccidx.py +6 -3
  56. akshare/futures/futures_inventory_99.py +61 -272
  57. akshare/futures/futures_news_shmet.py +4 -2
  58. akshare/futures/futures_roll_yield.py +12 -25
  59. akshare/futures/futures_spot_stock_em.py +19 -13
  60. akshare/futures/futures_stock_js.py +14 -12
  61. akshare/futures/futures_to_spot.py +38 -33
  62. akshare/futures/futures_warehouse_receipt.py +75 -71
  63. akshare/futures/futures_zh_sina.py +5 -5
  64. akshare/futures/symbol_var.py +18 -13
  65. akshare/futures_derivative/futures_contract_info_czce.py +60 -52
  66. akshare/futures_derivative/futures_contract_info_ine.py +43 -34
  67. akshare/futures_derivative/futures_contract_info_shfe.py +46 -35
  68. akshare/futures_derivative/futures_cot_sina.py +26 -19
  69. akshare/futures_derivative/futures_spot_sys.py +21 -8
  70. akshare/fx/currency_investing.py +19 -285
  71. akshare/index/index_cflp.py +29 -26
  72. akshare/index/index_cni.py +86 -88
  73. akshare/index/index_cons.py +26 -10
  74. akshare/index/index_cx.py +248 -47
  75. akshare/index/index_drewry.py +17 -16
  76. akshare/index/index_option_qvix.py +329 -0
  77. akshare/index/index_research_fund_sw.py +134 -0
  78. akshare/index/{index_sw_research.py → index_research_sw.py} +122 -58
  79. akshare/index/index_spot.py +9 -5
  80. akshare/index/index_stock_hk.py +35 -16
  81. akshare/index/index_stock_us_sina.py +1 -1
  82. akshare/index/index_stock_zh.py +180 -89
  83. akshare/index/index_stock_zh_csindex.py +15 -369
  84. akshare/index/index_sw.py +62 -34
  85. akshare/index/index_yw.py +46 -23
  86. akshare/index/index_zh_a_scope.py +48 -0
  87. akshare/index/index_zh_em.py +6 -4
  88. akshare/interest_rate/interbank_rate_em.py +14 -9
  89. akshare/movie/artist_yien.py +32 -5
  90. akshare/movie/movie_yien.py +92 -18
  91. akshare/movie/video_yien.py +28 -5
  92. akshare/news/news_baidu.py +78 -44
  93. akshare/news/news_cctv.py +38 -38
  94. akshare/news/news_stock.py +6 -3
  95. akshare/nlp/nlp_interface.py +7 -8
  96. akshare/option/cons.py +11 -11
  97. akshare/option/option_comm_qihuo.py +86 -0
  98. akshare/option/option_commodity.py +178 -51
  99. akshare/option/option_daily_stats_sse_szse.py +146 -0
  100. akshare/option/option_em.py +147 -138
  101. akshare/option/option_finance_sina.py +160 -137
  102. akshare/option/option_lhb_em.py +62 -56
  103. akshare/option/option_risk_indicator_sse.py +17 -14
  104. akshare/other/other_car_cpca.py +934 -0
  105. akshare/other/{other_car.py → other_car_gasgoo.py} +15 -54
  106. akshare/qdii/__init__.py +0 -0
  107. akshare/qdii/qdii_jsl.py +233 -0
  108. akshare/request.py +117 -0
  109. akshare/spot/spot_hog_soozhu.py +232 -0
  110. akshare/spot/spot_price_qh.py +121 -0
  111. akshare/spot/spot_sge.py +63 -10
  112. akshare/stock/stock_allotment_cninfo.py +10 -9
  113. akshare/stock/stock_board_concept_em.py +23 -14
  114. akshare/stock/stock_board_industry_em.py +40 -34
  115. akshare/stock/stock_cg_equity_mortgage.py +15 -11
  116. akshare/stock/stock_cg_guarantee.py +41 -51
  117. akshare/stock/stock_cg_lawsuit.py +36 -35
  118. akshare/stock/stock_dividend_cninfo.py +12 -6
  119. akshare/stock/stock_dzjy_em.py +347 -260
  120. akshare/stock/stock_fund_em.py +332 -84
  121. akshare/stock/stock_hk_famous.py +108 -0
  122. akshare/stock/stock_hk_sina.py +8 -7
  123. akshare/stock/stock_hold_control_cninfo.py +100 -15
  124. akshare/stock/stock_hold_control_em.py +4 -3
  125. akshare/stock/stock_hold_num_cninfo.py +18 -12
  126. akshare/stock/stock_hot_rank_em.py +2 -1
  127. akshare/stock/stock_hot_search_baidu.py +5 -2
  128. akshare/stock/stock_industry_cninfo.py +24 -18
  129. akshare/stock/stock_industry_pe_cninfo.py +45 -31
  130. akshare/stock/stock_industry_sw.py +9 -10
  131. akshare/stock/stock_info.py +25 -15
  132. akshare/stock/stock_info_em.py +5 -2
  133. akshare/stock/stock_intraday_em.py +5 -2
  134. akshare/stock/stock_intraday_sina.py +22 -18
  135. akshare/stock/stock_ipo_summary_cninfo.py +25 -10
  136. akshare/stock/stock_new_cninfo.py +32 -19
  137. akshare/stock/stock_news_cx.py +39 -0
  138. akshare/stock/stock_profile_cninfo.py +9 -8
  139. akshare/stock/stock_rank_forecast.py +8 -6
  140. akshare/stock/stock_share_changes_cninfo.py +18 -14
  141. akshare/stock/stock_share_hold.py +24 -19
  142. akshare/stock/stock_summary.py +54 -26
  143. akshare/stock/stock_us_famous.py +15 -6
  144. akshare/stock/stock_us_pink.py +7 -5
  145. akshare/stock/stock_us_sina.py +15 -12
  146. akshare/stock/stock_xq.py +38 -12
  147. akshare/stock/stock_zh_a_sina.py +53 -78
  148. akshare/stock/stock_zh_b_sina.py +32 -55
  149. akshare/stock/stock_zh_kcb_report.py +11 -9
  150. akshare/stock/stock_zh_kcb_sina.py +67 -64
  151. akshare/stock_feature/stock_a_below_net_asset_statistics.py +5 -2
  152. akshare/stock_feature/stock_a_high_low.py +5 -2
  153. akshare/stock_feature/stock_a_indicator.py +12 -9
  154. akshare/stock_feature/stock_a_pe_and_pb.py +27 -6
  155. akshare/stock_feature/stock_account_em.py +58 -40
  156. akshare/stock_feature/stock_analyst_em.py +36 -27
  157. akshare/stock_feature/stock_board_industry_ths.py +136 -400
  158. akshare/stock_feature/stock_comment_em.py +118 -85
  159. akshare/stock_feature/stock_concept_futu.py +183 -0
  160. akshare/stock_feature/stock_cyq_em.py +58 -54
  161. akshare/stock_feature/stock_disclosure_cninfo.py +147 -102
  162. akshare/stock_feature/stock_esg_sina.py +216 -11
  163. akshare/stock_feature/stock_fhps_em.py +60 -25
  164. akshare/stock_feature/stock_fhps_ths.py +25 -6
  165. akshare/stock_feature/stock_fund_flow.py +38 -25
  166. akshare/stock_feature/stock_gdfx_em.py +180 -95
  167. akshare/stock_feature/stock_gdhs.py +73 -49
  168. akshare/stock_feature/stock_gpzy_em.py +78 -46
  169. akshare/stock_feature/stock_hist_em.py +55 -23
  170. akshare/stock_feature/stock_hk_valuation_baidu.py +20 -8
  171. akshare/stock_feature/stock_hsgt_em.py +184 -452
  172. akshare/stock_feature/stock_info.py +52 -29
  173. akshare/stock_feature/stock_inner_trade_xq.py +39 -31
  174. akshare/stock_feature/stock_irm_cninfo.py +32 -9
  175. akshare/stock_feature/stock_jgdy_em.py +41 -38
  176. akshare/stock_feature/stock_lh_yybpm.py +36 -37
  177. akshare/stock_feature/stock_lhb_em.py +135 -71
  178. akshare/stock_feature/stock_lhb_sina.py +93 -46
  179. akshare/stock_feature/stock_margin_em.py +102 -0
  180. akshare/stock_feature/{stock_sse_margin.py → stock_margin_sse.py} +21 -15
  181. akshare/stock_feature/{stock_szse_margin.py → stock_margin_szse.py} +23 -19
  182. akshare/stock_feature/stock_market_legu.py +13 -8
  183. akshare/stock_feature/stock_pankou_em.py +72 -34
  184. akshare/stock_feature/stock_report_em.py +244 -54
  185. akshare/stock_feature/stock_research_report_em.py +48 -19
  186. akshare/stock_feature/stock_sns_sseinfo.py +15 -12
  187. akshare/stock_feature/stock_sy_em.py +86 -33
  188. akshare/stock_feature/stock_technology_ths.py +152 -120
  189. akshare/stock_feature/stock_tfp_em.py +35 -13
  190. akshare/stock_feature/stock_three_report_em.py +119 -77
  191. akshare/stock_feature/stock_ttm_lyr.py +4 -7
  192. akshare/stock_feature/stock_value_em.py +83 -0
  193. akshare/stock_feature/stock_wencai.py +21 -9
  194. akshare/stock_feature/stock_yjyg_em.py +63 -28
  195. akshare/stock_feature/stock_zf_pg.py +61 -38
  196. akshare/stock_feature/stock_zh_valuation_baidu.py +3 -2
  197. akshare/stock_feature/stock_ztb_em.py +62 -40
  198. akshare/stock_fundamental/stock_finance.py +150 -58
  199. akshare/stock_fundamental/stock_finance_ths.py +116 -31
  200. akshare/stock_fundamental/stock_mda_ym.py +5 -3
  201. akshare/stock_fundamental/stock_notice.py +29 -15
  202. akshare/stock_fundamental/stock_profit_forecast_em.py +31 -13
  203. akshare/stock_fundamental/stock_profit_forecast_ths.py +19 -10
  204. akshare/stock_fundamental/stock_register_em.py +448 -0
  205. akshare/stock_fundamental/stock_restricted_em.py +79 -32
  206. akshare/stock_fundamental/stock_zygc.py +10 -8
  207. akshare/stock_fundamental/stock_zyjs_ths.py +5 -3
  208. akshare/tool/trade_date_hist.py +4 -3
  209. akshare/utils/cons.py +10 -0
  210. akshare/utils/context.py +43 -0
  211. akshare/utils/demjson.py +2 -2
  212. akshare/utils/func.py +26 -0
  213. akshare/utils/tqdm.py +13 -3
  214. {akshare-1.12.99.dist-info → akshare-1.15.73.dist-info}/METADATA +52 -69
  215. akshare-1.15.73.dist-info/RECORD +385 -0
  216. {akshare-1.12.99.dist-info → akshare-1.15.73.dist-info}/WHEEL +1 -1
  217. tests/test_func.py +3 -5
  218. akshare/bond/bond_futures.py +0 -50
  219. akshare/bond/bond_investing.py +0 -139
  220. akshare/crypto/crypto_hist_investing.py +0 -249
  221. akshare/fortune/fortune_it_juzi.py +0 -123
  222. akshare/futures/futures_international.py +0 -170
  223. akshare/futures/futures_news_baidu.py +0 -54
  224. akshare/futures/inventory_data.py +0 -100
  225. akshare/futures_derivative/futures_index_price_nh.py +0 -61
  226. akshare/futures_derivative/futures_index_return_nh.py +0 -47
  227. akshare/futures_derivative/futures_index_volatility_nh.py +0 -51
  228. akshare/futures_derivative/futures_other_index_nh.py +0 -145
  229. akshare/index/index_fear_greed_funddb.py +0 -71
  230. akshare/index/index_investing.py +0 -232
  231. akshare/sport/sport_olympic_winter.py +0 -39
  232. akshare/stock_feature/stock_board_concept_ths.py +0 -422
  233. akshare/stock_fundamental/stock_register.py +0 -292
  234. akshare-1.12.99.dist-info/RECORD +0 -374
  235. {akshare-1.12.99.dist-info → akshare-1.15.73.dist-info}/LICENSE +0 -0
  236. {akshare-1.12.99.dist-info → akshare-1.15.73.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2023/3/21 22:27
4
+ Date: 2024/8/23 17:50
5
5
  Desc: 东方财富-沪深板块-行业板块
6
6
  https://quote.eastmoney.com/center/boardlist.html#industry_board
7
7
  """
8
+
8
9
  import re
9
10
 
10
11
  import pandas as pd
@@ -18,7 +19,7 @@ def stock_board_industry_name_em() -> pd.DataFrame:
18
19
  :return: 行业板块-名称
19
20
  :rtype: pandas.DataFrame
20
21
  """
21
- url = "http://17.push2.eastmoney.com/api/qt/clist/get"
22
+ url = "https://17.push2.eastmoney.com/api/qt/clist/get"
22
23
  params = {
23
24
  "pn": "1",
24
25
  "pz": "2000",
@@ -29,7 +30,9 @@ def stock_board_industry_name_em() -> pd.DataFrame:
29
30
  "invt": "2",
30
31
  "fid": "f3",
31
32
  "fs": "m:90 t:2 f:!50",
32
- "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222",
33
+ "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,"
34
+ "f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,"
35
+ "f140,f141,f207,f208,f209,f222",
33
36
  "_": "1626075887768",
34
37
  }
35
38
  r = requests.get(url, params=params)
@@ -104,7 +107,9 @@ def stock_board_industry_name_em() -> pd.DataFrame:
104
107
  temp_df["换手率"] = pd.to_numeric(temp_df["换手率"], errors="coerce")
105
108
  temp_df["上涨家数"] = pd.to_numeric(temp_df["上涨家数"], errors="coerce")
106
109
  temp_df["下跌家数"] = pd.to_numeric(temp_df["下跌家数"], errors="coerce")
107
- temp_df["领涨股票-涨跌幅"] = pd.to_numeric(temp_df["领涨股票-涨跌幅"], errors="coerce")
110
+ temp_df["领涨股票-涨跌幅"] = pd.to_numeric(
111
+ temp_df["领涨股票-涨跌幅"], errors="coerce"
112
+ )
108
113
  return temp_df
109
114
 
110
115
 
@@ -117,7 +122,7 @@ def stock_board_industry_spot_em(symbol: str = "小金属") -> pd.DataFrame:
117
122
  :return: 实时行情
118
123
  :rtype: pandas.DataFrame
119
124
  """
120
- url = "http://91.push2.eastmoney.com/api/qt/stock/get"
125
+ url = "https://91.push2.eastmoney.com/api/qt/stock/get"
121
126
  field_map = {
122
127
  "f43": "最新",
123
128
  "f44": "最高",
@@ -131,14 +136,14 @@ def stock_board_industry_spot_em(symbol: str = "小金属") -> pd.DataFrame:
131
136
  "f169": "涨跌额",
132
137
  }
133
138
 
134
- if re.match(r'^BK\d+', symbol):
139
+ if re.match(pattern=r"^BK\d+", string=symbol):
135
140
  em_code = symbol
136
141
  else:
137
142
  industry_listing = stock_board_industry_name_em()
138
- em_code = industry_listing.query('板块名称 == @symbol')["板块代码"].values[0]
143
+ em_code = industry_listing.query("板块名称 == @symbol")["板块代码"].values[0]
139
144
 
140
145
  params = dict(
141
- fields=','.join(field_map.keys()),
146
+ fields=",".join(field_map.keys()),
142
147
  mpi="1000",
143
148
  invt="2",
144
149
  fltt="1",
@@ -150,22 +155,22 @@ def stock_board_industry_spot_em(symbol: str = "小金属") -> pd.DataFrame:
150
155
  result = pd.DataFrame.from_dict(data_dict["data"], orient="index")
151
156
  result.rename(field_map, inplace=True)
152
157
  result.reset_index(inplace=True)
153
- result.columns = ['item', "value"]
154
- result['value'] = pd.to_numeric(result['value'], errors="coerce")
158
+ result.columns = ["item", "value"]
159
+ result["value"] = pd.to_numeric(result["value"], errors="coerce")
155
160
 
156
161
  # 各项转换成正常单位. 除了成交量与成交额, 原始数据中已是正常单位(元)
157
- result['value'] = result['value'] * 1e-2
162
+ result["value"] = result["value"] * 1e-2
158
163
  result.iloc[4, 1] = result.iloc[4, 1] * 1e2
159
164
  result.iloc[5, 1] = result.iloc[5, 1] * 1e2
160
165
  return result
161
166
 
162
167
 
163
168
  def stock_board_industry_hist_em(
164
- symbol: str = "小金属",
165
- start_date: str = "20211201",
166
- end_date: str = "20220401",
167
- period: str = "日k",
168
- adjust: str = "",
169
+ symbol: str = "小金属",
170
+ start_date: str = "20211201",
171
+ end_date: str = "20220401",
172
+ period: str = "日k",
173
+ adjust: str = "",
169
174
  ) -> pd.DataFrame:
170
175
  """
171
176
  东方财富网-沪深板块-行业板块-历史行情
@@ -184,14 +189,14 @@ def stock_board_industry_hist_em(
184
189
  :rtype: pandas.DataFrame
185
190
  """
186
191
  period_map = {
187
- "日k": '101',
188
- "周k": '102',
189
- "月k": '103',
192
+ "日k": "101",
193
+ "周k": "102",
194
+ "月k": "103",
190
195
  }
191
196
  stock_board_concept_em_map = stock_board_industry_name_em()
192
197
  stock_board_code = stock_board_concept_em_map[
193
198
  stock_board_concept_em_map["板块名称"] == symbol
194
- ]["板块代码"].values[0]
199
+ ]["板块代码"].values[0]
195
200
  adjust_map = {"": "0", "qfq": "1", "hfq": "2"}
196
201
  url = "http://7.push2his.eastmoney.com/api/qt/stock/kline/get"
197
202
  params = {
@@ -209,9 +214,7 @@ def stock_board_industry_hist_em(
209
214
  }
210
215
  r = requests.get(url, params=params)
211
216
  data_json = r.json()
212
- temp_df = pd.DataFrame(
213
- [item.split(",") for item in data_json["data"]["klines"]]
214
- )
217
+ temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]["klines"]])
215
218
  temp_df.columns = [
216
219
  "日期",
217
220
  "开盘",
@@ -254,7 +257,7 @@ def stock_board_industry_hist_em(
254
257
 
255
258
 
256
259
  def stock_board_industry_hist_min_em(
257
- symbol: str = "小金属", period: str = "5"
260
+ symbol: str = "小金属", period: str = "5"
258
261
  ) -> pd.DataFrame:
259
262
  """
260
263
  东方财富网-沪深板块-行业板块-分时历史行情
@@ -269,15 +272,15 @@ def stock_board_industry_hist_min_em(
269
272
  stock_board_concept_em_map = stock_board_industry_name_em()
270
273
  stock_board_code = stock_board_concept_em_map[
271
274
  stock_board_concept_em_map["板块名称"] == symbol
272
- ]["板块代码"].values[0]
275
+ ]["板块代码"].values[0]
273
276
  if period == "1":
274
277
  url = "https://push2his.eastmoney.com/api/qt/stock/trends2/get"
275
278
  params = {
276
279
  "fields1": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",
277
280
  "fields2": "f51,f52,f53,f54,f55,f56,f57,f58",
278
- "ut": 'fa5fd1943c7b386f172d6893dbfba10b',
279
- "iscr": '0',
280
- "ndays": '1',
281
+ "ut": "fa5fd1943c7b386f172d6893dbfba10b",
282
+ "iscr": "0",
283
+ "ndays": "1",
281
284
  "secid": f"90.{stock_board_code}",
282
285
  "_": "1687852931312",
283
286
  }
@@ -378,7 +381,7 @@ def stock_board_industry_cons_em(symbol: str = "小金属") -> pd.DataFrame:
378
381
  stock_board_concept_em_map = stock_board_industry_name_em()
379
382
  stock_board_code = stock_board_concept_em_map[
380
383
  stock_board_concept_em_map["板块名称"] == symbol
381
- ]["板块代码"].values[0]
384
+ ]["板块代码"].values[0]
382
385
  url = "http://29.push2.eastmoney.com/api/qt/clist/get"
383
386
  params = {
384
387
  "pn": "1",
@@ -390,7 +393,8 @@ def stock_board_industry_cons_em(symbol: str = "小金属") -> pd.DataFrame:
390
393
  "invt": "2",
391
394
  "fid": "f3",
392
395
  "fs": f"b:{stock_board_code} f:!50",
393
- "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,f45",
396
+ "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,"
397
+ "f23,f24,f25,f22,f11,f62,f128,f136,f115,f152,f45",
394
398
  "_": "1626081702127",
395
399
  }
396
400
  r = requests.get(url, params=params)
@@ -477,7 +481,11 @@ if __name__ == "__main__":
477
481
  print(stock_board_industry_spot_em_df)
478
482
 
479
483
  stock_board_industry_hist_em_df = stock_board_industry_hist_em(
480
- symbol="小金属", start_date="20211201", end_date="20240222", period="日k", adjust=""
484
+ symbol="小金属",
485
+ start_date="20211201",
486
+ end_date="20240222",
487
+ period="日k",
488
+ adjust="",
481
489
  )
482
490
  print(stock_board_industry_hist_em_df)
483
491
 
@@ -486,7 +494,5 @@ if __name__ == "__main__":
486
494
  )
487
495
  print(stock_board_industry_hist_min_em_df)
488
496
 
489
- stock_board_industry_cons_em_df = stock_board_industry_cons_em(
490
- symbol="小金属"
491
- )
497
+ stock_board_industry_cons_em_df = stock_board_industry_cons_em(symbol="小金属")
492
498
  print(stock_board_industry_cons_em_df)
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2023/5/29 23:34
4
+ Date: 2024/7/24 23:30
5
5
  Desc: 巨潮资讯-数据中心-专题统计-公司治理-股权质押
6
- http://webapi.cninfo.com.cn/#/thematicStatistics
6
+ https://webapi.cninfo.com.cn/#/thematicStatistics
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.datasets import get_ths_js
13
14
 
@@ -21,7 +22,7 @@ def _get_file_content_ths(file: str = "cninfo.js") -> str:
21
22
  :rtype: str
22
23
  """
23
24
  setting_file_path = get_ths_js(file)
24
- with open(setting_file_path) as f:
25
+ with open(setting_file_path, encoding="utf-8") as f:
25
26
  file_data = f.read()
26
27
  return file_data
27
28
 
@@ -29,13 +30,13 @@ def _get_file_content_ths(file: str = "cninfo.js") -> str:
29
30
  def stock_cg_equity_mortgage_cninfo(date: str = "20210930") -> pd.DataFrame:
30
31
  """
31
32
  巨潮资讯-数据中心-专题统计-公司治理-股权质押
32
- http://webapi.cninfo.com.cn/#/thematicStatistics
33
+ https://webapi.cninfo.com.cn/#/thematicStatistics
33
34
  :param date: 开始统计时间
34
35
  :type date: str
35
36
  :return: 股权质押
36
37
  :rtype: pandas.DataFrame
37
38
  """
38
- url = "http://webapi.cninfo.com.cn/api/sysapi/p_sysapi1094"
39
+ url = "https://webapi.cninfo.com.cn/api/sysapi/p_sysapi1094"
39
40
  js_code = py_mini_racer.MiniRacer()
40
41
  js_content = _get_file_content_ths("cninfo.js")
41
42
  js_code.eval(js_content)
@@ -48,11 +49,12 @@ def stock_cg_equity_mortgage_cninfo(date: str = "20210930") -> pd.DataFrame:
48
49
  "Cache-Control": "no-cache",
49
50
  "Content-Length": "0",
50
51
  "Host": "webapi.cninfo.com.cn",
51
- "Origin": "http://webapi.cninfo.com.cn",
52
+ "Origin": "https://webapi.cninfo.com.cn",
52
53
  "Pragma": "no-cache",
53
54
  "Proxy-Connection": "keep-alive",
54
- "Referer": "http://webapi.cninfo.com.cn/",
55
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36",
55
+ "Referer": "https://webapi.cninfo.com.cn/",
56
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
57
+ "Chrome/93.0.4577.63 Safari/537.36",
56
58
  "X-Requested-With": "XMLHttpRequest",
57
59
  }
58
60
  params = {
@@ -87,11 +89,13 @@ def stock_cg_equity_mortgage_cninfo(date: str = "20210930") -> pd.DataFrame:
87
89
  "累计质押占总股本比例",
88
90
  ]
89
91
  ]
90
- temp_df["公告日期"] = pd.to_datetime(temp_df["公告日期"]).dt.date
92
+ temp_df["公告日期"] = pd.to_datetime(temp_df["公告日期"], errors="coerce").dt.date
91
93
  temp_df["质押数量"] = pd.to_numeric(temp_df["质押数量"], errors="coerce")
92
94
  temp_df["占总股本比例"] = pd.to_numeric(temp_df["占总股本比例"], errors="coerce")
93
95
  temp_df["质押解除数量"] = pd.to_numeric(temp_df["质押解除数量"], errors="coerce")
94
- temp_df["累计质押占总股本比例"] = pd.to_numeric(temp_df["累计质押占总股本比例"], errors="coerce")
96
+ temp_df["累计质押占总股本比例"] = pd.to_numeric(
97
+ temp_df["累计质押占总股本比例"], errors="coerce"
98
+ )
95
99
  return temp_df
96
100
 
97
101
 
@@ -1,45 +1,30 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2021/9/26 23:19
4
+ Date: 2024/5/19 18:34
5
5
  Desc: 巨潮资讯-数据中心-专题统计-公司治理-对外担保
6
- http://webapi.cninfo.com.cn/#/thematicStatistics
6
+ https://webapi.cninfo.com.cn/#/thematicStatistics
7
7
  """
8
- import time
9
8
 
10
9
  import pandas as pd
11
10
  import requests
12
- from py_mini_racer import py_mini_racer
11
+ import py_mini_racer
12
+
13
+ from akshare.datasets import get_ths_js
13
14
 
14
- js_str = """
15
- function mcode(input) {
16
- var keyStr = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/" + "=";
17
- var output = "";
18
- var chr1, chr2, chr3 = "";
19
- var enc1, enc2, enc3, enc4 = "";
20
- var i = 0;
21
- do {
22
- chr1 = input.charCodeAt(i++);
23
- chr2 = input.charCodeAt(i++);
24
- chr3 = input.charCodeAt(i++);
25
- enc1 = chr1 >> 2;
26
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
27
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
28
- enc4 = chr3 & 63;
29
- if (isNaN(chr2)) {
30
- enc3 = enc4 = 64;
31
- } else if (isNaN(chr3)) {
32
- enc4 = 64;
33
- }
34
- output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2)
35
- + keyStr.charAt(enc3) + keyStr.charAt(enc4);
36
- chr1 = chr2 = chr3 = "";
37
- enc1 = enc2 = enc3 = enc4 = "";
38
- } while (i < input.length);
39
-
40
- return output;
41
- }
42
- """
15
+
16
+ def _get_file_content_ths(file: str = "cninfo.js") -> str:
17
+ """
18
+ 获取 JS 文件的内容
19
+ :param file: JS 文件名
20
+ :type file: str
21
+ :return: 文件内容
22
+ :rtype: str
23
+ """
24
+ setting_file_path = get_ths_js(file)
25
+ with open(setting_file_path, encoding="utf-8") as f:
26
+ file_data = f.read()
27
+ return file_data
43
28
 
44
29
 
45
30
  def stock_cg_guarantee_cninfo(
@@ -47,7 +32,7 @@ def stock_cg_guarantee_cninfo(
47
32
  ) -> pd.DataFrame:
48
33
  """
49
34
  巨潮资讯-数据中心-专题统计-公司治理-对外担保
50
- http://webapi.cninfo.com.cn/#/thematicStatistics
35
+ https://webapi.cninfo.com.cn/#/thematicStatistics
51
36
  :param symbol: choice of {"全部", "深市主板", "沪市", "创业板", "科创板"}
52
37
  :type symbol: str
53
38
  :param start_date: 开始统计时间
@@ -58,17 +43,17 @@ def stock_cg_guarantee_cninfo(
58
43
  :rtype: pandas.DataFrame
59
44
  """
60
45
  symbol_map = {
61
- "全部": '',
62
- "深市主板": '012002',
63
- "沪市": '012001',
64
- "创业板": '012015',
65
- "科创板": '012029',
46
+ "全部": "",
47
+ "深市主板": "012002",
48
+ "沪市": "012001",
49
+ "创业板": "012015",
50
+ "科创板": "012029",
66
51
  }
67
- url = "http://webapi.cninfo.com.cn/api/sysapi/p_sysapi1054"
68
- random_time_str = str(int(time.time()))
52
+ url = "https://webapi.cninfo.com.cn/api/sysapi/p_sysapi1054"
69
53
  js_code = py_mini_racer.MiniRacer()
70
- js_code.eval(js_str)
71
- mcode = js_code.call("mcode", random_time_str)
54
+ js_content = _get_file_content_ths("cninfo.js")
55
+ js_code.eval(js_content)
56
+ mcode = js_code.call("getResCode1")
72
57
  headers = {
73
58
  "Accept": "*/*",
74
59
  "Accept-Encoding": "gzip, deflate",
@@ -76,12 +61,13 @@ def stock_cg_guarantee_cninfo(
76
61
  "Cache-Control": "no-cache",
77
62
  "Content-Length": "0",
78
63
  "Host": "webapi.cninfo.com.cn",
79
- "mcode": mcode,
80
- "Origin": "http://webapi.cninfo.com.cn",
64
+ "Accept-Enckey": mcode,
65
+ "Origin": "https://webapi.cninfo.com.cn",
81
66
  "Pragma": "no-cache",
82
67
  "Proxy-Connection": "keep-alive",
83
- "Referer": "http://webapi.cninfo.com.cn/",
84
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36",
68
+ "Referer": "https://webapi.cninfo.com.cn/",
69
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
70
+ "Chrome/93.0.4577.63 Safari/537.36",
85
71
  "X-Requested-With": "XMLHttpRequest",
86
72
  }
87
73
  params = {
@@ -112,10 +98,14 @@ def stock_cg_guarantee_cninfo(
112
98
  "担保金融占净资产比例",
113
99
  ]
114
100
  ]
115
- temp_df["担保笔数"] = pd.to_numeric(temp_df["担保笔数"])
116
- temp_df["担保金额"] = pd.to_numeric(temp_df["担保金额"])
117
- temp_df["归属于母公司所有者权益"] = pd.to_numeric(temp_df["归属于母公司所有者权益"])
118
- temp_df["担保金融占净资产比例"] = pd.to_numeric(temp_df["担保金融占净资产比例"])
101
+ temp_df["担保笔数"] = pd.to_numeric(temp_df["担保笔数"], errors="coerce")
102
+ temp_df["担保金额"] = pd.to_numeric(temp_df["担保金额"], errors="coerce")
103
+ temp_df["归属于母公司所有者权益"] = pd.to_numeric(
104
+ temp_df["归属于母公司所有者权益"], errors="coerce"
105
+ )
106
+ temp_df["担保金融占净资产比例"] = pd.to_numeric(
107
+ temp_df["担保金融占净资产比例"], errors="coerce"
108
+ )
119
109
  return temp_df
120
110
 
121
111
 
@@ -5,45 +5,46 @@ Date: 2021/9/29 16:19
5
5
  Desc: 巨潮资讯-数据中心-专题统计-公司治理-公司诉讼
6
6
  http://webapi.cninfo.com.cn/#/thematicStatistics
7
7
  """
8
+
8
9
  import time
9
10
 
10
11
  import pandas as pd
11
12
  import requests
12
- from py_mini_racer import py_mini_racer
13
+ import py_mini_racer
13
14
 
14
15
  js_str = """
15
- function mcode(input) {
16
- var keyStr = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/" + "=";
17
- var output = "";
18
- var chr1, chr2, chr3 = "";
19
- var enc1, enc2, enc3, enc4 = "";
20
- var i = 0;
21
- do {
22
- chr1 = input.charCodeAt(i++);
23
- chr2 = input.charCodeAt(i++);
24
- chr3 = input.charCodeAt(i++);
25
- enc1 = chr1 >> 2;
26
- enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
27
- enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
28
- enc4 = chr3 & 63;
29
- if (isNaN(chr2)) {
30
- enc3 = enc4 = 64;
31
- } else if (isNaN(chr3)) {
32
- enc4 = 64;
33
- }
34
- output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2)
35
- + keyStr.charAt(enc3) + keyStr.charAt(enc4);
36
- chr1 = chr2 = chr3 = "";
37
- enc1 = enc2 = enc3 = enc4 = "";
38
- } while (i < input.length);
39
-
40
- return output;
41
- }
16
+ function mcode(input) {
17
+ var keyStr = "ABCDEFGHIJKLMNOP" + "QRSTUVWXYZabcdef" + "ghijklmnopqrstuv" + "wxyz0123456789+/" + "=";
18
+ var output = "";
19
+ var chr1, chr2, chr3 = "";
20
+ var enc1, enc2, enc3, enc4 = "";
21
+ var i = 0;
22
+ do {
23
+ chr1 = input.charCodeAt(i++);
24
+ chr2 = input.charCodeAt(i++);
25
+ chr3 = input.charCodeAt(i++);
26
+ enc1 = chr1 >> 2;
27
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
28
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
29
+ enc4 = chr3 & 63;
30
+ if (isNaN(chr2)) {
31
+ enc3 = enc4 = 64;
32
+ } else if (isNaN(chr3)) {
33
+ enc4 = 64;
34
+ }
35
+ output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2)
36
+ + keyStr.charAt(enc3) + keyStr.charAt(enc4);
37
+ chr1 = chr2 = chr3 = "";
38
+ enc1 = enc2 = enc3 = enc4 = "";
39
+ } while (i < input.length);
40
+
41
+ return output;
42
+ }
42
43
  """
43
44
 
44
45
 
45
46
  def stock_cg_lawsuit_cninfo(
46
- symbol: str = "全部", start_date: str = "20180630", end_date: str = "20210927"
47
+ symbol: str = "全部", start_date: str = "20180630", end_date: str = "20210927"
47
48
  ) -> pd.DataFrame:
48
49
  """
49
50
  巨潮资讯-数据中心-专题统计-公司治理-公司诉讼
@@ -58,11 +59,11 @@ def stock_cg_lawsuit_cninfo(
58
59
  :rtype: pandas.DataFrame
59
60
  """
60
61
  symbol_map = {
61
- "全部": '',
62
- "深市主板": '012002',
63
- "沪市": '012001',
64
- "创业板": '012015',
65
- "科创板": '012029',
62
+ "全部": "",
63
+ "深市主板": "012002",
64
+ "沪市": "012001",
65
+ "创业板": "012015",
66
+ "科创板": "012029",
66
67
  }
67
68
  url = "http://webapi.cninfo.com.cn/api/sysapi/p_sysapi1055"
68
69
  random_time_str = str(int(time.time()))
@@ -117,4 +118,4 @@ if __name__ == "__main__":
117
118
  stock_cg_lawsuit_cninfo_df = stock_cg_lawsuit_cninfo(
118
119
  symbol="全部", start_date="20180928", end_date="20210927"
119
120
  )
120
- print(stock_cg_lawsuit_cninfo_df)
121
+ print(stock_cg_lawsuit_cninfo_df)
@@ -1,13 +1,14 @@
1
1
  # -*- coding:utf-8 -*-
2
2
  # !/usr/bin/env python
3
3
  """
4
- Date: 2023/9/26 15:00
4
+ Date: 2024/6/5 17:00
5
5
  Desc: 巨潮资讯-个股-历史分红
6
6
  https://webapi.cninfo.com.cn/#/company?companyid=600009
7
7
  """
8
+
8
9
  import pandas as pd
9
10
  import requests
10
- from py_mini_racer import py_mini_racer
11
+ import py_mini_racer
11
12
 
12
13
  from akshare.datasets import get_ths_js
13
14
 
@@ -21,7 +22,7 @@ def _get_file_content_ths(file: str = "cninfo.js") -> str:
21
22
  :rtype: str
22
23
  """
23
24
  setting_file_path = get_ths_js(file)
24
- with open(setting_file_path) as f:
25
+ with open(setting_file_path, encoding="utf-8") as f:
25
26
  file_data = f.read()
26
27
  return file_data
27
28
 
@@ -53,7 +54,8 @@ def stock_dividend_cninfo(symbol: str = "600009") -> pd.DataFrame:
53
54
  "Pragma": "no-cache",
54
55
  "Proxy-Connection": "keep-alive",
55
56
  "Referer": "http://webapi.cninfo.com.cn/",
56
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36",
57
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
58
+ "Chrome/93.0.4577.63 Safari/537.36",
57
59
  "X-Requested-With": "XMLHttpRequest",
58
60
  }
59
61
  r = requests.post(url, params=params, headers=headers)
@@ -72,11 +74,15 @@ def stock_dividend_cninfo(symbol: str = "600009") -> pd.DataFrame:
72
74
  "分红类型",
73
75
  "报告时间",
74
76
  ]
75
- temp_df["实施方案公告日期"] = pd.to_datetime(temp_df["实施方案公告日期"], errors="coerce").dt.date
77
+ temp_df["实施方案公告日期"] = pd.to_datetime(
78
+ temp_df["实施方案公告日期"], errors="coerce"
79
+ ).dt.date
76
80
  temp_df["送股比例"] = pd.to_numeric(temp_df["送股比例"], errors="coerce")
77
81
  temp_df["转增比例"] = pd.to_numeric(temp_df["转增比例"], errors="coerce")
78
82
  temp_df["派息比例"] = pd.to_numeric(temp_df["派息比例"], errors="coerce")
79
- temp_df["股权登记日"] = pd.to_datetime(temp_df["股权登记日"], errors="coerce").dt.date
83
+ temp_df["股权登记日"] = pd.to_datetime(
84
+ temp_df["股权登记日"], errors="coerce"
85
+ ).dt.date
80
86
  temp_df["除权日"] = pd.to_datetime(temp_df["除权日"], errors="coerce").dt.date
81
87
  temp_df["派息日"] = pd.to_datetime(temp_df["派息日"], errors="coerce").dt.date
82
88
  temp_df.sort_values(by="实施方案公告日期", ignore_index=True, inplace=True)