akshare 1.14.49__py3-none-any.whl → 1.17.99__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.
Files changed (343) hide show
  1. akshare/__init__.py +595 -129
  2. akshare/air/air_hebei.py +77 -54
  3. akshare/air/air_zhenqi.py +0 -4
  4. akshare/air/cons.py +1 -0
  5. akshare/air/crypto.js +1 -1
  6. akshare/air/outcrypto.js +1 -1
  7. akshare/article/cons.py +1 -0
  8. akshare/article/epu_index.py +4 -3
  9. akshare/article/ff_factor.py +19 -8
  10. akshare/article/fred_md.py +4 -1
  11. akshare/article/risk_rv.py +3 -8
  12. akshare/bank/bank_cbirc_2020.py +11 -11
  13. akshare/bank/cons.py +7 -6
  14. akshare/bond/bond_buy_back_em.py +228 -0
  15. akshare/bond/bond_cb_sina.py +1 -0
  16. akshare/bond/bond_cb_ths.py +17 -9
  17. akshare/bond/bond_cbond.py +19 -14
  18. akshare/bond/bond_china.py +38 -39
  19. akshare/bond/bond_china_money.py +1 -1
  20. akshare/bond/bond_convert.py +10 -9
  21. akshare/bond/bond_em.py +37 -17
  22. akshare/bond/bond_summary.py +38 -37
  23. akshare/bond/bond_zh_cov.py +31 -40
  24. akshare/bond/bond_zh_sina.py +4 -0
  25. akshare/bond/cons.py +14 -11
  26. akshare/cal/__init__.py +0 -0
  27. akshare/cal/rv.py +170 -0
  28. akshare/cost/cost_living.py +7 -5
  29. akshare/crypto/__init__.py +1 -1
  30. akshare/crypto/crypto_bitcoin_cme.py +9 -7
  31. akshare/crypto/crypto_hold.py +4 -2
  32. akshare/currency/currency.py +1 -0
  33. akshare/currency/currency_china_bank_sina.py +11 -6
  34. akshare/data/__init__.py +1 -1
  35. akshare/data/cninfo.js +1 -1
  36. akshare/datasets.py +10 -21
  37. akshare/economic/cons.py +10 -3
  38. akshare/economic/macro_australia.py +74 -69
  39. akshare/economic/macro_bank.py +95 -653
  40. akshare/economic/macro_canada.py +92 -81
  41. akshare/economic/macro_china.py +97 -105
  42. akshare/economic/macro_china_hk.py +0 -1
  43. akshare/economic/macro_euro.py +103 -56
  44. akshare/economic/macro_finance_ths.py +7 -5
  45. akshare/economic/macro_germany.py +1 -1
  46. akshare/economic/macro_japan.py +0 -1
  47. akshare/economic/macro_other.py +1 -6
  48. akshare/economic/macro_swiss.py +2 -3
  49. akshare/economic/macro_uk.py +1 -1
  50. akshare/economic/macro_usa.py +7 -9
  51. akshare/economic/marco_cnbs.py +11 -6
  52. akshare/energy/energy_carbon.py +0 -1
  53. akshare/energy/energy_oil_em.py +1 -2
  54. akshare/event/cons.py +1 -0
  55. akshare/exceptions.py +43 -0
  56. akshare/file_fold/calendar.json +245 -2
  57. akshare/forex/__init__.py +0 -0
  58. akshare/forex/cons.py +192 -0
  59. akshare/forex/forex_em.py +149 -0
  60. akshare/fortune/fortune_500.py +1 -37
  61. akshare/fortune/fortune_bloomberg.py +6 -3
  62. akshare/fortune/fortune_forbes_500.py +3 -6
  63. akshare/fortune/fortune_hurun.py +2 -1
  64. akshare/fortune/fortune_xincaifu_500.py +17 -14
  65. akshare/fund/fund_announcement_em.py +145 -0
  66. akshare/fund/fund_aum_em.py +49 -35
  67. akshare/fund/fund_em.py +251 -220
  68. akshare/fund/fund_etf_em.py +44 -35
  69. akshare/fund/fund_etf_sina.py +75 -27
  70. akshare/fund/fund_etf_ths.py +2 -0
  71. akshare/fund/fund_fee_em.py +172 -0
  72. akshare/fund/fund_fhsp_em.py +42 -32
  73. akshare/fund/fund_init_em.py +8 -5
  74. akshare/fund/fund_lof_em.py +12 -19
  75. akshare/fund/fund_manager.py +25 -11
  76. akshare/fund/fund_overview_em.py +42 -0
  77. akshare/fund/fund_portfolio_em.py +23 -21
  78. akshare/fund/fund_position_lg.py +19 -8
  79. akshare/fund/fund_rank_em.py +2 -5
  80. akshare/fund/fund_rating.py +33 -12
  81. akshare/fund/fund_scale_em.py +24 -13
  82. akshare/fund/fund_scale_sina.py +20 -10
  83. akshare/fund/fund_xq.py +3 -2
  84. akshare/futures/cons.py +135 -39
  85. akshare/futures/cot.py +55 -56
  86. akshare/futures/futures_basis.py +49 -11
  87. akshare/futures/futures_comex_em.py +1 -0
  88. akshare/futures/futures_comm_ctp.py +1 -1
  89. akshare/futures/futures_contract_detail.py +59 -9
  90. akshare/futures/futures_daily_bar.py +66 -59
  91. akshare/futures/futures_foreign.py +14 -8
  92. akshare/futures/futures_hf_em.py +215 -61
  93. akshare/futures/futures_hist_em.py +191 -0
  94. akshare/futures/futures_hq_sina.py +5 -3
  95. akshare/futures/futures_index_ccidx.py +24 -82
  96. akshare/futures/futures_inventory_99.py +70 -272
  97. akshare/futures/futures_inventory_em.py +14 -11
  98. akshare/futures/futures_news_shmet.py +2 -2
  99. akshare/futures/futures_roll_yield.py +11 -24
  100. akshare/futures/futures_rule.py +7 -3
  101. akshare/futures/futures_rule_em.py +38 -0
  102. akshare/futures/futures_settlement_price_sgx.py +21 -6
  103. akshare/futures/futures_stock_js.py +0 -1
  104. akshare/futures/futures_to_spot.py +5 -6
  105. akshare/futures/futures_warehouse_receipt.py +48 -47
  106. akshare/futures/futures_zh_sina.py +3 -3
  107. akshare/futures/receipt.py +298 -165
  108. akshare/futures/requests_fun.py +16 -3
  109. akshare/futures/symbol_var.py +32 -13
  110. akshare/futures_derivative/cons.py +100 -103
  111. akshare/futures_derivative/futures_contract_info_cffex.py +55 -39
  112. akshare/futures_derivative/futures_contract_info_czce.py +2 -0
  113. akshare/futures_derivative/futures_contract_info_dce.py +43 -17
  114. akshare/futures_derivative/futures_contract_info_gfex.py +43 -31
  115. akshare/futures_derivative/futures_contract_info_ine.py +43 -34
  116. akshare/futures_derivative/futures_contract_info_shfe.py +3 -4
  117. akshare/futures_derivative/futures_cot_sina.py +8 -6
  118. akshare/futures_derivative/futures_index_sina.py +25 -13
  119. akshare/fx/cons.py +12 -7
  120. akshare/fx/fx_c_swap_cm.py +62 -0
  121. akshare/fx/fx_quote.py +3 -2
  122. akshare/fx/fx_quote_baidu.py +2 -1
  123. akshare/hf/__init__.py +1 -1
  124. akshare/hf/hf_sp500.py +8 -7
  125. akshare/index/cons.py +132 -28
  126. akshare/index/index_cni.py +7 -7
  127. akshare/index/index_cons.py +2 -2
  128. akshare/index/index_csindex.py +68 -0
  129. akshare/index/index_cx.py +20 -20
  130. akshare/index/index_drewry.py +17 -16
  131. akshare/index/index_eri.py +1 -0
  132. akshare/index/index_global_em.py +167 -0
  133. akshare/index/index_global_sina.py +82 -0
  134. akshare/index/index_kq_fz.py +17 -14
  135. akshare/index/index_kq_ss.py +1 -0
  136. akshare/index/index_option_qvix.py +351 -16
  137. akshare/index/index_research_sw.py +21 -21
  138. akshare/index/index_spot.py +9 -5
  139. akshare/index/index_stock_hk.py +5 -9
  140. akshare/index/index_stock_zh.py +111 -24
  141. akshare/index/index_stock_zh_csindex.py +3 -367
  142. akshare/index/index_sugar.py +18 -4
  143. akshare/index/index_sw.py +10 -2
  144. akshare/index/index_yw.py +53 -75
  145. akshare/index/index_zh_em.py +15 -82
  146. akshare/interest_rate/interbank_rate_em.py +0 -1
  147. akshare/movie/jm.js +0 -1
  148. akshare/news/__init__.py +1 -1
  149. akshare/news/news_baidu.py +395 -222
  150. akshare/news/news_stock.py +49 -16
  151. akshare/option/cons.py +2 -2
  152. akshare/option/option_commodity.py +341 -220
  153. akshare/option/option_commodity_sina.py +22 -26
  154. akshare/option/option_contract_info_ctp.py +63 -0
  155. akshare/option/option_current_sse.py +61 -0
  156. akshare/option/option_current_szse.py +84 -0
  157. akshare/option/option_czce.py +37 -9
  158. akshare/option/option_daily_stats_sse_szse.py +0 -1
  159. akshare/option/option_em.py +4 -8
  160. akshare/option/option_finance.py +60 -12
  161. akshare/option/option_finance_sina.py +7 -7
  162. akshare/option/option_lhb_em.py +0 -1
  163. akshare/option/option_margin.py +62 -0
  164. akshare/option/option_premium_analysis_em.py +58 -53
  165. akshare/option/option_risk_analysis_em.py +11 -8
  166. akshare/option/option_risk_indicator_sse.py +3 -4
  167. akshare/option/option_value_analysis_em.py +62 -55
  168. akshare/other/__init__.py +1 -1
  169. akshare/pro/__init__.py +0 -1
  170. akshare/pro/client.py +6 -4
  171. akshare/pro/cons.py +3 -2
  172. akshare/pro/data_pro.py +6 -5
  173. akshare/qdii/__init__.py +0 -0
  174. akshare/qdii/qdii_jsl.py +233 -0
  175. akshare/qhkc/__init__.py +1 -6
  176. akshare/qhkc/qhkc_api.py +64 -22
  177. akshare/qhkc_web/__init__.py +1 -6
  178. akshare/qhkc_web/qhkc_fund.py +10 -6
  179. akshare/qhkc_web/qhkc_index.py +28 -14
  180. akshare/qhkc_web/qhkc_tool.py +62 -59
  181. akshare/rate/__init__.py +1 -1
  182. akshare/rate/repo_rate.py +36 -32
  183. akshare/reits/__init__.py +1 -1
  184. akshare/reits/reits_basic.py +149 -13
  185. akshare/request.py +117 -0
  186. akshare/spot/__init__.py +1 -1
  187. akshare/spot/spot_hog_soozhu.py +165 -3
  188. akshare/spot/spot_sge.py +70 -9
  189. akshare/stock/cons.py +60 -23
  190. akshare/stock/stock_allotment_cninfo.py +8 -8
  191. akshare/stock/stock_ask_bid_em.py +3 -78
  192. akshare/stock/stock_board_concept_em.py +160 -35
  193. akshare/stock/stock_board_industry_em.py +163 -70
  194. akshare/stock/stock_dividend_cninfo.py +31 -17
  195. akshare/stock/stock_dzjy_em.py +347 -260
  196. akshare/stock/stock_fund_em.py +72 -64
  197. akshare/stock/stock_fund_hold.py +1 -2
  198. akshare/stock/stock_gsrl_em.py +1 -0
  199. akshare/stock/stock_hk_comparison_em.py +175 -0
  200. akshare/stock/stock_hk_famous.py +4 -5
  201. akshare/stock/stock_hk_fhpx_ths.py +2 -1
  202. akshare/stock/stock_hk_hot_rank_em.py +1 -0
  203. akshare/stock/stock_hk_sina.py +84 -36
  204. akshare/stock/stock_hold_control_cninfo.py +82 -0
  205. akshare/stock/stock_hold_control_em.py +0 -2
  206. akshare/stock/stock_hot_rank_em.py +4 -1
  207. akshare/stock/stock_hot_search_baidu.py +32 -19
  208. akshare/stock/stock_hot_up_em.py +4 -1
  209. akshare/stock/stock_hsgt_em.py +155 -0
  210. akshare/stock/stock_industry.py +1 -0
  211. akshare/stock/stock_industry_cninfo.py +1 -2
  212. akshare/stock/stock_info.py +6 -4
  213. akshare/stock/stock_info_em.py +17 -11
  214. akshare/stock/stock_intraday_em.py +4 -78
  215. akshare/stock/stock_intraday_sina.py +2 -2
  216. akshare/stock/stock_news_cx.py +39 -0
  217. akshare/stock/stock_profile_cninfo.py +7 -7
  218. akshare/stock/stock_profile_em.py +302 -0
  219. akshare/stock/stock_rank_forecast.py +6 -5
  220. akshare/stock/stock_repurchase_em.py +7 -2
  221. akshare/stock/stock_share_changes_cninfo.py +7 -5
  222. akshare/stock/stock_share_hold.py +24 -20
  223. akshare/stock/stock_stop.py +6 -6
  224. akshare/stock/stock_summary.py +153 -417
  225. akshare/stock/stock_us_famous.py +5 -6
  226. akshare/stock/stock_us_js.py +3 -2
  227. akshare/stock/stock_us_pink.py +38 -27
  228. akshare/stock/stock_us_sina.py +7 -3
  229. akshare/stock/stock_weibo_nlp.py +18 -20
  230. akshare/stock/stock_xq.py +24 -22
  231. akshare/stock/stock_zh_a_sina.py +8 -5
  232. akshare/stock/stock_zh_a_special.py +240 -243
  233. akshare/stock/stock_zh_a_tick_tx.py +11 -3
  234. akshare/stock/stock_zh_ah_tx.py +23 -26
  235. akshare/stock/stock_zh_b_sina.py +2 -2
  236. akshare/stock/stock_zh_comparison_em.py +250 -0
  237. akshare/stock/stock_zh_kcb_sina.py +67 -64
  238. akshare/stock_a/__init__.py +0 -0
  239. akshare/stock_a/stock_board_concept_name_em.py +170 -0
  240. akshare/stock_a/stock_individual_fund_flow_rank.py +258 -0
  241. akshare/stock_a/stock_zh_a_spot.py +212 -0
  242. akshare/stock_feature/cons.py +1 -0
  243. akshare/stock_feature/stock_a_indicator.py +9 -54
  244. akshare/stock_feature/stock_a_pe_and_pb.py +23 -5
  245. akshare/stock_feature/stock_account_em.py +0 -1
  246. akshare/stock_feature/stock_all_pb.py +2 -1
  247. akshare/stock_feature/stock_analyst_em.py +36 -30
  248. akshare/stock_feature/stock_board_concept_ths.py +328 -0
  249. akshare/stock_feature/stock_board_industry_ths.py +57 -2
  250. akshare/stock_feature/stock_buffett_index_lg.py +10 -8
  251. akshare/stock_feature/stock_classify_sina.py +3 -6
  252. akshare/stock_feature/stock_comment_em.py +81 -144
  253. akshare/stock_feature/stock_congestion_lg.py +2 -1
  254. akshare/stock_feature/stock_cyq_em.py +5 -11
  255. akshare/stock_feature/stock_disclosure_cninfo.py +6 -6
  256. akshare/stock_feature/stock_dxsyl_em.py +121 -74
  257. akshare/stock_feature/stock_ebs_lg.py +5 -4
  258. akshare/stock_feature/stock_esg_sina.py +29 -7
  259. akshare/stock_feature/stock_fhps_em.py +2 -1
  260. akshare/stock_feature/stock_fhps_ths.py +15 -7
  261. akshare/stock_feature/stock_fund_flow.py +30 -22
  262. akshare/stock_feature/stock_gddh_em.py +19 -11
  263. akshare/stock_feature/stock_gdfx_em.py +226 -113
  264. akshare/stock_feature/stock_gdhs.py +75 -50
  265. akshare/stock_feature/stock_gdzjc_em.py +21 -10
  266. akshare/stock_feature/stock_gpzy_em.py +78 -46
  267. akshare/stock_feature/stock_gxl_lg.py +3 -2
  268. akshare/stock_feature/stock_hist_em.py +137 -234
  269. akshare/stock_feature/stock_hist_tx.py +13 -10
  270. akshare/stock_feature/stock_hk_valuation_baidu.py +20 -8
  271. akshare/stock_feature/stock_hot_xq.py +4 -6
  272. akshare/stock_feature/stock_hsgt_em.py +269 -97
  273. akshare/stock_feature/stock_hsgt_exchange_rate.py +115 -87
  274. akshare/stock_feature/stock_hsgt_min_em.py +13 -16
  275. akshare/stock_feature/stock_info.py +7 -80
  276. akshare/stock_feature/stock_inner_trade_xq.py +38 -31
  277. akshare/stock_feature/stock_jgdy_em.py +43 -40
  278. akshare/stock_feature/stock_lhb_em.py +119 -3
  279. akshare/stock_feature/stock_margin_em.py +0 -1
  280. akshare/stock_feature/stock_margin_sse.py +0 -2
  281. akshare/stock_feature/stock_pankou_em.py +71 -35
  282. akshare/stock_feature/stock_qsjy_em.py +13 -4
  283. akshare/stock_feature/stock_report_em.py +151 -7
  284. akshare/stock_feature/stock_research_report_em.py +55 -20
  285. akshare/stock_feature/stock_sy_em.py +20 -15
  286. akshare/stock_feature/stock_technology_ths.py +122 -77
  287. akshare/stock_feature/stock_tfp_em.py +2 -1
  288. akshare/stock_feature/stock_three_report_em.py +21 -5
  289. akshare/stock_feature/stock_ttm_lyr.py +18 -9
  290. akshare/stock_feature/stock_value_em.py +83 -0
  291. akshare/stock_feature/stock_yjbb_em.py +58 -32
  292. akshare/stock_feature/stock_yjyg_cninfo.py +6 -2
  293. akshare/stock_feature/stock_yjyg_em.py +1 -1
  294. akshare/stock_feature/stock_yzxdr_em.py +24 -22
  295. akshare/stock_feature/stock_zdhtmx_em.py +20 -6
  296. akshare/stock_feature/stock_zh_vote_baidu.py +4 -1
  297. akshare/stock_feature/stock_ztb_em.py +39 -24
  298. akshare/stock_fundamental/__init__.py +1 -1
  299. akshare/stock_fundamental/stock_basic_info_xq.py +119 -0
  300. akshare/stock_fundamental/{stock_finance_hk.py → stock_finance_hk_em.py} +23 -16
  301. akshare/stock_fundamental/{stock_finance.py → stock_finance_sina.py} +60 -7
  302. akshare/stock_fundamental/stock_finance_ths.py +524 -57
  303. akshare/stock_fundamental/stock_finance_us_em.py +268 -0
  304. akshare/stock_fundamental/stock_gbjg_em.py +80 -0
  305. akshare/stock_fundamental/stock_hold.py +26 -17
  306. akshare/stock_fundamental/stock_ipo_declare.py +1 -0
  307. akshare/stock_fundamental/stock_kcb_detail_sse.py +10 -10
  308. akshare/stock_fundamental/stock_kcb_sse.py +26 -25
  309. akshare/stock_fundamental/stock_notice.py +12 -3
  310. akshare/stock_fundamental/stock_profit_forecast_em.py +31 -13
  311. akshare/stock_fundamental/stock_profit_forecast_hk_etnet.py +64 -41
  312. akshare/stock_fundamental/stock_profit_forecast_ths.py +86 -35
  313. akshare/stock_fundamental/stock_recommend.py +20 -4
  314. akshare/stock_fundamental/stock_zygc.py +5 -62
  315. akshare/utils/context.py +43 -0
  316. akshare/utils/demjson.py +2009 -1338
  317. akshare/utils/func.py +49 -2
  318. akshare/utils/multi_decrypt.py +53 -0
  319. akshare/utils/token_process.py +6 -5
  320. {akshare-1.14.49.dist-info → akshare-1.17.99.dist-info}/METADATA +54 -80
  321. akshare-1.17.99.dist-info/RECORD +409 -0
  322. {akshare-1.14.49.dist-info → akshare-1.17.99.dist-info}/WHEEL +1 -1
  323. {akshare-1.14.49.dist-info → akshare-1.17.99.dist-info/licenses}/LICENSE +1 -1
  324. tests/test_func.py +3 -5
  325. akshare/bond/bond_futures.py +0 -50
  326. akshare/bond/bond_investing.py +0 -139
  327. akshare/crypto/crypto_hist_investing.py +0 -249
  328. akshare/fund/fund_announcement.py +0 -56
  329. akshare/futures/futures_international.py +0 -170
  330. akshare/futures/futures_news_baidu.py +0 -54
  331. akshare/futures/inventory_data.py +0 -100
  332. akshare/futures_derivative/futures_index_price_nh.py +0 -61
  333. akshare/futures_derivative/futures_index_return_nh.py +0 -47
  334. akshare/futures_derivative/futures_index_volatility_nh.py +0 -53
  335. akshare/futures_derivative/futures_other_index_nh.py +0 -145
  336. akshare/index/index_fear_greed_funddb.py +0 -78
  337. akshare/index/index_investing.py +0 -232
  338. akshare/sport/__init__.py +0 -6
  339. akshare/sport/sport_olympic.py +0 -27
  340. akshare/stock_feature/stock_wencai.py +0 -104
  341. akshare/stock_fundamental/stock_mda_ym.py +0 -40
  342. akshare-1.14.49.dist-info/RECORD +0 -387
  343. {akshare-1.14.49.dist-info → akshare-1.17.99.dist-info}/top_level.txt +0 -0
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2024/7/13 18:00
4
+ Date: 2025/3/10 18:00
5
5
  Desc: 东方财富网-行情首页-沪深京 A 股
