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
@@ -5,6 +5,7 @@ Date: 2022/12/27 21:11
5
5
  Desc: 东方财富-行情中心-盘口异动
6
6
  https://quote.eastmoney.com/changes/
7
7
  """
8
+
8
9
  import pandas as pd
9
10
  import requests
10
11
 
@@ -13,12 +14,14 @@ def stock_changes_em(symbol: str = "大笔买入") -> pd.DataFrame:
13
14
  """
14
15
  东方财富-行情中心-盘口异动
15
16
  https://quote.eastmoney.com/changes/
16
- :param symbol: choice of {'火箭发射', '快速反弹', '大笔买入', '封涨停板', '打开跌停板', '有大买盘', '竞价上涨', '高开5日线', '向上缺口', '60日新高', '60日大幅上涨', '加速下跌', '高台跳水', '大笔卖出', '封跌停板', '打开涨停板', '有大卖盘', '竞价下跌', '低开5日线', '向下缺口', '60日新低', '60日大幅下跌'}
17
+ :param symbol: choice of {'火箭发射', '快速反弹', '大笔买入', '封涨停板', '打开跌停板', '有大买盘',
18
+ '竞价上涨', '高开5日线', '向上缺口', '60日新高', '60日大幅上涨', '加速下跌', '高台跳水',
19
+ '大笔卖出', '封跌停板', '打开涨停板', '有大卖盘', '竞价下跌', '低开5日线', '向下缺口', '60日新低', '60日大幅下跌'}
17
20
  :type symbol: str
18
21
  :return: 盘口异动
19
22
  :rtype: pandas.DataFrame
20
23
  """
21
- url = "http://push2ex.eastmoney.com/getAllStockChanges"
24
+ url = "https://push2ex.eastmoney.com/getAllStockChanges"
22
25
  symbol_map = {
23
26
  "火箭发射": "8201",
24
27
  "快速反弹": "8202",
@@ -85,54 +88,89 @@ def stock_board_change_em() -> pd.DataFrame:
85
88
  :return: 当日板块异动详情页
86
89
  :rtype: pandas.DataFrame
87
90
  """
88
- url = "http://push2ex.eastmoney.com/getAllBKChanges"
91
+ url = "https://push2ex.eastmoney.com/getAllBKChanges"
89
92
  params = {
90
- 'ut': '7eea3edcaed734bea9cbfc24409ed989',
91
- 'dpt': 'wzchanges',
92
- 'pageindex': '0',
93
- 'pagesize': '5000',
94
- '_': '1671978840598',
93
+ "ut": "7eea3edcaed734bea9cbfc24409ed989",
94
+ "dpt": "wzchanges",
95
+ "pageindex": "0",
96
+ "pagesize": "5000",
97
+ "_": "1671978840598",
95
98
  }
96
99
  r = requests.get(url, params=params)
97
100
  data_json = r.json()
98
- data_df = pd.DataFrame(data_json['data']['allbk'])
101
+ data_df = pd.DataFrame(data_json["data"]["allbk"])
99
102
  data_df.columns = [
100
- '-',
101
- '-',
102
- '板块名称',
103
- '涨跌幅',
104
- '主力净流入',
105
- '板块异动总次数',
103
+ "-",
104
+ "-",
105
+ "板块名称",
106
+ "涨跌幅",
107
+ "主力净流入",
108
+ "板块异动总次数",
106
109
  "ms",
107
110
  "板块具体异动类型列表及出现次数",
108
111
  ]
