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,12 +1,11 @@
1
1
  # -*- coding:utf-8 -*-
2
2
  # !/usr/bin/env python
3
3
  """
4
- Date: 2023/3/10 16:32
4
+ Date: 2024/4/14 15:00
5
5
  Desc: 东方财富网-数据中心-沪深港通持股
6
6
  https://data.eastmoney.com/hsgtcg/
7
7
  沪深港通详情: https://finance.eastmoney.com/news/1622,20161118685370149.html
8
8
  """
9
- import json
10
9
 
11
10
  import pandas as pd
12
11
  import requests
@@ -24,9 +23,12 @@ def stock_hsgt_fund_flow_summary_em() -> pd.DataFrame:
24
23
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
25
24
  params = {
26
25
  "reportName": "RPT_MUTUAL_QUOTA",
27
- "columns": "TRADE_DATE,MUTUAL_TYPE,BOARD_TYPE,MUTUAL_TYPE_NAME,FUNDS_DIRECTION,INDEX_CODE,INDEX_NAME,BOARD_CODE",
28
- "quoteColumns": "status~07~BOARD_CODE,dayNetAmtIn~07~BOARD_CODE,dayAmtRemain~07~BOARD_CODE,dayAmtThreshold~07~BOARD_CODE,f104~07~BOARD_CODE,f105~07~BOARD_CODE,f106~07~BOARD_CODE,f3~03~INDEX_CODE~INDEX_f3,netBuyAmt~07~BOARD_CODE",
29
- 'quoteType': '0',
26
+ "columns": "TRADE_DATE,MUTUAL_TYPE,BOARD_TYPE,MUTUAL_TYPE_NAME,FUNDS_DIRECTION,"
27
+ "INDEX_CODE,INDEX_NAME,BOARD_CODE",
28
+ "quoteColumns": "status~07~BOARD_CODE,dayNetAmtIn~07~BOARD_CODE,dayAmtRemain~07~BOARD_CODE,"
29
+ "dayAmtThreshold~07~BOARD_CODE,f104~07~BOARD_CODE,f105~07~BOARD_CODE,"
30
+ "f106~07~BOARD_CODE,f3~03~INDEX_CODE~INDEX_f3,netBuyAmt~07~BOARD_CODE",
31
+ "quoteType": "0",
30
32
  "pageNumber": "1",
31
33
  "pageSize": "2000",
32
34
  "sortTypes": "1",
@@ -57,32 +59,34 @@ def stock_hsgt_fund_flow_summary_em() -> pd.DataFrame:
57
59
  "指数涨跌幅",
58
60
  "成交净买额",
59
61
  ]
60
- temp_df = temp_df[[
61
- "交易日",
62
- "类型",
63
- "板块",
64
- "资金方向",
65
- "交易状态",
66
- "成交净买额",
67
- "资金净流入",
68
- "当日资金余额",
69
- "上涨数",
70
- "持平数",
71
- "下跌数",
72
- "相关指数",
73
- "指数涨跌幅",
74
- ]]
75
- temp_df['交易日'] = pd.to_datetime(temp_df['交易日']).dt.date
76
- temp_df['成交净买额'] = pd.to_numeric(temp_df['成交净买额'], errors="coerce")
77
- temp_df['资金净流入'] = pd.to_numeric(temp_df['资金净流入'], errors="coerce")
78
- temp_df['当日资金余额'] = pd.to_numeric(temp_df['当日资金余额'], errors="coerce")
79
- temp_df['上涨数'] = pd.to_numeric(temp_df['上涨数'], errors="coerce")
80
- temp_df['持平数'] = pd.to_numeric(temp_df['持平数'], errors="coerce")
81
- temp_df['下跌数'] = pd.to_numeric(temp_df['下跌数'], errors="coerce")
82
- temp_df['指数涨跌幅'] = pd.to_numeric(temp_df['指数涨跌幅'], errors="coerce")
83
- temp_df['成交净买额'] = temp_df['成交净买额'] / 10000
84
- temp_df['资金净流入'] = temp_df['资金净流入'] / 10000
85
- temp_df['当日资金余额'] = temp_df['当日资金余额'] / 10000
62
+ temp_df = temp_df[
63
+ [
64
+ "交易日",
65
+ "类型",
66
+ "板块",
67
+ "资金方向",
68
+ "交易状态",
69
+ "成交净买额",
70
+ "资金净流入",
71
+ "当日资金余额",
72
+ "上涨数",
73
+ "持平数",
74
+ "下跌数",
75
+ "相关指数",
76
+ "指数涨跌幅",
77
+ ]
78
+ ]
79
+ temp_df["交易日"] = pd.to_datetime(temp_df["交易日"], errors="coerce").dt.date
80
+ temp_df["成交净买额"] = pd.to_numeric(temp_df["成交净买额"], errors="coerce")
81
+ temp_df["资金净流入"] = pd.to_numeric(temp_df["资金净流入"], errors="coerce")
82
+ temp_df["当日资金余额"] = pd.to_numeric(temp_df["当日资金余额"], errors="coerce")
83
+ temp_df["上涨数"] = pd.to_numeric(temp_df["上涨数"], errors="coerce")
84
+ temp_df["持平数"] = pd.to_numeric(temp_df["持平数"], errors="coerce")
85
+ temp_df["下跌数"] = pd.to_numeric(temp_df["下跌数"], errors="coerce")
86
+ temp_df["指数涨跌幅"] = pd.to_numeric(temp_df["指数涨跌幅"], errors="coerce")
87
+ temp_df["成交净买额"] = temp_df["成交净买额"] / 10000
88
+ temp_df["资金净流入"] = temp_df["资金净流入"] / 10000
89
+ temp_df["当日资金余额"] = temp_df["当日资金余额"] / 10000
86
90
  return temp_df
87
91
 
88
92
 
@@ -103,7 +107,8 @@ def stock_hk_ggt_components_em() -> pd.DataFrame:
103
107
  "fltt": "2",