6
6
  https://quote.eastmoney.com/
7
7
  """
8
8
 
9
- from functools import lru_cache
10
-
11
9
  import pandas as pd
12
10
  import requests
13
11
 
12
+ from akshare.utils.func import fetch_paginated_data
13
+
14
14
 
15
15
  def stock_zh_a_spot_em() -> pd.DataFrame:
16
16
  """
@@ -22,24 +22,20 @@ def stock_zh_a_spot_em() -> pd.DataFrame:
22
22
  url = "https://82.push2.eastmoney.com/api/qt/clist/get"
23
23
  params = {
24
24
  "pn": "1",
25
- "pz": "50000",
25
+ "pz": "100",
26
26
  "po": "1",
27
27
  "np": "1",
28
28
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
29
29
  "fltt": "2",
30
30
  "invt": "2",
31
- "fid": "f3",
31
+ "fid": "f12",
32
32
  "fs": "m:0 t:6,m:0 t:80,m:1 t:2,m:1 t:23,m:0 t:81 s:2048",
33
33
  "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,"
34
- "f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
35
- "_": "1623833739532",
34
+ "f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
36
35
  }
37
- r = requests.get(url, timeout=15, params=params)
38
- data_json = r.json()
39
- if not data_json["data"]["diff"]:
40
- return pd.DataFrame()
41
- temp_df = pd.DataFrame(data_json["data"]["diff"])
36
+ temp_df = fetch_paginated_data(url, params)
42
37
  temp_df.columns = [
38
+ "index",
43
39
  "_",
44
40
  "最新价",
45
41
  "涨跌幅",
@@ -72,8 +68,6 @@ def stock_zh_a_spot_em() -> pd.DataFrame:
72
68
  "-",
73
69
  "-",
74
70
  ]