109
- data_df['板块异动最频繁个股及所属类型-买卖方向'] = [item['m'] for item in data_df['ms']]
110
- data_df['板块异动最频繁个股及所属类型-股票代码'] = [item['c'] for item in data_df['ms']]
111
- data_df['板块异动最频繁个股及所属类型-股票名称'] = [item['n'] for item in data_df['ms']]
112
- data_df['板块异动最频繁个股及所属类型-买卖方向'] = data_df['板块异动最频繁个股及所属类型-买卖方向'].map({0: "大笔买入", 1: "大笔卖出"})
113
- data_df = data_df[[
114
- '板块名称',
115
- '涨跌幅',
116
- '主力净流入',
117
- '板块异动总次数',
118
- '板块异动最频繁个股及所属类型-股票代码',
119
- '板块异动最频繁个股及所属类型-股票名称',
120
- '板块异动最频繁个股及所属类型-买卖方向',
121
- "板块具体异动类型列表及出现次数",
122
- ]]
123
- data_df['涨跌幅'] = pd.to_numeric(data_df['涨跌幅'], errors="coerce")
124
- data_df['主力净流入'] = pd.to_numeric(data_df['主力净流入'], errors="coerce")
125
- data_df['板块异动总次数'] = pd.to_numeric(data_df['板块异动总次数'], errors="coerce")
112
+ data_df["板块异动最频繁个股及所属类型-买卖方向"] = [
113
+ item["m"] for item in data_df["ms"]
114
+ ]
115
+ data_df["板块异动最频繁个股及所属类型-股票代码"] = [
116
+ item["c"] for item in data_df["ms"]
117
+ ]
118
+ data_df["板块异动最频繁个股及所属类型-股票名称"] = [
119
+ item["n"] for item in data_df["ms"]
120
+ ]
121
+ data_df["板块异动最频繁个股及所属类型-买卖方向"] = data_df[
122
+ "板块异动最频繁个股及所属类型-买卖方向"
123
+ ].map({0: "大笔买入", 1: "大笔卖出"})
124
+ data_df = data_df[
125
+ [
126
+ "板块名称",
127
+ "涨跌幅",
128
+ "主力净流入",
129
+ "板块异动总次数",
130
+ "板块异动最频繁个股及所属类型-股票代码",
131
+ "板块异动最频繁个股及所属类型-股票名称",
132
+ "板块异动最频繁个股及所属类型-买卖方向",
133
+ "板块具体异动类型列表及出现次数",
134
+ ]
135
+ ]
136
+ data_df["涨跌幅"] = pd.to_numeric(data_df["涨跌幅"], errors="coerce")
137
+ data_df["主力净流入"] = pd.to_numeric(data_df["主力净流入"], errors="coerce")
138
+ data_df["板块异动总次数"] = pd.to_numeric(
139
+ data_df["板块异动总次数"], errors="coerce"
140
+ )
126
141
  return data_df
127
142
 
128
143
 
129
144
  if __name__ == "__main__":
130
- stock_changes_em_df = stock_changes_em(symbol='火箭发射')
145
+ stock_changes_em_df = stock_changes_em(symbol="大笔买入")
131
146
  print(stock_changes_em_df)
132
147
 
133
148
  stock_board_change_em_df = stock_board_change_em()
134
149
  print(stock_board_change_em_df)
135
150
 
136
- for item in {'火箭发射', '快速反弹', '大笔买入', '封涨停板', '打开跌停板', '有大买盘', '竞价上涨', '高开5日线', '向上缺口', '60日新高', '60日大幅上涨', '加速下跌', '高台跳水', '大笔卖出', '封跌停板', '打开涨停板', '有大卖盘', '竞价下跌', '低开5日线', '向下缺口', '60日新低', '60日大幅下跌'}:
151
+ for item in {
152
+ "火箭发射",
153
+ "快速反弹",
154
+ "大笔买入",
155
+ "封涨停板",
156
+ "打开跌停板",
157
+ "有大买盘",
158
+ "竞价上涨",
159
+ "高开5日线",
160
+ "向上缺口",
161
+ "60日新高",
162
+ "60日大幅上涨",
163
+ "加速下跌",
164
+ "高台跳水",
165
+ "大笔卖出",
166
+ "封跌停板",
167
+ "打开涨停板",
168
+ "有大卖盘",
169
+ "竞价下跌",
170
+ "低开5日线",
171
+ "向下缺口",
172
+ "60日新低",
173
+ "60日大幅下跌",
174
+ }:
137
175
  stock_changes_em_df = stock_changes_em(symbol=item)
138
176
  print(stock_changes_em_df)
@@ -1,29 +1,34 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2022/5/1 19:48
4
+ Date: 2024/9/20 15:30
5
5
  Desc: 东方财富-数据中心-年报季报-业绩快报-三大报表
6
6
  资产负债表
7
- http://data.eastmoney.com/bbsj/202003/zcfz.html
7
+ https://data.eastmoney.com/bbsj/202003/zcfz.html
8
8
  利润表
9
- http://data.eastmoney.com/bbsj/202003/lrb.html
9
+ https://data.eastmoney.com/bbsj/202003/lrb.html
10
10
  现金流量表