104
108
  "fid": "f3",
105
109
  "fs": "b:DLMK0146,b:DLMK0144",
106
- "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152",
110
+ "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f23,f24,"
111
+ "f25,f26,f22,f33,f11,f62,f128,f136,f115,f152",
107
112
  "_": "1639974456250",
108
113
  }
109
114
  r = requests.get(url, params=params)
@@ -167,312 +172,6 @@ def stock_hk_ggt_components_em() -> pd.DataFrame:
167
172
  return temp_df
168
173
 
169
174
 
170
- def stock_hsgt_north_net_flow_in_em(symbol: str = "沪股通") -> pd.DataFrame:
171
- """
172
- 东方财富网-数据中心-沪深港通持股-北向概括-净流入
173
- http://data.eastmoney.com/hsgtcg/
174
- :param symbol: choice of {"沪股通", "深股通", "北上"}
175
- :type symbol: str
176
- :return: 东方财富网-数据中心-沪深港通持股-北向概括-净流入
177
- :rtype: pandas.DataFrame
178
- """
179
- url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
180
- params = {
181
- "fields1": "f1,f3,f5",
182
- "fields2": "f51,f52",
183
- "klt": "101",
184
- "lmt": "5000",
185
- "ut": "b2884a393a59ad64002292a3e90d46a5",
186
- "cb": "jQuery18305732402561585701_1584961751919",
187
- "_": "1584962164273",
188
- }
189
- r = requests.get(url, params=params)
190
- data_text = r.text
191
- data_json = json.loads(data_text[data_text.find("{") : -2])
192
- if symbol == "沪股通":
193
- temp_df = (
194
- pd.DataFrame(data_json["data"]["hk2sh"])
195
- .iloc[:, 0]
196
- .str.split(",", expand=True)
197
- )
198
- temp_df.columns = ["date", "value"]
199
- temp_df["value"] = pd.to_numeric(temp_df["value"])
200
- return temp_df
201
- if symbol == "深股通":
202
- temp_df = (
203
- pd.DataFrame(data_json["data"]["hk2sz"])
204
- .iloc[:, 0]
205
- .str.split(",", expand=True)
206
- )
207
- temp_df.columns = ["date", "value"]
208
- temp_df["value"] = pd.to_numeric(temp_df["value"])
209
- return temp_df
210
- if symbol == "北上":
211
- temp_df = (
212
- pd.DataFrame(data_json["data"]["s2n"])
213
- .iloc[:, 0]
214
- .str.split(",", expand=True)
215
- )
216
- temp_df.columns = ["date", "value"]
217
- temp_df["value"] = pd.to_numeric(temp_df["value"])
218
- return temp_df
219
-
220
-
221
- def stock_hsgt_north_cash_em(symbol: str = "沪股通") -> pd.DataFrame:
222
- """
223
- 东方财富网-数据中心-沪深港通持股-北向概括-资金余额
224
- http://data.eastmoney.com/hsgtcg/
225
- :param symbol: choice of {"沪股通", "深股通", "北上"}
226
- :type symbol: str
227
- :return: 东方财富网-数据中心-沪深港通持股-北向概括-资金余额
228
- :rtype: pandas.DataFrame
229
- """
230
- url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
231
- params = {
232
- "fields1": "f1,f3,f5",
233
- "fields2": "f51,f53",
234
- "klt": "101",
235
- "lmt": "5000",
236
- "ut": "b2884a393a59ad64002292a3e90d46a5",
237
- "cb": "jQuery18305732402561585701_1584961751919",
238
- "_": "1584962164273",
239
- }
240
- r = requests.get(url, params=params)
241
- data_text = r.text
242
- data_json = json.loads(data_text[data_text.find("{") : -2])
243
- if symbol == "沪股通":
244
- temp_df = (
245
- pd.DataFrame(data_json["data"]["hk2sh"])
246
- .iloc[:, 0]
247
- .str.split(",", expand=True)
248
- )
249
- temp_df.columns = ["date", "value"]
250
- temp_df["value"] = pd.to_numeric(temp_df["value"])
251
- return temp_df
252
- if symbol == "深股通":
253
- temp_df = (
254
- pd.DataFrame(data_json["data"]["hk2sz"])
255
- .iloc[:, 0]
256
- .str.split(",", expand=True)
257
- )
258
- temp_df.columns = ["date", "value"]
259
- temp_df["value"] = pd.to_numeric(temp_df["value"])
260
- return temp_df
261
- if symbol == "北上":
262
- temp_df = (
263
- pd.DataFrame(data_json["data"]["s2n"])
264
- .iloc[:, 0]
265
- .str.split(",", expand=True)
266
- )
267
- temp_df.columns = ["date", "value"]
268
- temp_df["value"] = pd.to_numeric(temp_df["value"])
269
- return temp_df
270
-
271
-
272
- def stock_hsgt_north_acc_flow_in_em(symbol: str = "沪股通") -> pd.DataFrame:
273
- """
274
- 东方财富网-数据中心-沪深港通持股-北向概况-累计净流入
275
- http://data.eastmoney.com/hsgtcg/
276
- :param symbol: choice of {"沪股通", "深股通", "北上"}
277
- :type symbol: str
278
- :return: 东方财富网-数据中心-沪深港通持股-北向概括-累计净流入
279
- :rtype: pandas.DataFrame
280
- """
281
- url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
282
- params = {
283
- "fields1": "f1,f3,f5",
284
- "fields2": "f51,f54",
285
- "klt": "101",
286
- "lmt": "5000",
287
- "ut": "b2884a393a59ad64002292a3e90d46a5",
288
- "cb": "jQuery18305732402561585701_1584961751919",
289
- "_": "1584962164273",
290
- }
291
- r = requests.get(url, params=params)
292
- data_text = r.text
293
- data_json = json.loads(data_text[data_text.find("{") : -2])
294
- if symbol == "沪股通":
295
- temp_df = (
296
- pd.DataFrame(data_json["data"]["hk2sh"])
297
- .iloc[:, 0]
298
- .str.split(",", expand=True)
299
- )
300
- temp_df.columns = ["date", "value"]
301
- temp_df["value"] = pd.to_numeric(temp_df["value"])
302
- return temp_df
303
- if symbol == "深股通":
304
- temp_df = (
305
- pd.DataFrame(data_json["data"]["hk2sz"])
306
- .iloc[:, 0]
307
- .str.split(",", expand=True)
308
- )
309
- temp_df.columns = ["date", "value"]
310
- temp_df["value"] = pd.to_numeric(temp_df["value"])
311
- return temp_df
312
- if symbol == "北上":
313
- temp_df = (
314
- pd.DataFrame(data_json["data"]["s2n"])
315
- .iloc[:, 0]
316
- .str.split(",", expand=True)
317
- )
318
- temp_df.columns = ["date", "value"]
319
- temp_df["value"] = pd.to_numeric(temp_df["value"])
320
- return temp_df
321
-
322
-
323
- def stock_hsgt_south_net_flow_in_em(symbol: str = "沪股通") -> pd.DataFrame:
324
- """
325
- 东方财富网-数据中心-沪深港通持股-南向概括-净流入
326
- http://data.eastmoney.com/hsgtcg/
327
- :param symbol: choice of {"沪股通", "深股通", "南下"}
328
- :type symbol: str
329
- :return: 东方财富网-数据中心-沪深港通持股-南向概括-净流入
330
- :rtype: pandas.DataFrame
331
- """
332
- url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
333
- params = {
334
- "fields1": "f2,f4,f6",
335
- "fields2": "f51,f52",
336
- "klt": "101",
337
- "lmt": "5000",
338
- "ut": "b2884a393a59ad64002292a3e90d46a5",
339
- "cb": "jQuery18307854355493858363_1584963487410",
340
- "_": "1584964176697",
341
- }
342
- r = requests.get(url, params=params)
343
- data_text = r.text
344
- data_json = json.loads(data_text[data_text.find("{") : -2])
345
- if symbol == "沪股通":
346
- temp_df = (
347
- pd.DataFrame(data_json["data"]["sh2hk"])
348
- .iloc[:, 0]
349
- .str.split(",", expand=True)
350
- )
351
- temp_df.columns = ["date", "value"]
352
- temp_df["value"] = pd.to_numeric(temp_df["value"])
353
- return temp_df
354
- if symbol == "深股通":
355
- temp_df = (
356
- pd.DataFrame(data_json["data"]["sz2hk"])
357
- .iloc[:, 0]
358
- .str.split(",", expand=True)
359
- )
360
- temp_df.columns = ["date", "value"]
361
- temp_df["value"] = pd.to_numeric(temp_df["value"])
362
- return temp_df
363
- if symbol == "南下":
364
- temp_df = (
365
- pd.DataFrame(data_json["data"]["n2s"])
366
- .iloc[:, 0]
367
- .str.split(",", expand=True)
368
- )
369
- temp_df.columns = ["date", "value"]
370
- temp_df["value"] = pd.to_numeric(temp_df["value"])
371
- return temp_df
372
-
373
-
374
- def stock_hsgt_south_cash_em(symbol: str = "沪股通") -> pd.DataFrame:
375
- """
376
- 东方财富网-数据中心-沪深港通持股-南向概括-资金余额
377
- http://data.eastmoney.com/hsgtcg/
378
- :param symbol: choice of {"沪股通", "深股通", "南下"}
379
- :type symbol: str
380
- :return: 东方财富网-数据中心-沪深港通持股-南向概括-资金余额
381
- :rtype: pandas.DataFrame
382
- """
383
- url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
384
- params = {
385
- "fields1": "f2,f4,f6",
386
- "fields2": "f51,f53",
387
- "klt": "101",
388
- "lmt": "5000",
389
- "ut": "b2884a393a59ad64002292a3e90d46a5",
390
- "cb": "jQuery18307854355493858363_1584963487410",
391
- "_": "1584964176697",
392
- }
393
- r = requests.get(url, params=params)
394
- data_text = r.text
395
- data_json = json.loads(data_text[data_text.find("{") : -2])
396
- if symbol == "沪股通":
397
- temp_df = (
398
- pd.DataFrame(data_json["data"]["sh2hk"])
399
- .iloc[:, 0]
400
- .str.split(",", expand=True)
401
- )
402
- temp_df.columns = ["date", "value"]
403
- temp_df["value"] = pd.to_numeric(temp_df["value"])
404
- return temp_df
405
- if symbol == "深股通":
406
- temp_df = (
407
- pd.DataFrame(data_json["data"]["sz2hk"])
408
- .iloc[:, 0]
409
- .str.split(",", expand=True)
410
- )
411
- temp_df.columns = ["date", "value"]
412
- temp_df["value"] = pd.to_numeric(temp_df["value"])
413
- return temp_df
414
- if symbol == "南下":
415
- temp_df = (
416
- pd.DataFrame(data_json["data"]["n2s"])
417
- .iloc[:, 0]
418
- .str.split(",", expand=True)
419
- )
420
- temp_df.columns = ["date", "value"]
421
- temp_df["value"] = pd.to_numeric(temp_df["value"])
422
- return temp_df
423
-
424
-
425
- def stock_hsgt_south_acc_flow_in_em(symbol: str = "沪股通") -> pd.DataFrame:
426
- """
427
- 东方财富网-数据中心-沪深港通持股-南向概括-累计净流入
428
- http://data.eastmoney.com/hsgtcg/
429
- :param symbol: choice of {"沪股通", "深股通", "南下"}
430
- :type symbol: str
431
- :return: 东方财富网-数据中心-沪深港通持股-南向概括-累计净流入
432
- :rtype: pandas.DataFrame
433
- """
434
- url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
435
- params = {
436
- "fields1": "f2,f4,f6",
437
- "fields2": "f51,f54",
438
- "klt": "101",
439
- "lmt": "5000",
440
- "ut": "b2884a393a59ad64002292a3e90d46a5",
441
- "cb": "jQuery18307854355493858363_1584963487410",
442
- "_": "1584964176697",
443
- }
444
- r = requests.get(url, params=params)
445
- data_text = r.text
446
- data_json = json.loads(data_text[data_text.find("{") : -2])
447
- if symbol == "沪股通":
448
- temp_df = (
449
- pd.DataFrame(data_json["data"]["sh2hk"])
450
- .iloc[:, 0]
451
- .str.split(",", expand=True)
452
- )
453
- temp_df.columns = ["date", "value"]
454
- temp_df["value"] = pd.to_numeric(temp_df["value"])
455
- return temp_df
456
- if symbol == "深股通":
457
- temp_df = (
458
- pd.DataFrame(data_json["data"]["sz2hk"])
459
- .iloc[:, 0]
460
- .str.split(",", expand=True)
461
- )
462
- temp_df.columns = ["date", "value"]
463
- temp_df["value"] = pd.to_numeric(temp_df["value"])
464
- return temp_df
465
- if symbol == "南下":
466
- temp_df = (
467
- pd.DataFrame(data_json["data"]["n2s"])
468
- .iloc[:, 0]
469
- .str.split(",", expand=True)
470
- )
471
- temp_df.columns = ["date", "value"]
472
- temp_df["value"] = pd.to_numeric(temp_df["value"])
473
- return temp_df
474
-
475
-
476
175
  def stock_hsgt_hold_stock_em(
477
176
  market: str = "沪股通", indicator: str = "5日排行"
478
177
  ) -> pd.DataFrame:
@@ -496,6 +195,8 @@ def stock_hsgt_hold_stock_em(
496
195
  .strip(")")
497
196
  )
498
197
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
198
+ indicator_type = ""
199
+ filter_str = ""
499
200
  if indicator == "今日排行":
500
201
  indicator_type = "1"
501
202
  if indicator == "3日排行":
@@ -511,9 +212,7 @@ def stock_hsgt_hold_stock_em(
511
212
  if indicator == "年排行":
512
213
  indicator_type = "Y"
513
214
  if market == "北向":
514
- filter_str = (
515
- f"""(TRADE_DATE='{date}')(INTERVAL_TYPE="{indicator_type}")"""
516
- )
215
+ filter_str = f"""(TRADE_DATE='{date}')(INTERVAL_TYPE="{indicator_type}")"""
517
216
  elif market == "沪股通":
518
217
  filter_str = f"""(TRADE_DATE='{date}')(INTERVAL_TYPE="{indicator_type}")(MUTUAL_TYPE="001")"""
519
218
  elif market == "深股通":
@@ -612,8 +311,12 @@ def stock_hsgt_hold_stock_em(
612
311
  big_df["今日涨跌幅"] = pd.to_numeric(big_df["今日涨跌幅"], errors="coerce")
613
312
  big_df["今日持股-股数"] = pd.to_numeric(big_df["今日持股-股数"], errors="coerce")
614
313
  big_df["今日持股-市值"] = pd.to_numeric(big_df["今日持股-市值"], errors="coerce")
615
- big_df["今日持股-占流通股比"] = pd.to_numeric(big_df["今日持股-占流通股比"], errors="coerce")
616
- big_df["今日持股-占总股本比"] = pd.to_numeric(big_df["今日持股-占总股本比"], errors="coerce")
314
+ big_df["今日持股-占流通股比"] = pd.to_numeric(
315
+ big_df["今日持股-占流通股比"], errors="coerce"
316
+ )
317
+ big_df["今日持股-占总股本比"] = pd.to_numeric(
318
+ big_df["今日持股-占总股本比"], errors="coerce"
319
+ )
617
320
  big_df[f'{indicator.split("排")[0]}增持估计-股数'] = pd.to_numeric(
618
321
  big_df[f'{indicator.split("排")[0]}增持估计-股数'], errors="coerce"
619
322
  )
@@ -654,6 +357,7 @@ def stock_hsgt_stock_statistics_em(
654
357
  """
655
358
  start_date = "-".join([start_date[:4], start_date[4:6], start_date[6:]])
656
359
  end_date = "-".join([end_date[:4], end_date[4:6], end_date[6:]])
360
+ big_df = pd.DataFrame()
657
361
  if symbol == "南向持股":
658
362
  params = {
659
363
  "sortColumns": "TRADE_DATE",
@@ -669,9 +373,7 @@ def stock_hsgt_stock_statistics_em(
669
373
  }
670
374
  if start_date == end_date:
671
375
  params.update(
672
- {
673
- "filter": f"""(INTERVAL_TYPE="1")(RN=1)(TRADE_DATE='{start_date}')"""
674
- }
376
+ {"filter": f"""(INTERVAL_TYPE="1")(RN=1)(TRADE_DATE='{start_date}')"""}
675
377
  )
676
378
  url = "http://datacenter-web.eastmoney.com/api/data/v1/get"
677
379
  r = requests.get(url, params=params)
@@ -736,10 +438,18 @@ def stock_hsgt_stock_statistics_em(
736
438
  big_df["当日涨跌幅"] = pd.to_numeric(big_df["当日涨跌幅"], errors="coerce")
737
439
  big_df["持股数量"] = pd.to_numeric(big_df["持股数量"], errors="coerce")
738
440
  big_df["持股市值"] = pd.to_numeric(big_df["持股市值"], errors="coerce")
739
- big_df["持股数量占发行股百分比"] = pd.to_numeric(big_df["持股数量占发行股百分比"], errors="coerce")
740
- big_df["持股市值变化-1日"] = pd.to_numeric(big_df["持股市值变化-1日"], errors="coerce")
741
- big_df["持股市值变化-5日"] = pd.to_numeric(big_df["持股市值变化-5日"], errors="coerce")
742
- big_df["持股市值变化-10日"] = pd.to_numeric(big_df["持股市值变化-10日"], errors="coerce")
441
+ big_df["持股数量占发行股百分比"] = pd.to_numeric(
442
+ big_df["持股数量占发行股百分比"], errors="coerce"
443
+ )
444
+ big_df["持股市值变化-1日"] = pd.to_numeric(
445
+ big_df["持股市值变化-1日"], errors="coerce"
446
+ )
447
+ big_df["持股市值变化-5日"] = pd.to_numeric(
448
+ big_df["持股市值变化-5日"], errors="coerce"
449
+ )
450
+ big_df["持股市值变化-10日"] = pd.to_numeric(
451
+ big_df["持股市值变化-10日"], errors="coerce"
452
+ )
743
453
  elif symbol == "北向持股":
744
454
  params = {
745
455
  "sortColumns": "TRADE_DATE",
@@ -836,10 +546,18 @@ def stock_hsgt_stock_statistics_em(
836
546
  big_df["当日涨跌幅"] = pd.to_numeric(big_df["当日涨跌幅"], errors="coerce")
837
547
  big_df["持股数量"] = pd.to_numeric(big_df["持股数量"], errors="coerce")
838
548
  big_df["持股市值"] = pd.to_numeric(big_df["持股市值"], errors="coerce")
839
- big_df["持股数量占发行股百分比"] = pd.to_numeric(big_df["持股数量占发行股百分比"], errors="coerce")
840
- big_df["持股市值变化-1日"] = pd.to_numeric(big_df["持股市值变化-1日"], errors="coerce")
841
- big_df["持股市值变化-5日"] = pd.to_numeric(big_df["持股市值变化-5日"], errors="coerce")
842
- big_df["持股市值变化-10日"] = pd.to_numeric(big_df["持股市值变化-10日"], errors="coerce")
549
+ big_df["持股数量占发行股百分比"] = pd.to_numeric(
550
+ big_df["持股数量占发行股百分比"], errors="coerce"
551
+ )
552
+ big_df["持股市值变化-1日"] = pd.to_numeric(
553
+ big_df["持股市值变化-1日"], errors="coerce"
554
+ )
555
+ big_df["持股市值变化-5日"] = pd.to_numeric(
556
+ big_df["持股市值变化-5日"], errors="coerce"
557
+ )
558
+ big_df["持股市值变化-10日"] = pd.to_numeric(
559
+ big_df["持股市值变化-10日"], errors="coerce"
560
+ )
843
561
  elif symbol == "沪股通持股":
844
562
  params = {
845
563
  "sortColumns": "TRADE_DATE",
@@ -934,10 +652,18 @@ def stock_hsgt_stock_statistics_em(
934
652
  big_df["当日涨跌幅"] = pd.to_numeric(big_df["当日涨跌幅"], errors="coerce")
935
653
  big_df["持股数量"] = pd.to_numeric(big_df["持股数量"], errors="coerce")
936
654
  big_df["持股市值"] = pd.to_numeric(big_df["持股市值"], errors="coerce")
937
- big_df["持股数量占发行股百分比"] = pd.to_numeric(big_df["持股数量占发行股百分比"], errors="coerce")
938
- big_df["持股市值变化-1日"] = pd.to_numeric(big_df["持股市值变化-1日"], errors="coerce")
939
- big_df["持股市值变化-5日"] = pd.to_numeric(big_df["持股市值变化-5日"], errors="coerce")
940
- big_df["持股市值变化-10日"] = pd.to_numeric(big_df["持股市值变化-10日"], errors="coerce")
655
+ big_df["持股数量占发行股百分比"] = pd.to_numeric(
656
+ big_df["持股数量占发行股百分比"], errors="coerce"
657
+ )
658
+ big_df["持股市值变化-1日"] = pd.to_numeric(
659
+ big_df["持股市值变化-1日"], errors="coerce"
660
+ )
661
+ big_df["持股市值变化-5日"] = pd.to_numeric(
662
+ big_df["持股市值变化-5日"], errors="coerce"
663
+ )
664
+ big_df["持股市值变化-10日"] = pd.to_numeric(
665
+ big_df["持股市值变化-10日"], errors="coerce"
666
+ )
941
667
  elif symbol == "深股通持股":
942
668
  params = {
943
669
  "sortColumns": "TRADE_DATE",
@@ -1032,10 +758,18 @@ def stock_hsgt_stock_statistics_em(
1032
758
  big_df["当日涨跌幅"] = pd.to_numeric(big_df["当日涨跌幅"], errors="coerce")
1033
759
  big_df["持股数量"] = pd.to_numeric(big_df["持股数量"], errors="coerce")
1034
760
  big_df["持股市值"] = pd.to_numeric(big_df["持股市值"], errors="coerce")
1035
- big_df["持股数量占发行股百分比"] = pd.to_numeric(big_df["持股数量占发行股百分比"], errors="coerce")
1036
- big_df["持股市值变化-1日"] = pd.to_numeric(big_df["持股市值变化-1日"], errors="coerce")
1037
- big_df["持股市值变化-5日"] = pd.to_numeric(big_df["持股市值变化-5日"], errors="coerce")
1038
- big_df["持股市值变化-10日"] = pd.to_numeric(big_df["持股市值变化-10日"], errors="coerce")
761
+ big_df["持股数量占发行股百分比"] = pd.to_numeric(
762
+ big_df["持股数量占发行股百分比"], errors="coerce"
763
+ )
764
+ big_df["持股市值变化-1日"] = pd.to_numeric(
765
+ big_df["持股市值变化-1日"], errors="coerce"
766
+ )
767
+ big_df["持股市值变化-5日"] = pd.to_numeric(
768
+ big_df["持股市值变化-5日"], errors="coerce"
769
+ )
770
+ big_df["持股市值变化-10日"] = pd.to_numeric(
771
+ big_df["持股市值变化-10日"], errors="coerce"
772
+ )
1039
773
  return big_df
1040
774
 
1041
775
 
@@ -1046,7 +780,7 @@ def stock_hsgt_institution_statistics_em(
1046
780
  ):
1047
781
  """
1048
782
  东方财富网-数据中心-沪深港通-沪深港通持股-每日机构统计
1049
- http://data.eastmoney.com/hsgtcg/InstitutionStatistics.aspx
783
+ https://data.eastmoney.com/hsgtcg/InstitutionStatistics.aspx
1050
784
  :param market: choice of {"北向持股", "南向持股", "沪股通持股", "深股通持股"}
1051
785
  :type market: str
1052
786
  :param start_date: 指定数据获取开始的时间, e.g., "20200713"
@@ -1310,17 +1044,24 @@ def stock_hsgt_institution_statistics_em(
1310
1044
  return big_df
1311
1045
 
1312
1046
 
1313
- def stock_hsgt_hist_em(symbol: str = "沪股通") -> pd.DataFrame:
1047
+ def stock_hsgt_hist_em(symbol: str = "北向资金") -> pd.DataFrame:
1314
1048
  """
1315
1049
  东方财富网-数据中心-资金流向-沪深港通资金流向-沪深港通历史数据
1316
- http://data.eastmoney.com/hsgt/index.html
1317
- :param symbol: choice of {"沪股通", "深股通", "港股通沪", "港股通深"}
1050
+ https://data.eastmoney.com/hsgt/index.html
1051
+ :param symbol: choice of {"北向资金", "沪股通", "深股通", "南向资金", "港股通沪", "港股通深"}
1318
1052
  :type symbol: str
1319
1053
  :return: 沪深港通历史数据
1320
1054
  :rtype: pandas.DataFrame
1321
1055
  """
1322
- symbol_map = {"沪股通": "1", "深股通": "3", "港股通沪": "2", "港股通深": "4"}
1323
- url = "http://datacenter-web.eastmoney.com/api/data/v1/get"
1056
+ symbol_map = {
1057
+ "北向资金": "5",
1058
+ "沪股通": "1",
1059
+ "深股通": "3",
1060
+ "南向资金": "6",
1061
+ "港股通沪": "2",
1062
+ "港股通深": "4",
1063
+ }
1064
+ url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
1324
1065
  params = {
1325
1066
  "sortColumns": "TRADE_DATE",
1326
1067
  "sortTypes": "-1",
@@ -1341,11 +1082,15 @@ def stock_hsgt_hist_em(symbol: str = "沪股通") -> pd.DataFrame:
1341
1082
  r = requests.get(url, params=params)
1342
1083
  data_json = r.json()
1343
1084
  temp_df = pd.DataFrame(data_json["result"]["data"])
1344
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
1345
- if symbol == "沪股通":
1085
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
1086
+ if symbol == "北向资金":
1087
+ index_name = "沪深300"
1088
+ elif symbol == "沪股通":
1346
1089
  index_name = "上证指数"
1347
1090
  elif symbol == "深股通":
1348
1091
  index_name = "深证指数"
1092
+ elif symbol == "南向资金":
1093
+ index_name = "沪深300"
1349
1094
  else:
1350
1095
  index_name = "恒生指数"
1351
1096
 
@@ -1359,11 +1104,12 @@ def stock_hsgt_hist_em(symbol: str = "沪股通") -> pd.DataFrame:
1359
1104
  "ACCUM_DEAL_AMT": "历史累计净买额",
1360
1105
  "BUY_AMT": "买入成交额",
1361
1106
  "SELL_AMT": "卖出成交额",
1362
- "LEAD_STOCKS_CODE": "-",
1107
+ "LEAD_STOCKS_CODE": "领涨股-代码",
1363
1108
  "LEAD_STOCKS_NAME": "领涨股",
1364
- "LS_CHANGE_RATE": "领涨股涨跌幅",
1109
+ "LS_CHANGE_RATE": "领涨股-涨跌幅",
1365
1110
  "INDEX_CLOSE_PRICE": index_name,
1366
- "INDEX_CHANGE_RATE": "涨跌幅",
1111
+ "INDEX_CHANGE_RATE": f"{index_name}-涨跌幅",
1112
+ "HOLD_MARKET_CAP": "持股市值",
1367
1113
  },
1368
1114
  inplace=True,
1369
1115
  )
@@ -1376,25 +1122,39 @@ def stock_hsgt_hist_em(symbol: str = "沪股通") -> pd.DataFrame:
1376
1122
  "历史累计净买额",
1377
1123
  "当日资金流入",
1378
1124
  "当日余额",
1125
+ "持股市值",
1379
1126
  "领涨股",
1380
- "领涨股涨跌幅",
1127
+ "领涨股-涨跌幅",
1381
1128
  index_name,
1382
- "涨跌幅",
1129
+ f"{index_name}-涨跌幅",
1130
+ "领涨股-代码",
1383
1131
  ]
1384
1132
  ]
1385
- big_df["日期"] = pd.to_datetime(big_df["日期"]).dt.date
1386
- big_df["当日资金流入"] = pd.to_numeric(big_df["当日资金流入"]) / 100
1387
- big_df["当日余额"] = pd.to_numeric(big_df["当日余额"]) / 100
1133
+ big_df["日期"] = pd.to_datetime(big_df["日期"], errors="coerce").dt.date
1134
+ big_df.sort_values(["日期"], inplace=True, ignore_index=True)
1135
+ big_df["当日资金流入"] = (
1136
+ pd.to_numeric(big_df["当日资金流入"], errors="coerce") / 100
1137
+ )
1138
+ big_df["当日余额"] = pd.to_numeric(big_df["当日余额"], errors="coerce") / 100
1388
1139
  if symbol == "沪股通" or symbol == "深股通":
1389
- big_df["历史累计净买额"] = pd.to_numeric(big_df["历史累计净买额"]) / 100
1140
+ big_df["历史累计净买额"] = (
1141
+ pd.to_numeric(big_df["历史累计净买额"], errors="coerce") / 100
1142
+ )
1390
1143
  else:
1391
- big_df["历史累计净买额"] = pd.to_numeric(big_df["历史累计净买额"]) / 100 / 10000
1392
- big_df["当日成交净买额"] = pd.to_numeric(big_df["当日成交净买额"]) / 100
1393
- big_df["买入成交额"] = pd.to_numeric(big_df["买入成交额"]) / 100
1394
- big_df["卖出成交额"] = pd.to_numeric(big_df["卖出成交额"]) / 100
1395
- big_df["领涨股涨跌幅"] = pd.to_numeric(big_df["领涨股涨跌幅"])
1396
- big_df[index_name] = pd.to_numeric(big_df[index_name])
1397
- big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"])
1144
+ big_df["历史累计净买额"] = (
1145
+ pd.to_numeric(big_df["历史累计净买额"], errors="coerce") / 100 / 10000
1146
+ )
1147
+ big_df["当日成交净买额"] = (
1148
+ pd.to_numeric(big_df["当日成交净买额"], errors="coerce") / 100
1149
+ )
1150
+ big_df["买入成交额"] = pd.to_numeric(big_df["买入成交额"], errors="coerce") / 100
1151
+ big_df["卖出成交额"] = pd.to_numeric(big_df["卖出成交额"], errors="coerce") / 100
1152
+ big_df["领涨股-涨跌幅"] = pd.to_numeric(big_df["领涨股-涨跌幅"], errors="coerce")
1153
+ big_df[index_name] = pd.to_numeric(big_df[index_name], errors="coerce")
1154
+ big_df[f"{index_name}-涨跌幅"] = pd.to_numeric(
1155
+ big_df[f"{index_name}-涨跌幅"], errors="coerce"
1156
+ )
1157
+ big_df["持股市值"] = pd.to_numeric(big_df["持股市值"], errors="coerce")
1398
1158
  return big_df
1399
1159
 
1400
1160
 
@@ -1414,9 +1174,7 @@ def stock_hsgt_board_rank_em(
1414
1174
  url = "https://data.eastmoney.com/hsgtcg/hy.html"
1415
1175
  r = requests.get(url)
1416
1176
  soup = BeautifulSoup(r.text, "lxml")
1417
- current_date = (
1418
- soup.find(attrs={"id": "bkph_date"}).text.strip("(").strip(")")
1419
- )
1177
+ current_date = soup.find(attrs={"id": "bkph_date"}).text.strip("(").strip(")")
1420
1178
  symbol_map = {
1421
1179
  "北向资金增持行业板块排行": "5",
1422
1180
  "北向资金增持概念板块排行": "4",
@@ -1509,15 +1267,33 @@ def stock_hsgt_board_rank_em(
1509
1267
  ]
1510
1268
  ]
1511
1269
  temp_df["最新涨跌幅"] = pd.to_numeric(temp_df["最新涨跌幅"], errors="coerce")
1512
- temp_df["北向资金今日持股-股票只数"] = pd.to_numeric(temp_df["北向资金今日持股-股票只数"], errors="coerce")
1513
- temp_df["北向资金今日持股-市值"] = pd.to_numeric(temp_df["北向资金今日持股-市值"], errors="coerce")
1514
- temp_df["北向资金今日持股-占板块比"] = pd.to_numeric(temp_df["北向资金今日持股-占板块比"], errors="coerce")
1515
- temp_df["北向资金今日持股-占北向资金比"] = pd.to_numeric(temp_df["北向资金今日持股-占北向资金比"], errors="coerce")
1516
- temp_df["北向资金今日增持估计-股票只数"] = pd.to_numeric(temp_df["北向资金今日增持估计-股票只数"], errors="coerce")
1517
- temp_df["北向资金今日增持估计-市值"] = pd.to_numeric(temp_df["北向资金今日增持估计-市值"], errors="coerce")
1518
- temp_df["北向资金今日增持估计-市值增幅"] = pd.to_numeric(temp_df["北向资金今日增持估计-市值增幅"], errors="coerce")
1519
- temp_df["北向资金今日增持估计-占板块比"] = pd.to_numeric(temp_df["北向资金今日增持估计-占板块比"], errors="coerce")
1520
- temp_df["北向资金今日增持估计-占北向资金比"] = pd.to_numeric(temp_df["北向资金今日增持估计-占北向资金比"], errors="coerce")
1270
+ temp_df["北向资金今日持股-股票只数"] = pd.to_numeric(
1271
+ temp_df["北向资金今日持股-股票只数"], errors="coerce"
1272
+ )
1273
+ temp_df["北向资金今日持股-市值"] = pd.to_numeric(
1274
+ temp_df["北向资金今日持股-市值"], errors="coerce"
1275
+ )
1276
+ temp_df["北向资金今日持股-占板块比"] = pd.to_numeric(
1277
+ temp_df["北向资金今日持股-占板块比"], errors="coerce"
1278
+ )
1279
+ temp_df["北向资金今日持股-占北向资金比"] = pd.to_numeric(
1280
+ temp_df["北向资金今日持股-占北向资金比"], errors="coerce"
1281
+ )
1282
+ temp_df["北向资金今日增持估计-股票只数"] = pd.to_numeric(
1283
+ temp_df["北向资金今日增持估计-股票只数"], errors="coerce"
1284
+ )
1285
+ temp_df["北向资金今日增持估计-市值"] = pd.to_numeric(
1286
+ temp_df["北向资金今日增持估计-市值"], errors="coerce"
1287
+ )
1288
+ temp_df["北向资金今日增持估计-市值增幅"] = pd.to_numeric(
1289
+ temp_df["北向资金今日增持估计-市值增幅"], errors="coerce"
1290
+ )
1291
+ temp_df["北向资金今日增持估计-占板块比"] = pd.to_numeric(
1292
+ temp_df["北向资金今日增持估计-占板块比"], errors="coerce"
1293
+ )
1294
+ temp_df["北向资金今日增持估计-占北向资金比"] = pd.to_numeric(
1295
+ temp_df["北向资金今日增持估计-占北向资金比"], errors="coerce"
1296
+ )
1521
1297
  temp_df["报告时间"] = pd.to_datetime(temp_df["报告时间"], errors="coerce").dt.date
1522
1298
  return temp_df
1523
1299
 
@@ -1626,7 +1402,7 @@ def stock_hsgt_individual_detail_em(
1626
1402
  data_json = r.json()
1627
1403
  try:
1628
1404
  data_json["result"]["pages"]
1629
- except TypeError as e:
1405
+ except TypeError:
1630
1406
  params.update(
1631
1407
  {
1632
1408
  "filter": f"""(SECURITY_CODE="{symbol}")(MARKET_CODE="001")(HOLD_DATE>='{'-'.join([start_date[:4], start_date[4:6], start_date[6:]])}')(HOLD_DATE<='{'-'.join([end_date[:4], end_date[4:6], end_date[6:]])}')""",
@@ -1697,42 +1473,6 @@ if __name__ == "__main__":
1697
1473
  stock_hk_ggt_components_em_df = stock_hk_ggt_components_em()
1698
1474
  print(stock_hk_ggt_components_em_df)
1699
1475
 
1700
- stock_hsgt_north_net_flow_in_em_df = stock_hsgt_north_net_flow_in_em(
1701
- symbol="沪股通"
1702
- )
1703
- print(stock_hsgt_north_net_flow_in_em_df)
1704
-
1705
- stock_hsgt_north_net_flow_in_em_df = stock_hsgt_north_net_flow_in_em(
1706
- symbol="深股通"
1707
- )
1708
- print(stock_hsgt_north_net_flow_in_em_df)
1709
-
1710
- stock_hsgt_north_net_flow_in_em_df = stock_hsgt_north_net_flow_in_em(
1711
- symbol="北上"
1712
- )
1713
- print(stock_hsgt_north_net_flow_in_em_df)
1714
-
1715
- stock_hsgt_north_cash_em_df = stock_hsgt_north_cash_em(symbol="沪股通")
1716
- print(stock_hsgt_north_cash_em_df)
1717
-
1718
- stock_hsgt_north_acc_flow_in_em_df = stock_hsgt_north_acc_flow_in_em(
1719
- symbol="北上"
1720
- )
1721
- print(stock_hsgt_north_acc_flow_in_em_df)
1722
-
1723
- stock_hsgt_south_net_flow_in_em_df = stock_hsgt_south_net_flow_in_em(
1724
- symbol="沪股通"
1725
- )
1726
- print(stock_hsgt_south_net_flow_in_em_df)
1727
-
1728
- stock_hsgt_south_cash_em_df = stock_hsgt_south_cash_em(symbol="沪股通")
1729
- print(stock_hsgt_south_cash_em_df)
1730
-
1731
- stock_hsgt_south_acc_flow_in_em_df = stock_hsgt_south_acc_flow_in_em(
1732
- symbol="沪股通"
1733
- )
1734
- print(stock_hsgt_south_acc_flow_in_em_df)
1735
-
1736
1476
  stock_hsgt_hold_stock_em_df = stock_hsgt_hold_stock_em(
1737
1477
  market="北向", indicator="今日排行"
1738
1478
  )
@@ -1773,35 +1513,27 @@ if __name__ == "__main__":
1773
1513
  )
1774
1514
  print(stock_hsgt_stock_statistics_em_df)
1775
1515
 
1776
- stock_hsgt_institution_statistics_em_df = (
1777
- stock_hsgt_institution_statistics_em(
1778
- market="北向持股", start_date="20240110", end_date="20240110"
1779
- )
1516
+ stock_hsgt_institution_statistics_em_df = stock_hsgt_institution_statistics_em(
1517
+ market="北向持股", start_date="20240110", end_date="20240110"
1780
1518
  )
1781
1519
  print(stock_hsgt_institution_statistics_em_df)
1782
1520
 
1783
- stock_hsgt_institution_statistics_em_df = (
1784
- stock_hsgt_institution_statistics_em(
1785
- market="南向持股", start_date="20240110", end_date="20240110"
1786
- )
1521
+ stock_hsgt_institution_statistics_em_df = stock_hsgt_institution_statistics_em(
1522
+ market="南向持股", start_date="20240110", end_date="20240110"
1787
1523
  )
1788
1524
  print(stock_hsgt_institution_statistics_em_df)
1789
1525
 
1790
- stock_hsgt_institution_statistics_em_df = (
1791
- stock_hsgt_institution_statistics_em(
1792
- market="沪股通持股", start_date="20240110", end_date="20240110"
1793
- )
1526
+ stock_hsgt_institution_statistics_em_df = stock_hsgt_institution_statistics_em(
1527
+ market="沪股通持股", start_date="20240110", end_date="20240110"
1794
1528
  )
1795
1529
  print(stock_hsgt_institution_statistics_em_df)
1796
1530
 
1797
- stock_hsgt_institution_statistics_em_df = (
1798
- stock_hsgt_institution_statistics_em(
1799
- market="深股通持股", start_date="20240110", end_date="20240110"
1800
- )
1531
+ stock_hsgt_institution_statistics_em_df = stock_hsgt_institution_statistics_em(
1532
+ market="深股通持股", start_date="20240110", end_date="20240110"
1801
1533
  )
1802
1534
  print(stock_hsgt_institution_statistics_em_df)
1803
1535
 
1804
- stock_hsgt_hist_em_df = stock_hsgt_hist_em(symbol="港股通沪")
1536
+ stock_hsgt_hist_em_df = stock_hsgt_hist_em(symbol="北向资金")
1805
1537
  print(stock_hsgt_hist_em_df)
1806
1538
 
1807
1539
  stock_hsgt_board_rank_em_df = stock_hsgt_board_rank_em(