75
- temp_df.reset_index(inplace=True)
76
- temp_df["index"] = temp_df.index + 1
77
71
  temp_df.rename(columns={"index": "序号"}, inplace=True)
78
72
  temp_df = temp_df[
79
73
  [
@@ -137,24 +131,20 @@ def stock_sh_a_spot_em() -> pd.DataFrame:
137
131
  url = "https://82.push2.eastmoney.com/api/qt/clist/get"
138
132
  params = {
139
133
  "pn": "1",
140
- "pz": "50000",
134
+ "pz": "100",
141
135
  "po": "1",
142
136
  "np": "1",
143
137
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
144
138
  "fltt": "2",
145
139
  "invt": "2",
146
- "fid": "f3",
140
+ "fid": "f12",
147
141
  "fs": "m:1 t:2,m:1 t:23",
148
142
  "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,"
149
- "f24,f25,f22,f11,f62,f128,f136,f115,f152",
150
- "_": "1623833739532",
143
+ "f24,f25,f22,f11,f62,f128,f136,f115,f152",
151
144
  }
152
- r = requests.get(url, timeout=15, params=params)
153
- data_json = r.json()
154
- if not data_json["data"]["diff"]:
155
- return pd.DataFrame()
156
- temp_df = pd.DataFrame(data_json["data"]["diff"])
145
+ temp_df = fetch_paginated_data(url, params)
157
146
  temp_df.columns = [
147
+ "序号",
158
148
  "_",
159
149
  "最新价",
160
150
  "涨跌幅",
@@ -187,9 +177,6 @@ def stock_sh_a_spot_em() -> pd.DataFrame:
187
177
  "-",
188
178
  "-",
189
179
  ]
190
- temp_df.reset_index(inplace=True)
191
- temp_df["index"] = temp_df.index + 1
192
- temp_df.rename(columns={"index": "序号"}, inplace=True)
193
180
  temp_df = temp_df[
194
181
  [
195
182
  "序号",
@@ -252,24 +239,20 @@ def stock_sz_a_spot_em() -> pd.DataFrame:
252
239
  url = "https://82.push2.eastmoney.com/api/qt/clist/get"
253
240
  params = {
254
241
  "pn": "1",
255
- "pz": "50000",
242
+ "pz": "100",
256
243
  "po": "1",
257
244
  "np": "1",
258
245
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
259
246
  "fltt": "2",
260
247
  "invt": "2",
261
- "fid": "f3",
248
+ "fid": "f12",
262
249
  "fs": "m:0 t:6,m:0 t:80",
263
250
  "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,"
264
- "f25,f22,f11,f62,f128,f136,f115,f152",
265
- "_": "1623833739532",
251
+ "f25,f22,f11,f62,f128,f136,f115,f152",
266
252
  }
267
- r = requests.get(url, timeout=15, params=params)
268
- data_json = r.json()
269
- if not data_json["data"]["diff"]:
270
- return pd.DataFrame()
271
- temp_df = pd.DataFrame(data_json["data"]["diff"])
253
+ temp_df = fetch_paginated_data(url, params)
272
254
  temp_df.columns = [
255
+ "序号",
273
256
  "_",
274
257
  "最新价",
275
258
  "涨跌幅",
@@ -302,9 +285,6 @@ def stock_sz_a_spot_em() -> pd.DataFrame:
302
285
  "-",
303
286
  "-",
304
287
  ]
305
- temp_df.reset_index(inplace=True)
306
- temp_df["index"] = temp_df.index + 1
307
- temp_df.rename(columns={"index": "序号"}, inplace=True)
308
288
  temp_df = temp_df[
309
289
  [
310
290
  "序号",
@@ -367,24 +347,20 @@ def stock_bj_a_spot_em() -> pd.DataFrame:
367
347
  url = "https://82.push2.eastmoney.com/api/qt/clist/get"
368
348
  params = {
369
349
  "pn": "1",
370
- "pz": "50000",
350
+ "pz": "100",
371
351
  "po": "1",
372
352
  "np": "1",
373
353
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
374
354
  "fltt": "2",
375
355
  "invt": "2",
376
- "fid": "f3",
356
+ "fid": "f12",
377
357
  "fs": "m:0 t:81 s:2048",
378
358
  "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24"
379
- ",f25,f22,f11,f62,f128,f136,f115,f152",
380
- "_": "1623833739532",
359
+ ",f25,f22,f11,f62,f128,f136,f115,f152",
381
360
  }
382
- r = requests.get(url, timeout=15, params=params)
383
- data_json = r.json()
384
- if not data_json["data"]["diff"]:
385
- return pd.DataFrame()
386
- temp_df = pd.DataFrame(data_json["data"]["diff"])
361
+ temp_df = fetch_paginated_data(url, params)
387
362
  temp_df.columns = [
363
+ "序号",
388
364
  "_",
389
365
  "最新价",
390
366
  "涨跌幅",
@@ -417,9 +393,6 @@ def stock_bj_a_spot_em() -> pd.DataFrame:
417
393
  "-",
418
394
  "-",
419
395
  ]
420
- temp_df.reset_index(inplace=True)
421
- temp_df["index"] = temp_df.index + 1
422
- temp_df.rename(columns={"index": "序号"}, inplace=True)
423
396
  temp_df = temp_df[
424
397
  [
425
398
  "序号",
@@ -482,7 +455,7 @@ def stock_new_a_spot_em() -> pd.DataFrame:
482
455
  url = "https://82.push2.eastmoney.com/api/qt/clist/get"
483
456
  params = {
484
457
  "pn": "1",
485
- "pz": "50000",
458
+ "pz": "100",
486
459
  "po": "1",
487
460
  "np": "1",
488
461
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
@@ -492,15 +465,11 @@ def stock_new_a_spot_em() -> pd.DataFrame:
492
465
  "fid": "f26",
493
466
  "fs": "m:0 f:8,m:1 f:8",
494
467
  "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,"
495
- "f25,f26,f22,f11,f62,f128,f136,f115,f152",
496
- "_": "1623833739532",
468
+ "f25,f26,f22,f11,f62,f128,f136,f115,f152",
497
469
  }
498
- r = requests.get(url, timeout=15, params=params)
499
- data_json = r.json()
500
- if not data_json["data"]["diff"]:
501
- return pd.DataFrame()
502
- temp_df = pd.DataFrame(data_json["data"]["diff"])
470
+ temp_df = fetch_paginated_data(url, params)
503
471
  temp_df.columns = [
472
+ "序号",
504
473
  "_",
505
474
  "最新价",
506
475
  "涨跌幅",
@@ -534,9 +503,6 @@ def stock_new_a_spot_em() -> pd.DataFrame:
534
503
  "-",
535
504
  "-",
536
505
  ]
537
- temp_df.reset_index(inplace=True)
538
- temp_df["index"] = temp_df.index + 1
539
- temp_df.rename(columns={"index": "序号"}, inplace=True)
540
506
  temp_df = temp_df[
541
507
  [
542
508
  "序号",
@@ -602,25 +568,21 @@ def stock_cy_a_spot_em() -> pd.DataFrame:
602
568
  url = "https://7.push2.eastmoney.com/api/qt/clist/get"
603
569
  params = {
604
570
  "pn": "1",
605
- "pz": "50000",
571
+ "pz": "100",
606
572
  "po": "1",
607
573
  "np": "1",
608
574
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
609
575
  "fltt": "2",
610
576
  "invt": "2",
611
577
  "wbp2u": "|0|0|0|web",
612
- "fid": "f3",
578
+ "fid": "f12",
613
579
  "fs": "m:0 t:80",
614
580
  "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,"
615
- "f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
616
- "_": "1623833739532",
581
+ "f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
617
582
  }
618
- r = requests.get(url, timeout=15, params=params)
619
- data_json = r.json()
620
- if not data_json["data"]["diff"]:
621
- return pd.DataFrame()
622
- temp_df = pd.DataFrame(data_json["data"]["diff"])
583
+ temp_df = fetch_paginated_data(url, params)
623
584
  temp_df.columns = [
585
+ "序号",
624
586
  "_",
625
587
  "最新价",
626
588
  "涨跌幅",
@@ -653,9 +615,6 @@ def stock_cy_a_spot_em() -> pd.DataFrame:
653
615
  "-",
654
616
  "-",
655
617
  ]
656
- temp_df.reset_index(inplace=True)
657
- temp_df["index"] = temp_df.index + 1
658
- temp_df.rename(columns={"index": "序号"}, inplace=True)
659
618
  temp_df = temp_df[
660
619
  [
661
620
  "序号",
@@ -718,25 +677,21 @@ def stock_kc_a_spot_em() -> pd.DataFrame:
718
677
  url = "https://7.push2.eastmoney.com/api/qt/clist/get"
719
678
  params = {
720
679
  "pn": "1",
721
- "pz": "50000",
680
+ "pz": "100",
722
681
  "po": "1",
723
682
  "np": "1",
724
683
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
725
684
  "fltt": "2",
726
685
  "invt": "2",
727
686
  "wbp2u": "|0|0|0|web",
728
- "fid": "f3",
687
+ "fid": "f12",
729
688
  "fs": "m:1 t:23",
730
689
  "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,"
731
- "f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
732
- "_": "1623833739532",
690
+ "f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
733
691
  }
734
- r = requests.get(url, timeout=15, params=params)
735
- data_json = r.json()
736
- if not data_json["data"]["diff"]:
737
- return pd.DataFrame()
738
- temp_df = pd.DataFrame(data_json["data"]["diff"])
692
+ temp_df = fetch_paginated_data(url, params)
739
693
  temp_df.columns = [
694
+ "序号",
740
695
  "_",
741
696
  "最新价",
742
697
  "涨跌幅",
@@ -769,9 +724,6 @@ def stock_kc_a_spot_em() -> pd.DataFrame:
769
724
  "-",
770
725
  "-",
771
726
  ]
772
- temp_df.reset_index(inplace=True)
773
- temp_df["index"] = temp_df.index + 1
774
- temp_df.rename(columns={"index": "序号"}, inplace=True)
775
727
  temp_df = temp_df[
776
728
  [
777
729
  "序号",
@@ -824,6 +776,69 @@ def stock_kc_a_spot_em() -> pd.DataFrame:
824
776
  return temp_df
825
777
 
826
778
 
779
+ def stock_zh_ab_comparison_em() -> pd.DataFrame:
780
+ """
781
+ 东方财富网-行情中心-沪深京个股-AB股比价-全部AB股比价
782
+ https://quote.eastmoney.com/center/gridlist.html#ab_comparison
783
+ :return: 实时行情
784
+ :rtype: pandas.DataFrame
785
+ """
786
+ url = "https://push2.eastmoney.com/api/qt/clist/get"
787
+ params = {
788
+ "np": "1",
789
+ "fltt": "1",
790
+ "invt": "2",
791
+ "fs": "m:1+b:BK0498,m:0+b:BK0498",
792
+ "fields": "f201,f202,f203,f196,f200,f197,f152,f12,f13,f14,f1,f2,f4,f3,f199",
793
+ "fid": "f199",
794
+ "pn": "1",
795
+ "pz": "100",
796
+ "po": "1",
797
+ "dect": "1",
798
+ "wbp2u": "|0|0|0|web",
799
+ }
800
+ columns_map = {
801
+ "index": "序号",
802
+ "f1": "-",
803
+ "f2": "最新价B",
804
+ "f3": "涨跌幅B",
805
+ "f4": "-",
806
+ "f12": "A股代码",
807
+ "f13": "-",
808
+ "f14": "A股名称",
809
+ "f152": "-",
810
+ "f196": "最新价A",
811
+ "f197": "涨跌幅A",
812
+ "f199": "比价",
813
+ "f200": "-",
814
+ "f201": "B股代码",
815
+ "f202": "-",
816
+ "f203": "B股名称"
817
+ }
818
+ temp_df = fetch_paginated_data(url, params)
819
+ temp_df = temp_df.rename(columns=columns_map)
820
+ list_name = [value for key, value in columns_map.items() if value != "_"]
821
+ temp_df = temp_df[list_name]
822
+ temp_df = temp_df[[
823
+ "序号",
824
+ "B股代码",
825
+ "B股名称",
826
+ "最新价B",
827
+ "涨跌幅B",
828
+ "A股代码",
829
+ "A股名称",
830
+ "最新价A",
831
+ "涨跌幅A",
832
+ "比价",
833
+ ]]
834
+ temp_df["最新价B"] = pd.to_numeric(temp_df["最新价B"], errors="coerce") / 100
835
+ temp_df["涨跌幅B"] = pd.to_numeric(temp_df["涨跌幅B"], errors="coerce") / 100
836
+ temp_df["最新价A"] = pd.to_numeric(temp_df["最新价A"], errors="coerce") / 100
837
+ temp_df["涨跌幅A"] = pd.to_numeric(temp_df["涨跌幅A"], errors="coerce") / 100
838
+ temp_df["比价"] = pd.to_numeric(temp_df["比价"], errors="coerce") / 100
839
+ return temp_df
840
+
841
+
827
842
  def stock_zh_b_spot_em() -> pd.DataFrame:
828
843
  """
829
844
  东方财富网- B 股-实时行情
@@ -834,24 +849,20 @@ def stock_zh_b_spot_em() -> pd.DataFrame:
834
849
  url = "https://28.push2.eastmoney.com/api/qt/clist/get"
835
850
  params = {
836
851
  "pn": "1",
837
- "pz": "50000",
852
+ "pz": "100",
838
853
  "po": "1",
839
854
  "np": "1",
840
855
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
841
856
  "fltt": "2",
842
857
  "invt": "2",
843
- "fid": "f3",
858
+ "fid": "f12",
844
859
  "fs": "m:0 t:7,m:1 t:3",
845
860
  "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20"
846
- ",f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
847
- "_": "1623833739532",
861
+ ",f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
848
862
  }
849
- r = requests.get(url, timeout=15, params=params)
850
- data_json = r.json()
851
- if not data_json["data"]["diff"]:
852
- return pd.DataFrame()
853
- temp_df = pd.DataFrame(data_json["data"]["diff"])
863
+ temp_df = fetch_paginated_data(url, params)
854
864
  temp_df.columns = [
865
+ "序号",
855
866
  "_",
856
867
  "最新价",
857
868
  "涨跌幅",
@@ -884,9 +895,6 @@ def stock_zh_b_spot_em() -> pd.DataFrame:
884
895
  "-",
885
896
  "-",
886
897
  ]
887
- temp_df.reset_index(inplace=True)
888
- temp_df["index"] = temp_df.index + 1
889
- temp_df.rename(columns={"index": "序号"}, inplace=True)
890
898
  temp_df = temp_df[
891
899
  [
892
900
  "序号",
@@ -939,79 +947,6 @@ def stock_zh_b_spot_em() -> pd.DataFrame:
939
947
  return temp_df
940
948
 
941
949
 
942
- @lru_cache()
943
- def code_id_map_em() -> dict:
944
- """
945
- 东方财富-股票和市场代码
946
- https://quote.eastmoney.com/center/gridlist.html#hs_a_board
947
- :return: 股票和市场代码
948
- :rtype: dict
949
- """
950
- url = "https://80.push2.eastmoney.com/api/qt/clist/get"
951
- params = {
952
- "pn": "1",
953
- "pz": "50000",
954
- "po": "1",
955
- "np": "1",
956
- "ut": "bd1d9ddb04089700cf9c27f6f7426281",
957
- "fltt": "2",
958
- "invt": "2",
959
- "fid": "f3",
960
- "fs": "m:1 t:2,m:1 t:23",
961
- "fields": "f12",
962
- "_": "1623833739532",
963
- }
964
- r = requests.get(url, timeout=15, params=params)
965
- data_json = r.json()
966
- if not data_json["data"]["diff"]:
967
- return dict()
968
- temp_df = pd.DataFrame(data_json["data"]["diff"])
969
- temp_df["market_id"] = 1
970
- temp_df.columns = ["sh_code", "sh_id"]
971
- code_id_dict = dict(zip(temp_df["sh_code"], temp_df["sh_id"]))
972
- params = {
973
- "pn": "1",
974
- "pz": "50000",
975
- "po": "1",
976
- "np": "1",
977
- "ut": "bd1d9ddb04089700cf9c27f6f7426281",
978
- "fltt": "2",
979
- "invt": "2",
980
- "fid": "f3",
981
- "fs": "m:0 t:6,m:0 t:80",
982
- "fields": "f12",
983
- "_": "1623833739532",
984
- }
985
- r = requests.get(url, timeout=15, params=params)
986
- data_json = r.json()
987
- if not data_json["data"]["diff"]:
988
- return dict()
989
- temp_df_sz = pd.DataFrame(data_json["data"]["diff"])
990
- temp_df_sz["sz_id"] = 0
991
- code_id_dict.update(dict(zip(temp_df_sz["f12"], temp_df_sz["sz_id"])))
992
- params = {
993
- "pn": "1",
994
- "pz": "50000",
995
- "po": "1",
996
- "np": "1",
997
- "ut": "bd1d9ddb04089700cf9c27f6f7426281",
998
- "fltt": "2",
999
- "invt": "2",
1000
- "fid": "f3",
1001
- "fs": "m:0 t:81 s:2048",
1002
- "fields": "f12",
1003
- "_": "1623833739532",
1004
- }
1005
- r = requests.get(url, timeout=15, params=params)
1006
- data_json = r.json()
1007
- if not data_json["data"]["diff"]:
1008
- return dict()
1009
- temp_df_sz = pd.DataFrame(data_json["data"]["diff"])
1010
- temp_df_sz["bj_id"] = 0
1011
- code_id_dict.update(dict(zip(temp_df_sz["f12"], temp_df_sz["bj_id"])))
1012
- return code_id_dict
1013
-
1014
-
1015
950
  def stock_zh_a_hist(
1016
951
  symbol: str = "000001",
1017
952
  period: str = "daily",
@@ -1038,7 +973,7 @@ def stock_zh_a_hist(
1038
973
  :return: 每日行情
1039
974
  :rtype: pandas.DataFrame
1040
975
  """
1041
- code_id_dict = code_id_map_em()
976
+ market_code = 1 if symbol.startswith("6") else 0
1042
977
  adjust_dict = {"qfq": "1", "hfq": "2", "": "0"}
1043
978
  period_dict = {"daily": "101", "weekly": "102", "monthly": "103"}
1044
979
  url = "https://push2his.eastmoney.com/api/qt/stock/kline/get"
@@ -1048,10 +983,9 @@ def stock_zh_a_hist(
1048
983
  "ut": "7eea3edcaed734bea9cbfc24409ed989",
1049
984
  "klt": period_dict[period],
1050
985
  "fqt": adjust_dict[adjust],
1051
- "secid": f"{code_id_dict[symbol]}.{symbol}",
986
+ "secid": f"{market_code}.{symbol}",
1052
987
  "beg": start_date,
1053
988
  "end": end_date,
1054
- "_": "1623766962675",
1055
989
  }
1056
990
  r = requests.get(url, params=params, timeout=timeout)
1057
991
  data_json = r.json()
@@ -1126,7 +1060,7 @@ def stock_zh_a_hist_min_em(
1126
1060
  :return: 每日分时行情
1127
1061
  :rtype: pandas.DataFrame
1128
1062
  """
1129
- code_id_dict = code_id_map_em()
1063
+ market_code = 1 if symbol.startswith("6") else 0
1130
1064
  adjust_map = {
1131
1065
  "": "0",
1132
1066
  "qfq": "1",
@@ -1140,8 +1074,7 @@ def stock_zh_a_hist_min_em(
1140
1074
  "ut": "7eea3edcaed734bea9cbfc24409ed989",
1141
1075
  "ndays": "5",
1142
1076
  "iscr": "0",
1143
- "secid": f"{code_id_dict[symbol]}.{symbol}",
1144
- "_": "1623766962675",
1077
+ "secid": f"{market_code}.{symbol}",
1145
1078
  }
1146
1079
  r = requests.get(url, timeout=15, params=params)
1147
1080
  data_json = r.json()
@@ -1178,10 +1111,9 @@ def stock_zh_a_hist_min_em(
1178
1111
  "ut": "7eea3edcaed734bea9cbfc24409ed989",
1179
1112
  "klt": period,
1180
1113
  "fqt": adjust_map[adjust],
1181
- "secid": f"{code_id_dict[symbol]}.{symbol}",
1114
+ "secid": f"{market_code}.{symbol}",
1182
1115
  "beg": "0",
1183
1116
  "end": "20500000",
1184
- "_": "1630930917857",
1185
1117
  }
1186
1118
  r = requests.get(url, timeout=15, params=params)
1187
1119
  data_json = r.json()
@@ -1250,17 +1182,15 @@ def stock_zh_a_hist_pre_min_em(
1250
1182
  :return: 每日分时行情包含盘前数据
1251
1183
  :rtype: pandas.DataFrame
1252
1184
  """
1253
- code_id_dict = code_id_map_em()
1185
+ market_code = 1 if symbol.startswith("6") else 0
1254
1186
  url = "https://push2.eastmoney.com/api/qt/stock/trends2/get"
1255
1187
  params = {
1256
1188
  "fields1": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",
1257
1189
  "fields2": "f51,f52,f53,f54,f55,f56,f57,f58",
1258
- "ut": "fa5fd1943c7b386f172d6893dbfba10b",
1259
1190
  "ndays": "1",
1260
1191
  "iscr": "1",
1261
1192
  "iscca": "0",
1262
- "secid": f"{code_id_dict[symbol]}.{symbol}",
1263
- "_": "1623766962675",
1193
+ "secid": f"{market_code}.{symbol}",
1264
1194
  }
1265
1195
  r = requests.get(url, timeout=15, params=params)
1266
1196
  data_json = r.json()
@@ -1277,7 +1207,7 @@ def stock_zh_a_hist_pre_min_em(
1277
1207
  ]
1278
1208
  temp_df.index = pd.to_datetime(temp_df["时间"])
1279
1209
  date_format = temp_df.index[0].date().isoformat()
1280
- temp_df = temp_df[date_format + " " + start_time : date_format + " " + end_time]
1210
+ temp_df = temp_df[date_format + " " + start_time: date_format + " " + end_time]
1281
1211
  temp_df.reset_index(drop=True, inplace=True)
1282
1212
  temp_df["开盘"] = pd.to_numeric(temp_df["开盘"], errors="coerce")
1283
1213
  temp_df["收盘"] = pd.to_numeric(temp_df["收盘"], errors="coerce")
@@ -1300,22 +1230,20 @@ def stock_hk_spot_em() -> pd.DataFrame:
1300
1230
  url = "https://72.push2.eastmoney.com/api/qt/clist/get"
1301
1231
  params = {
1302
1232
  "pn": "1",
1303
- "pz": "50000",
1233
+ "pz": "100",
1304
1234
  "po": "1",
1305
1235
  "np": "1",
1306
1236
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
1307
1237
  "fltt": "2",
1308
1238
  "invt": "2",
1309
- "fid": "f3",
1239
+ "fid": "f12",
1310
1240
  "fs": "m:128 t:3,m:128 t:4,m:128 t:1,m:128 t:2",
1311
1241
  "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,"
1312
- "f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
1313
- "_": "1624010056945",
1242
+ "f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
1314
1243
  }
1315
- r = requests.get(url, timeout=15, params=params)
1316
- data_json = r.json()
1317
- temp_df = pd.DataFrame(data_json["data"]["diff"])
1244
+ temp_df = fetch_paginated_data(url, params)
1318
1245
  temp_df.columns = [
1246
+ "序号",
1319
1247
  "_",
1320
1248
  "最新价",
1321
1249
  "涨跌幅",
@@ -1348,9 +1276,6 @@ def stock_hk_spot_em() -> pd.DataFrame:
1348
1276
  "_",
1349
1277
  "_",
1350
1278
  ]
1351
- temp_df.reset_index(inplace=True)
1352
- temp_df["index"] = temp_df.index + 1
1353
- temp_df.rename(columns={"index": "序号"}, inplace=True)
1354
1279
  temp_df = temp_df[
1355
1280
  [
1356
1281
  "序号",
@@ -1390,22 +1315,20 @@ def stock_hk_main_board_spot_em() -> pd.DataFrame:
1390
1315
  url = "https://81.push2.eastmoney.com/api/qt/clist/get"
1391
1316
  params = {
1392
1317
  "pn": "1",
1393
- "pz": "50000",
1318
+ "pz": "100",
1394
1319
  "po": "1",
1395
1320
  "np": "1",
1396
1321
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
1397
1322
  "fltt": "2",
1398
1323
  "invt": "2",
1399
- "fid": "f3",
1324
+ "fid": "f12",
1400
1325
  "fs": "m:128 t:3",
1401
1326
  "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,"
1402
- "f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
1403
- "_": "1624010056945",
1327
+ "f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152",
1404
1328
  }
1405
- r = requests.get(url, timeout=15, params=params)
1406
- data_json = r.json()
1407
- temp_df = pd.DataFrame(data_json["data"]["diff"])
1329
+ temp_df = fetch_paginated_data(url, params)
1408
1330
  temp_df.columns = [
1331
+ "序号",
1409
1332
  "_",
1410
1333
  "最新价",
1411
1334
  "涨跌幅",
@@ -1438,9 +1361,6 @@ def stock_hk_main_board_spot_em() -> pd.DataFrame:
1438
1361
  "_",
1439
1362
  "_",
1440
1363
  ]
1441
- temp_df.reset_index(inplace=True)
1442
- temp_df["index"] = temp_df.index + 1
1443
- temp_df.rename(columns={"index": "序号"}, inplace=True)
1444
1364
  temp_df = temp_df[
1445
1365
  [
1446
1366
  "序号",
@@ -1498,14 +1418,12 @@ def stock_hk_hist(
1498
1418
  url = "https://33.push2his.eastmoney.com/api/qt/stock/kline/get"
1499
1419
  params = {
1500
1420
  "secid": f"116.{symbol}",
1501
- "ut": "fa5fd1943c7b386f172d6893dbfba10b",
1502
1421
  "fields1": "f1,f2,f3,f4,f5,f6",
1503
1422
  "fields2": "f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",
1504
1423
  "klt": period_dict[period],
1505
1424
  "fqt": adjust_dict[adjust],
1506
1425
  "end": "20500000",
1507
1426
  "lmt": "1000000",
1508
- "_": "1623766962675",
1509
1427
  }
1510
1428
  r = requests.get(url, timeout=15, params=params)
1511
1429
  data_json = r.json()
@@ -1577,11 +1495,9 @@ def stock_hk_hist_min_em(
1577
1495
  params = {
1578
1496
  "fields1": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",
1579
1497
  "fields2": "f51,f52,f53,f54,f55,f56,f57,f58",
1580
- "ut": "fa5fd1943c7b386f172d6893dbfba10b",
1581
1498
  "iscr": "0",
1582
1499
  "ndays": "5",
1583
1500
  "secid": f"116.{symbol}",
1584
- "_": "1623766962675",
1585
1501
  }
1586
1502
  r = requests.get(url, timeout=15, params=params)
1587
1503
  data_json = r.json()
@@ -1621,7 +1537,6 @@ def stock_hk_hist_min_em(
1621
1537
  "secid": f"116.{symbol}",
1622
1538
  "beg": "0",
1623
1539
  "end": "20500000",
1624
- "_": "1630930917857",
1625
1540
  }
1626
1541
  r = requests.get(url, timeout=15, params=params)
1627
1542
  data_json = r.json()
@@ -1683,22 +1598,20 @@ def stock_us_spot_em() -> pd.DataFrame:
1683
1598
  url = "https://72.push2.eastmoney.com/api/qt/clist/get"
1684
1599
  params = {
1685
1600
  "pn": "1",
1686
- "pz": "20000",
1601
+ "pz": "100",
1687
1602
  "po": "1",
1688
1603
  "np": "1",
1689
1604
  "ut": "bd1d9ddb04089700cf9c27f6f7426281",
1690
1605
  "fltt": "2",
1691
1606
  "invt": "2",
1692
- "fid": "f3",
1607
+ "fid": "f12",
1693
1608
  "fs": "m:105,m:106,m:107",
1694
1609
  "fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,"
1695
- "f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152",
1696
- "_": "1624010056945",
1610
+ "f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152",
1697
1611
  }
1698
- r = requests.get(url, timeout=15, params=params)
1699
- data_json = r.json()
1700
- temp_df = pd.DataFrame(data_json["data"]["diff"])
1612
+ temp_df = fetch_paginated_data(url, params)
1701
1613
  temp_df.columns = [
1614
+ "序号",
1702
1615
  "_",
1703
1616
  "最新价",
1704
1617
  "涨跌幅",
@@ -1733,9 +1646,6 @@ def stock_us_spot_em() -> pd.DataFrame:
1733
1646
  "_",
1734
1647
  "_",
1735
1648
  ]
1736
- temp_df.reset_index(inplace=True)
1737
- temp_df["index"] = range(1, len(temp_df) + 1)
1738
- temp_df.rename(columns={"index": "序号"}, inplace=True)
1739
1649
  temp_df["代码"] = temp_df["编码"].astype(str) + "." + temp_df["简称"]
1740
1650
  temp_df = temp_df[
1741
1651
  [
@@ -1801,14 +1711,12 @@ def stock_us_hist(
1801
1711
  url = "https://63.push2his.eastmoney.com/api/qt/stock/kline/get"
1802
1712
  params = {
1803
1713
  "secid": f"{symbol}",
1804
- "ut": "fa5fd1943c7b386f172d6893dbfba10b",
1805
1714
  "fields1": "f1,f2,f3,f4,f5,f6",
1806
1715
  "fields2": "f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61",
1807
1716
  "klt": period_dict[period],
1808
1717
  "fqt": adjust_dict[adjust],
1809
1718
  "end": "20500000",
1810
1719
  "lmt": "1000000",
1811
- "_": "1623766962675",
1812
1720
  }
1813
1721
  r = requests.get(url, timeout=15, params=params)
1814
1722
  data_json = r.json()
@@ -1866,11 +1774,9 @@ def stock_us_hist_min_em(
1866
1774
  params = {
1867
1775
  "fields1": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13",
1868
1776
  "fields2": "f51,f52,f53,f54,f55,f56,f57,f58",
1869
- "ut": "fa5fd1943c7b386f172d6893dbfba10b",
1870
1777
  "iscr": "0",
1871
1778
  "ndays": "5",
1872
1779
  "secid": f"{symbol.split('.')[0]}.{symbol.split('.')[1]}",
1873
- "_": "1623766962675",
1874
1780
  }
1875
1781
  r = requests.get(url, params=params, timeout=15)
1876
1782
  data_json = r.json()
@@ -1926,9 +1832,6 @@ if __name__ == "__main__":
1926
1832
  stock_zh_b_spot_em_df = stock_zh_b_spot_em()
1927
1833
  print(stock_zh_b_spot_em_df)
1928
1834
 
1929
- code_id_map_em_df = code_id_map_em()
1930
- print(code_id_map_em_df)
1931
-
1932
1835
  stock_hk_spot_em_df = stock_hk_spot_em()
1933
1836
  print(stock_hk_spot_em_df)
1934
1837
 
@@ -1936,10 +1839,10 @@ if __name__ == "__main__":
1936
1839
  print(stock_hk_main_board_spot_em_df)
1937
1840
 
1938
1841
  stock_zh_a_hist_df = stock_zh_a_hist(
1939
- symbol="000001",
1842
+ symbol="600734",
1940
1843
  period="daily",
1941
- start_date="20170301",
1942
- end_date="20240528",
1844
+ start_date="20050501",
1845
+ end_date="20250304",
1943
1846
  adjust="hfq",
1944
1847
  )
1945
1848
  print(stock_zh_a_hist_df)
@@ -2005,9 +1908,9 @@ if __name__ == "__main__":
2005
1908
  print(stock_us_hist_min_em_df)
2006
1909
 
2007
1910
  stock_zh_a_hist_min_em_df = stock_zh_a_hist_min_em(
2008
- symbol="000001",
2009
- start_date="2024-03-20 09:30:00",
2010
- end_date="2024-03-20 15:00:00",
1911
+ symbol="300364",
1912
+ start_date="2025-03-07 09:30:00",
1913
+ end_date="2025-03-07 15:00:00",
2011
1914
  period="5",
2012
1915
  adjust="hfq",
2013
1916
  )
@@ -2017,7 +1920,7 @@ if __name__ == "__main__":
2017
1920
  symbol="833454",
2018
1921
  period="daily",
2019
1922
  start_date="20170301",
2020
- end_date="20211115",
1923
+ end_date="20241115",
2021
1924
  adjust="hfq",
2022
1925
  )
2023
1926
  print(stock_zh_a_hist_df)
@@ -2026,8 +1929,8 @@ if __name__ == "__main__":
2026
1929
  symbol="01611",
2027
1930
  period="1",
2028
1931
  adjust="",
2029
- start_date="2024-04-12 09:30:00",
2030
- end_date="2024-04-12 18:32:00",
1932
+ start_date="2025-03-07 09:30:00",
1933
+ end_date="2025-03-07 18:32:00",
2031
1934
  )
2032
1935
  print(stock_hk_hist_min_em_df)
2033
1936