11
- http://data.eastmoney.com/bbsj/202003/xjll.html
11
+ https://data.eastmoney.com/bbsj/202003/xjll.html
12
12
  """
13
+
13
14
  import pandas as pd
14
15
  import requests
15
- from tqdm import tqdm
16
+
17
+ from akshare.utils.tqdm import get_tqdm
16
18
 
17
19
 
18
- def stock_zcfz_em(date: str = "20220331") -> pd.DataFrame:
20
+ def stock_zcfz_em(date: str = "20240331") -> pd.DataFrame:
19
21
  """
20
22
  东方财富-数据中心-年报季报-业绩快报-资产负债表
21
- http://data.eastmoney.com/bbsj/202003/zcfz.html
23
+ https://data.eastmoney.com/bbsj/202003/zcfz.html
22
24
  :param date: choice of {"20200331", "20200630", "20200930", "20201231", "..."}; 从 20100331 开始
23
25
  :type date: str
24
26
  :return: 资产负债表
25
27
  :rtype: pandas.DataFrame
26
28
  """
29
+ import warnings
30
+
31
+ warnings.filterwarnings(action="ignore", category=FutureWarning)
27
32
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
28
33
  params = {
29
34
  "sortColumns": "NOTICE_DATE,SECURITY_CODE",
@@ -32,12 +37,14 @@ def stock_zcfz_em(date: str = "20220331") -> pd.DataFrame:
32
37
  "pageNumber": "1",
33
38
  "reportName": "RPT_DMSK_FN_BALANCE",
34
39
  "columns": "ALL",
35
- "filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE!="069001017")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')""",
40
+ "filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE!="069001017")
41
+ (REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')""",
36
42
  }
37
43
  r = requests.get(url, params=params)
38
44
  data_json = r.json()
39
45
  page_num = data_json["result"]["pages"]
40
46
  big_df = pd.DataFrame()
47
+ tqdm = get_tqdm()
41
48
  for page in tqdm(range(1, page_num + 1), leave=False):
42
49
  params.update(
43
50
  {
@@ -47,7 +54,7 @@ def stock_zcfz_em(date: str = "20220331") -> pd.DataFrame:
47
54
  r = requests.get(url, params=params)
48
55
  data_json = r.json()
49
56
  temp_df = pd.DataFrame(data_json["result"]["data"])
50
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
57
+ big_df = pd.concat(objs=[big_df, temp_df], join="outer", ignore_index=True)
51
58
 
52
59
  big_df.reset_index(inplace=True)
53
60
  big_df["index"] = big_df.index + 1
@@ -131,23 +138,168 @@ def stock_zcfz_em(date: str = "20220331") -> pd.DataFrame:
131
138
  ]
132
139
  ]
133
140
 
134
- big_df["资产-货币资金"] = pd.to_numeric(big_df["资产-货币资金"])
135
- big_df["资产-应收账款"] = pd.to_numeric(big_df["资产-应收账款"])
136
- big_df["资产-存货"] = pd.to_numeric(big_df["资产-存货"])
137
- big_df["资产-总资产"] = pd.to_numeric(big_df["资产-总资产"])
138
- big_df["资产-总资产同比"] = pd.to_numeric(big_df["资产-总资产同比"])
139
- big_df["负债-应付账款"] = pd.to_numeric(big_df["负债-应付账款"])
140
- big_df["负债-预收账款"] = pd.to_numeric(big_df["负债-预收账款"])
141
- big_df["负债-总负债"] = pd.to_numeric(big_df["负债-总负债"])
142
- big_df["负债-总负债同比"] = pd.to_numeric(big_df["负债-总负债同比"])
143
- big_df["资产负债率"] = pd.to_numeric(big_df["资产负债率"])
144
- big_df["股东权益合计"] = pd.to_numeric(big_df["股东权益合计"])
145
- big_df["股东权益合计"] = pd.to_numeric(big_df["股东权益合计"])
146
- big_df["公告日期"] = pd.to_datetime(big_df["公告日期"]).dt.date
141
+ big_df["资产-货币资金"] = pd.to_numeric(big_df["资产-货币资金"], errors="coerce")
142
+ big_df["资产-应收账款"] = pd.to_numeric(big_df["资产-应收账款"], errors="coerce")
143
+ big_df["资产-存货"] = pd.to_numeric(big_df["资产-存货"], errors="coerce")
144
+ big_df["资产-总资产"] = pd.to_numeric(big_df["资产-总资产"], errors="coerce")
145
+ big_df["资产-总资产同比"] = pd.to_numeric(
146
+ big_df["资产-总资产同比"], errors="coerce"
147
+ )
148
+ big_df["负债-应付账款"] = pd.to_numeric(big_df["负债-应付账款"], errors="coerce")
149
+ big_df["负债-预收账款"] = pd.to_numeric(big_df["负债-预收账款"], errors="coerce")
150
+ big_df["负债-总负债"] = pd.to_numeric(big_df["负债-总负债"], errors="coerce")
151
+ big_df["负债-总负债同比"] = pd.to_numeric(
152
+ big_df["负债-总负债同比"], errors="coerce"
153
+ )
154
+ big_df["资产负债率"] = pd.to_numeric(big_df["资产负债率"], errors="coerce")
155
+ big_df["股东权益合计"] = pd.to_numeric(big_df["股东权益合计"], errors="coerce")
156
+ big_df["股东权益合计"] = pd.to_numeric(big_df["股东权益合计"], errors="coerce")
157
+ big_df["公告日期"] = pd.to_datetime(big_df["公告日期"], errors="coerce").dt.date
147
158
  return big_df
148
159
 
149
160
 
150
- def stock_lrb_em(date: str = "20081231") -> pd.DataFrame:
161
+ def stock_zcfz_bj_em(date: str = "20240331") -> pd.DataFrame:
162
+ """
163
+ 东方财富-数据中心-年报季报-业绩快报-资产负债表
164
+ https://data.eastmoney.com/bbsj/202003/zcfz.html
165
+ :param date: choice of {"20200331", "20200630", "20200930", "20201231", "..."}; 从 20100331 开始
166
+ :type date: str
167
+ :return: 资产负债表
168
+ :rtype: pandas.DataFrame
169
+ """
170
+ import warnings
171
+
172
+ warnings.filterwarnings(action="ignore", category=FutureWarning)
173
+ url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
174
+ params = {
175
+ "sortColumns": "NOTICE_DATE,SECURITY_CODE",
176
+ "sortTypes": "-1,-1",
177
+ "pageSize": "500",
178
+ "pageNumber": "1",
179
+ "reportName": "RPT_DMSK_FN_BALANCE",
180
+ "columns": "ALL",
181
+ "filter": f"""(TRADE_MARKET_CODE="069001017")
182
+ (REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')""",
183
+ }
184
+ r = requests.get(url, params=params)
185
+ data_json = r.json()
186
+ page_num = data_json["result"]["pages"]
187
+ big_df = pd.DataFrame()
188
+ tqdm = get_tqdm()
189
+ for page in tqdm(range(1, page_num + 1), leave=False):
190
+ params.update(
191
+ {
192
+ "pageNumber": page,
193
+ }
194
+ )
195
+ r = requests.get(url, params=params)
196
+ data_json = r.json()
197
+ temp_df = pd.DataFrame(data_json["result"]["data"])
198
+ big_df = pd.concat(objs=[big_df, temp_df], join="outer", ignore_index=True)
199
+
200
+ big_df.reset_index(inplace=True)
201
+ big_df["index"] = big_df.index + 1
202
+ big_df.columns = [
203
+ "序号",
204
+ "_",
205
+ "股票代码",
206
+ "_",
207
+ "_",
208
+ "股票简称",
209
+ "_",
210
+ "_",
211
+ "_",
212
+ "_",
213
+ "_",
214
+ "_",
215
+ "_",
216
+ "公告日期",
217
+ "_",
218
+ "资产-总资产",
219
+ "_",
220
+ "资产-货币资金",
221
+ "_",
222
+ "资产-应收账款",
223
+ "_",
224
+ "资产-存货",
225
+ "_",
226
+ "负债-总负债",
227
+ "负债-应付账款",
228
+ "_",
229
+ "负债-预收账款",
230
+ "_",
231
+ "股东权益合计",
232
+ "_",
233
+ "资产-总资产同比",
234
+ "负债-总负债同比",
235
+ "_",
236
+ "资产负债率",
237
+ "_",
238
+ "_",
239
+ "_",
240
+ "_",
241
+ "_",
242
+ "_",
243
+ "_",
244
+ "_",
245
+ "_",
246
+ "_",
247
+ "_",
248
+ "_",
249
+ "_",
250
+ "_",
251
+ "_",
252
+ "_",
253
+ "_",
254
+ "_",
255
+ "_",
256
+ "_",
257
+ "_",
258
+ "_",
259
+ "_",
260
+ "_",
261
+ ]
262
+ big_df = big_df[
263
+ [
264
+ "序号",
265
+ "股票代码",
266
+ "股票简称",
267
+ "资产-货币资金",
268
+ "资产-应收账款",
269
+ "资产-存货",
270
+ "资产-总资产",
271
+ "资产-总资产同比",
272
+ "负债-应付账款",
273
+ "负债-预收账款",
274
+ "负债-总负债",
275
+ "负债-总负债同比",
276
+ "资产负债率",
277
+ "股东权益合计",
278
+ "公告日期",
279
+ ]
280
+ ]
281
+
282
+ big_df["资产-货币资金"] = pd.to_numeric(big_df["资产-货币资金"], errors="coerce")
283
+ big_df["资产-应收账款"] = pd.to_numeric(big_df["资产-应收账款"], errors="coerce")
284
+ big_df["资产-存货"] = pd.to_numeric(big_df["资产-存货"], errors="coerce")
285
+ big_df["资产-总资产"] = pd.to_numeric(big_df["资产-总资产"], errors="coerce")
286
+ big_df["资产-总资产同比"] = pd.to_numeric(
287
+ big_df["资产-总资产同比"], errors="coerce"
288
+ )
289
+ big_df["负债-应付账款"] = pd.to_numeric(big_df["负债-应付账款"], errors="coerce")
290
+ big_df["负债-预收账款"] = pd.to_numeric(big_df["负债-预收账款"], errors="coerce")
291
+ big_df["负债-总负债"] = pd.to_numeric(big_df["负债-总负债"], errors="coerce")
292
+ big_df["负债-总负债同比"] = pd.to_numeric(
293
+ big_df["负债-总负债同比"], errors="coerce"
294
+ )
295
+ big_df["资产负债率"] = pd.to_numeric(big_df["资产负债率"], errors="coerce")
296
+ big_df["股东权益合计"] = pd.to_numeric(big_df["股东权益合计"], errors="coerce")
297
+ big_df["股东权益合计"] = pd.to_numeric(big_df["股东权益合计"], errors="coerce")
298
+ big_df["公告日期"] = pd.to_datetime(big_df["公告日期"], errors="coerce").dt.date
299
+ return big_df
300
+
301
+
302
+ def stock_lrb_em(date: str = "20240331") -> pd.DataFrame:
151
303
  """
152
304
  东方财富-数据中心-年报季报-业绩快报-利润表
153
305
  https://data.eastmoney.com/bbsj/202003/lrb.html
@@ -156,6 +308,9 @@ def stock_lrb_em(date: str = "20081231") -> pd.DataFrame:
156
308
  :return: 利润表
157
309
  :rtype: pandas.DataFrame
158
310
  """
311
+ import warnings
312
+
313
+ warnings.filterwarnings(action="ignore", category=FutureWarning)
159
314
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
160
315
  params = {
161
316
  "sortColumns": "NOTICE_DATE,SECURITY_CODE",
@@ -164,12 +319,14 @@ def stock_lrb_em(date: str = "20081231") -> pd.DataFrame:
164
319
  "pageNumber": "1",
165
320
  "reportName": "RPT_DMSK_FN_INCOME",
166
321
  "columns": "ALL",
167
- "filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE!="069001017")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')""",
322
+ "filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE!="069001017")
323
+ (REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')""",
168
324
  }
169
325
  r = requests.get(url, params=params)
170
326
  data_json = r.json()
171
327
  page_num = data_json["result"]["pages"]
172
328
  big_df = pd.DataFrame()
329
+ tqdm = get_tqdm()
173
330
  for page in tqdm(range(1, page_num + 1), leave=False):
174
331
  params.update(
175
332
  {
@@ -179,7 +336,7 @@ def stock_lrb_em(date: str = "20081231") -> pd.DataFrame:
179
336
  r = requests.get(url, params=params)
180
337
  data_json = r.json()
181
338
  temp_df = pd.DataFrame(data_json["result"]["data"])
182
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
339
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
183
340
 
184
341
  big_df.reset_index(inplace=True)
185
342
  big_df["index"] = big_df.index + 1
@@ -252,31 +409,44 @@ def stock_lrb_em(date: str = "20081231") -> pd.DataFrame:
252
409
  ]
253
410
  ]
254
411
 
255
- big_df["净利润"] = pd.to_numeric(big_df["净利润"])
256
- big_df["净利润同比"] = pd.to_numeric(big_df["净利润同比"])
257
- big_df["营业总收入"] = pd.to_numeric(big_df["营业总收入"])
258
- big_df["营业总收入同比"] = pd.to_numeric(big_df["营业总收入同比"])
259
- big_df["营业总支出-营业支出"] = pd.to_numeric(big_df["营业总支出-营业支出"])
260
- big_df["营业总支出-销售费用"] = pd.to_numeric(big_df["营业总支出-销售费用"])
261
- big_df["营业总支出-管理费用"] = pd.to_numeric(big_df["营业总支出-管理费用"])
262
- big_df["营业总支出-财务费用"] = pd.to_numeric(big_df["营业总支出-财务费用"])
263
- big_df["营业总支出-营业总支出"] = pd.to_numeric(big_df["营业总支出-营业总支出"])
264
- big_df["营业利润"] = pd.to_numeric(big_df["营业利润"])
265
- big_df["利润总额"] = pd.to_numeric(big_df["利润总额"])
266
- big_df["公告日期"] = pd.to_datetime(big_df["公告日期"]).dt.date
412
+ big_df["净利润"] = pd.to_numeric(big_df["净利润"], errors="coerce")
413
+ big_df["净利润同比"] = pd.to_numeric(big_df["净利润同比"], errors="coerce")
414
+ big_df["营业总收入"] = pd.to_numeric(big_df["营业总收入"], errors="coerce")
415
+ big_df["营业总收入同比"] = pd.to_numeric(big_df["营业总收入同比"], errors="coerce")
416
+ big_df["营业总支出-营业支出"] = pd.to_numeric(
417
+ big_df["营业总支出-营业支出"], errors="coerce"
418
+ )
419
+ big_df["营业总支出-销售费用"] = pd.to_numeric(
420
+ big_df["营业总支出-销售费用"], errors="coerce"
421
+ )
422
+ big_df["营业总支出-管理费用"] = pd.to_numeric(
423
+ big_df["营业总支出-管理费用"], errors="coerce"
424
+ )
425
+ big_df["营业总支出-财务费用"] = pd.to_numeric(
426
+ big_df["营业总支出-财务费用"], errors="coerce"
427
+ )
428
+ big_df["营业总支出-营业总支出"] = pd.to_numeric(
429
+ big_df["营业总支出-营业总支出"], errors="coerce"
430
+ )
431
+ big_df["营业利润"] = pd.to_numeric(big_df["营业利润"], errors="coerce")
432
+ big_df["利润总额"] = pd.to_numeric(big_df["利润总额"], errors="coerce")
433
+ big_df["公告日期"] = pd.to_datetime(big_df["公告日期"], errors="coerce").dt.date
267
434
 
268
435
  return big_df
269
436
 
270
437
 
271
- def stock_xjll_em(date: str = "20220331") -> pd.DataFrame:
438
+ def stock_xjll_em(date: str = "20240331") -> pd.DataFrame:
272
439
  """
273
440
  东方财富-数据中心-年报季报-业绩快报-现金流量表
274
- http://data.eastmoney.com/bbsj/202003/xjll.html
441
+ https://data.eastmoney.com/bbsj/202003/xjll.html
275
442
  :param date: choice of {"20200331", "20200630", "20200930", "20201231", "..."}; 从 20100331 开始
276
443
  :type date: str
277
444
  :return: 现金流量表
278
445
  :rtype: pandas.DataFrame
279
446
  """
447
+ import warnings
448
+
449
+ warnings.filterwarnings(action="ignore", category=FutureWarning)
280
450
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
281
451
  params = {
282
452
  "sortColumns": "NOTICE_DATE,SECURITY_CODE",
@@ -285,12 +455,14 @@ def stock_xjll_em(date: str = "20220331") -> pd.DataFrame:
285
455
  "pageNumber": "1",
286
456
  "reportName": "RPT_DMSK_FN_CASHFLOW",
287
457
  "columns": "ALL",
288
- "filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE!="069001017")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')""",
458
+ "filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE!="069001017")
459
+ (REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')""",
289
460
  }
290
461
  r = requests.get(url, params=params)
291
462
  data_json = r.json()
292
463
  page_num = data_json["result"]["pages"]
293
464
  big_df = pd.DataFrame()
465
+ tqdm = get_tqdm()
294
466
  for page in tqdm(range(1, page_num + 1), leave=False):
295
467
  params.update(
296
468
  {
@@ -300,7 +472,7 @@ def stock_xjll_em(date: str = "20220331") -> pd.DataFrame:
300
472
  r = requests.get(url, params=params)
301
473
  data_json = r.json()
302
474
  temp_df = pd.DataFrame(data_json["result"]["data"])
303
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
475
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
304
476
 
305
477
  big_df.reset_index(inplace=True)
306
478
  big_df["index"] = big_df.index + 1
@@ -372,25 +544,43 @@ def stock_xjll_em(date: str = "20220331") -> pd.DataFrame:
372
544
  ]
373
545
  ]
374
546
 
375
- big_df["净现金流-净现金流"] = pd.to_numeric(big_df["净现金流-净现金流"])
376
- big_df["净现金流-同比增长"] = pd.to_numeric(big_df["净现金流-同比增长"])
377
- big_df["经营性现金流-现金流量净额"] = pd.to_numeric(big_df["经营性现金流-现金流量净额"])
378
- big_df["经营性现金流-净现金流占比"] = pd.to_numeric(big_df["经营性现金流-净现金流占比"])
379
- big_df["投资性现金流-现金流量净额"] = pd.to_numeric(big_df["投资性现金流-现金流量净额"])
380
- big_df["投资性现金流-净现金流占比"] = pd.to_numeric(big_df["投资性现金流-净现金流占比"])
381
- big_df["融资性现金流-现金流量净额"] = pd.to_numeric(big_df["融资性现金流-现金流量净额"])
382
- big_df["融资性现金流-净现金流占比"] = pd.to_numeric(big_df["融资性现金流-净现金流占比"])
383
- big_df["公告日期"] = pd.to_datetime(big_df["公告日期"]).dt.date
384
-
547
+ big_df["净现金流-净现金流"] = pd.to_numeric(
548
+ big_df["净现金流-净现金流"], errors="coerce"
549
+ )
550
+ big_df["净现金流-同比增长"] = pd.to_numeric(
551
+ big_df["净现金流-同比增长"], errors="coerce"
552
+ )
553
+ big_df["经营性现金流-现金流量净额"] = pd.to_numeric(
554
+ big_df["经营性现金流-现金流量净额"], errors="coerce"
555
+ )
556
+ big_df["经营性现金流-净现金流占比"] = pd.to_numeric(
557
+ big_df["经营性现金流-净现金流占比"], errors="coerce"
558
+ )
559
+ big_df["投资性现金流-现金流量净额"] = pd.to_numeric(
560
+ big_df["投资性现金流-现金流量净额"], errors="coerce"
561
+ )
562
+ big_df["投资性现金流-净现金流占比"] = pd.to_numeric(
563
+ big_df["投资性现金流-净现金流占比"], errors="coerce"
564
+ )
565
+ big_df["融资性现金流-现金流量净额"] = pd.to_numeric(
566
+ big_df["融资性现金流-现金流量净额"], errors="coerce"
567
+ )
568
+ big_df["融资性现金流-净现金流占比"] = pd.to_numeric(
569
+ big_df["融资性现金流-净现金流占比"], errors="coerce"
570
+ )
571
+ big_df["公告日期"] = pd.to_datetime(big_df["公告日期"], errors="coerce").dt.date
385
572
  return big_df
386
573
 
387
574
 
388
575
  if __name__ == "__main__":
389
- stock_zcfz_em_df = stock_zcfz_em(date="20220331")
576
+ stock_zcfz_em_df = stock_zcfz_em(date="20240331")
390
577
  print(stock_zcfz_em_df)
391
578
 
392
- stock_lrb_em_df = stock_lrb_em(date="20220331")
579
+ stock_zcfz_bj_em_df = stock_zcfz_bj_em(date="20240331")
580
+ print(stock_zcfz_bj_em_df)
581
+
582
+ stock_lrb_em_df = stock_lrb_em(date="20240331")
393
583
  print(stock_lrb_em_df)
394
584
 
395
- stock_xjll_em_df = stock_xjll_em(date="20220331")
585
+ stock_xjll_em_df = stock_xjll_em(date="20240331")
396
586
  print(stock_xjll_em_df)