akshare 1.16.64__py3-none-any.whl → 1.16.66__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 (176) hide show
  1. akshare/__init__.py +3 -1
  2. akshare/air/cons.py +1 -0
  3. akshare/air/crypto.js +1 -1
  4. akshare/air/outcrypto.js +1 -1
  5. akshare/article/cons.py +1 -0
  6. akshare/article/epu_index.py +4 -3
  7. akshare/article/ff_factor.py +19 -8
  8. akshare/article/fred_md.py +4 -1
  9. akshare/article/risk_rv.py +3 -8
  10. akshare/bond/bond_cb_sina.py +1 -0
  11. akshare/bond/bond_cbond.py +19 -14
  12. akshare/bond/bond_em.py +34 -15
  13. akshare/bond/bond_summary.py +38 -37
  14. akshare/bond/bond_zh_cov.py +0 -6
  15. akshare/bond/cons.py +14 -11
  16. akshare/crypto/__init__.py +1 -1
  17. akshare/crypto/crypto_bitcoin_cme.py +7 -7
  18. akshare/crypto/crypto_hold.py +4 -1
  19. akshare/currency/currency.py +1 -0
  20. akshare/currency/currency_china_bank_sina.py +6 -3
  21. akshare/data/__init__.py +1 -1
  22. akshare/data/cninfo.js +1 -1
  23. akshare/economic/cons.py +10 -3
  24. akshare/economic/macro_australia.py +0 -7
  25. akshare/economic/macro_canada.py +92 -81
  26. akshare/economic/macro_china.py +0 -34
  27. akshare/economic/macro_china_hk.py +0 -1
  28. akshare/economic/macro_euro.py +103 -56
  29. akshare/economic/macro_germany.py +1 -1
  30. akshare/economic/macro_japan.py +0 -1
  31. akshare/economic/macro_other.py +1 -6
  32. akshare/economic/macro_swiss.py +2 -3
  33. akshare/economic/macro_uk.py +1 -1
  34. akshare/economic/macro_usa.py +0 -2
  35. akshare/energy/energy_carbon.py +0 -1
  36. akshare/energy/energy_oil_em.py +1 -2
  37. akshare/event/cons.py +1 -0
  38. akshare/forex/forex_em.py +0 -1
  39. akshare/fortune/fortune_bloomberg.py +6 -3
  40. akshare/fortune/fortune_forbes_500.py +3 -6
  41. akshare/fortune/fortune_hurun.py +2 -1
  42. akshare/fortune/fortune_xincaifu_500.py +17 -14
  43. akshare/fund/fund_announcement.py +1 -0
  44. akshare/fund/fund_aum_em.py +47 -35
  45. akshare/fund/fund_em.py +0 -7
  46. akshare/fund/fund_etf_em.py +0 -5
  47. akshare/fund/fund_fhsp_em.py +27 -20
  48. akshare/fund/fund_init_em.py +8 -5
  49. akshare/fund/fund_lof_em.py +0 -5
  50. akshare/fund/fund_manager.py +18 -7
  51. akshare/fund/fund_portfolio_em.py +0 -1
  52. akshare/fund/fund_position_lg.py +19 -8
  53. akshare/fund/fund_rank_em.py +0 -3
  54. akshare/fund/fund_rating.py +28 -9
  55. akshare/fund/fund_scale_em.py +24 -13
  56. akshare/futures/futures_comex_em.py +1 -0
  57. akshare/futures/futures_contract_detail.py +11 -8
  58. akshare/futures/futures_inventory_em.py +0 -2
  59. akshare/futures/futures_rule.py +5 -1
  60. akshare/futures/futures_settlement_price_sgx.py +21 -6
  61. akshare/futures/futures_stock_js.py +0 -1
  62. akshare/futures/receipt.py +279 -153
  63. akshare/futures/requests_fun.py +16 -3
  64. akshare/futures_derivative/cons.py +100 -103
  65. akshare/futures_derivative/futures_contract_info_cffex.py +53 -39
  66. akshare/futures_derivative/futures_contract_info_dce.py +16 -9
  67. akshare/futures_derivative/futures_contract_info_gfex.py +43 -31
  68. akshare/futures_derivative/futures_index_sina.py +25 -13
  69. akshare/fx/cons.py +12 -7
  70. akshare/fx/fx_quote.py +1 -0
  71. akshare/fx/fx_quote_baidu.py +2 -1
  72. akshare/hf/__init__.py +1 -1
  73. akshare/hf/hf_sp500.py +8 -7
  74. akshare/index/index_eri.py +1 -0
  75. akshare/index/index_global_em.py +0 -1
  76. akshare/index/index_kq_fz.py +17 -14
  77. akshare/index/index_kq_ss.py +1 -0
  78. akshare/index/index_stock_hk.py +0 -1
  79. akshare/index/index_stock_zh.py +0 -3
  80. akshare/index/index_sugar.py +18 -4
  81. akshare/index/index_zh_em.py +0 -15
  82. akshare/interest_rate/interbank_rate_em.py +0 -1
  83. akshare/movie/jm.js +0 -1
  84. akshare/news/__init__.py +1 -1
  85. akshare/news/news_stock.py +0 -1
  86. akshare/option/option_commodity_sina.py +22 -26
  87. akshare/option/option_daily_stats_sse_szse.py +0 -1
  88. akshare/option/option_em.py +0 -1
  89. akshare/option/option_lhb_em.py +0 -1
  90. akshare/option/option_risk_indicator_sse.py +0 -1
  91. akshare/other/__init__.py +1 -1
  92. akshare/pro/__init__.py +0 -1
  93. akshare/pro/client.py +6 -4
  94. akshare/pro/cons.py +3 -2
  95. akshare/pro/data_pro.py +6 -5
  96. akshare/qhkc/qhkc_api.py +63 -21
  97. akshare/qhkc_web/qhkc_fund.py +1 -0
  98. akshare/qhkc_web/qhkc_index.py +1 -0
  99. akshare/qhkc_web/qhkc_tool.py +55 -54
  100. akshare/rate/__init__.py +1 -1
  101. akshare/rate/repo_rate.py +36 -32
  102. akshare/reits/__init__.py +1 -1
  103. akshare/reits/reits_basic.py +44 -2
  104. akshare/sport/__init__.py +1 -1
  105. akshare/sport/sport_olympic.py +1 -0
  106. akshare/spot/__init__.py +1 -1
  107. akshare/stock/cons.py +19 -12
  108. akshare/stock/stock_board_concept_em.py +0 -6
  109. akshare/stock/stock_board_industry_em.py +0 -6
  110. akshare/stock/stock_dzjy_em.py +1 -1
  111. akshare/stock/stock_fund_em.py +0 -2
  112. akshare/stock/stock_fund_hold.py +1 -2
  113. akshare/stock/stock_gsrl_em.py +1 -0
  114. akshare/stock/stock_hk_famous.py +0 -1
  115. akshare/stock/stock_hk_fhpx_ths.py +2 -1
  116. akshare/stock/stock_hk_hot_rank_em.py +1 -0
  117. akshare/stock/stock_hold_control_em.py +0 -2
  118. akshare/stock/stock_hot_up_em.py +4 -1
  119. akshare/stock/stock_hsgt_em.py +0 -2
  120. akshare/stock/stock_industry.py +1 -0
  121. akshare/stock/stock_info.py +0 -2
  122. akshare/stock/stock_info_em.py +0 -1
  123. akshare/stock/stock_repurchase_em.py +7 -2
  124. akshare/stock/stock_share_hold.py +0 -1
  125. akshare/stock/stock_stop.py +0 -1
  126. akshare/stock/stock_summary.py +0 -2
  127. akshare/stock/stock_us_famous.py +0 -1
  128. akshare/stock/stock_us_js.py +3 -2
  129. akshare/stock/stock_us_pink.py +0 -1
  130. akshare/stock/stock_weibo_nlp.py +18 -20
  131. akshare/stock/stock_zh_a_special.py +0 -3
  132. akshare/stock/stock_zh_a_tick_tx.py +11 -3
  133. akshare/stock_a/stock_board_concept_name_em.py +0 -1
  134. akshare/stock_a/stock_zh_a_spot.py +0 -1
  135. akshare/stock_feature/cons.py +1 -0
  136. akshare/stock_feature/stock_account_em.py +0 -1
  137. akshare/stock_feature/stock_all_pb.py +2 -1
  138. akshare/stock_feature/stock_analyst_em.py +0 -3
  139. akshare/stock_feature/stock_buffett_index_lg.py +7 -6
  140. akshare/stock_feature/stock_classify_sina.py +3 -6
  141. akshare/stock_feature/stock_comment_em.py +0 -2
  142. akshare/stock_feature/stock_congestion_lg.py +2 -1
  143. akshare/stock_feature/stock_dxsyl_em.py +116 -71
  144. akshare/stock_feature/stock_gdzjc_em.py +16 -5
  145. akshare/stock_feature/stock_gxl_lg.py +3 -2
  146. akshare/stock_feature/stock_hist_em.py +0 -20
  147. akshare/stock_feature/stock_hist_tx.py +10 -8
  148. akshare/stock_feature/stock_hot_xq.py +4 -6
  149. akshare/stock_feature/stock_hsgt_em.py +0 -2
  150. akshare/stock_feature/stock_hsgt_exchange_rate.py +0 -2
  151. akshare/stock_feature/stock_hsgt_min_em.py +13 -16
  152. akshare/stock_feature/stock_inner_trade_xq.py +0 -1
  153. akshare/stock_feature/stock_lhb_em.py +0 -1
  154. akshare/stock_feature/stock_margin_em.py +0 -1
  155. akshare/stock_feature/stock_margin_sse.py +0 -2
  156. akshare/stock_feature/stock_pankou_em.py +0 -2
  157. akshare/stock_feature/stock_qsjy_em.py +13 -4
  158. akshare/stock_feature/stock_research_report_em.py +0 -1
  159. akshare/stock_feature/stock_yjyg_cninfo.py +4 -1
  160. akshare/stock_feature/stock_yjyg_em.py +1 -1
  161. akshare/stock_feature/stock_zh_vote_baidu.py +4 -1
  162. akshare/stock_feature/stock_ztb_em.py +0 -6
  163. akshare/stock_fundamental/__init__.py +1 -1
  164. akshare/stock_fundamental/stock_hold.py +26 -17
  165. akshare/stock_fundamental/stock_ipo_declare.py +1 -0
  166. akshare/stock_fundamental/stock_kcb_detail_sse.py +10 -10
  167. akshare/stock_fundamental/stock_kcb_sse.py +26 -25
  168. akshare/stock_fundamental/stock_profit_forecast_hk_etnet.py +64 -41
  169. akshare/stock_fundamental/stock_recommend.py +20 -4
  170. akshare/utils/demjson.py +2007 -1336
  171. akshare/utils/token_process.py +6 -5
  172. {akshare-1.16.64.dist-info → akshare-1.16.66.dist-info}/METADATA +12 -35
  173. {akshare-1.16.64.dist-info → akshare-1.16.66.dist-info}/RECORD +176 -176
  174. {akshare-1.16.64.dist-info → akshare-1.16.66.dist-info}/WHEEL +0 -0
  175. {akshare-1.16.64.dist-info → akshare-1.16.66.dist-info}/licenses/LICENSE +0 -0
  176. {akshare-1.16.64.dist-info → akshare-1.16.66.dist-info}/top_level.txt +0 -0
akshare/__init__.py CHANGED
@@ -3073,9 +3073,11 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
3073
3073
  1.16.62 fix: fix stock_gdfx_free_holding_change_em interface
3074
3074
  1.16.63 fix: fix stock_board_concept_name_ths interface
3075
3075
  1.16.64 add: add reits_hist_em interface
3076
+ 1.16.65 fix: fix stock_dzjy_yybph interface
3077
+ 1.16.66 fix: fix macro_cons_silver interface
3076
3078
  """
3077
3079
 
3078
- __version__ = "1.16.64"
3080
+ __version__ = "1.16.66"
3079
3081
  __author__ = "AKFamily"
3080
3082
 
3081
3083
  import sys
akshare/air/cons.py CHANGED
@@ -4,6 +4,7 @@
4
4
  Date: 2019/11/25 20:45
5
5
  Desc: 空气质量接口配置文件
6
6
  """
7
+
7
8
  city_chinese_list = [
8
9
  "北京",
9
10
  "重庆",
akshare/air/crypto.js CHANGED
@@ -136,4 +136,4 @@ function decode_result(a) {
136
136
  var hexcase = 0,
137
137
  b64pad = "",
138
138
  chrsz = 8,
139
- appId = "a01901d3caba1f362d69474674ce477f";
139
+ appId = "a01901d3caba1f362d69474674ce477f";
akshare/air/outcrypto.js CHANGED
@@ -4897,4 +4897,4 @@ CryptoJS.mode.ECB = function() {
4897
4897
  blockSize: 2
4898
4898
  });
4899
4899
  h.TripleDES = e._6(g)
4900
- })();
4900
+ })();
akshare/article/cons.py CHANGED
@@ -4,6 +4,7 @@
4
4
  Date: 2019/11/14 20:32
5
5
  Desc: 学术板块配置文件
6
6
  """
7
+
7
8
  # EPU
8
9
  epu_home_url = "http://www.policyuncertainty.com/index.html"
9
10
 
@@ -5,6 +5,7 @@ Date: 2024/1/20 22:00
5
5
  Desc: 经济政策不确定性指数
6
6
  https://www.policyuncertainty.com/index.html
7
7
  """
8
+
8
9
  import pandas as pd
9
10
 
10
11
 
@@ -28,7 +29,7 @@ def article_epu_index(symbol: str = "China") -> pd.DataFrame:
28
29
  symbol = "HK"
29
30
  epu_df = pd.read_excel(
30
31
  io=f"http://www.policyuncertainty.com/media/{symbol}_EPU_Data_Annotated.xlsx",
31
- engine="openpyxl"
32
+ engine="openpyxl",
32
33
  )
33
34
  return epu_df
34
35
  if symbol in ["Germany", "France", "Italy"]: # 欧洲
@@ -40,13 +41,13 @@ def article_epu_index(symbol: str = "China") -> pd.DataFrame:
40
41
  if symbol in ["Ireland", "Chile", "Colombia", "Netherlands", "Singapore", "Sweden"]:
41
42
  epu_df = pd.read_excel(
42
43
  io=f"http://www.policyuncertainty.com/media/{symbol}_Policy_Uncertainty_Data.xlsx",
43
- engine="openpyxl"
44
+ engine="openpyxl",
44
45
  )
45
46
  return epu_df
46
47
  if symbol == "Greece":
47
48
  epu_df = pd.read_excel(
48
49
  io=f"http://www.policyuncertainty.com/media/FKT_{symbol}_Policy_Uncertainty_Data.xlsx",
49
- engine="openpyxl"
50
+ engine="openpyxl",
50
51
  )
51
52
  return epu_df
52
53
  url = f"http://www.policyuncertainty.com/media/{symbol}_Policy_Uncertainty_Data.csv"
@@ -5,6 +5,7 @@ Date: 2024/1/20 22:30
5
5
  Desc: FF-data-library
6
6
  https://mba.tuck.dartmouth.edu/pages/faculty/ken.french/data_library.html
7
7
  """
8
+
8
9
  from io import StringIO
9
10
 
10
11
  import pandas as pd
@@ -23,26 +24,31 @@ def article_ff_crr() -> pd.DataFrame:
23
24
  res = requests.get(ff_home_url)
24
25
  # first table
25
26
  list_index = (
26
- pd.read_html(StringIO(res.text), header=0, index_col=0)[4].iloc[2, :].index.tolist()
27
+ pd.read_html(StringIO(res.text), header=0, index_col=0)[4]
28
+ .iloc[2, :]
29
+ .index.tolist()
27
30
  )
28
31
  list_0 = [
29
32
  item
30
33
  for item in pd.read_html(StringIO(res.text), header=0, index_col=0)[4]
31
- .iloc[0, :].iloc[0]
34
+ .iloc[0, :]
35
+ .iloc[0]
32
36
  .split(" ")
33
37
  if item != ""
34
38
  ]
35
39
  list_1 = [
36
40
  item
37
41
  for item in pd.read_html(StringIO(res.text), header=0, index_col=0)[4]
38
- .iloc[0, :].iloc[1]
42
+ .iloc[0, :]
43
+ .iloc[1]
39
44
  .split(" ")
40
45
  if item != ""
41
46
  ]
42
47
  list_2 = [
43
48
  item
44
49
  for item in pd.read_html(StringIO(res.text), header=0, index_col=0)[4]
45
- .iloc[0, :].iloc[2]
50
+ .iloc[0, :]
51
+ .iloc[2]
46
52
  .split(" ")
47
53
  if item != ""
48
54
  ]
@@ -63,26 +69,31 @@ def article_ff_crr() -> pd.DataFrame:
63
69
 
64
70
  # second table
65
71
  list_index = (
66
- pd.read_html(StringIO(res.text), header=0, index_col=0)[4].iloc[1, :].index.tolist()
72
+ pd.read_html(StringIO(res.text), header=0, index_col=0)[4]
73
+ .iloc[1, :]
74
+ .index.tolist()
67
75
  )
68
76
  list_0 = [
69
77
  item
70
78
  for item in pd.read_html(StringIO(res.text), header=0, index_col=0)[4]
71
- .iloc[1, :].iloc[0]
79
+ .iloc[1, :]
80
+ .iloc[0]
72
81
  .split(" ")
73
82
  if item != ""
74
83
  ]
75
84
  list_1 = [
76
85
  item
77
86
  for item in pd.read_html(StringIO(res.text), header=0, index_col=0)[4]
78
- .iloc[1, :].iloc[1]
87
+ .iloc[1, :]
88
+ .iloc[1]
79
89
  .split(" ")
80
90
  if item != ""
81
91
  ]
82
92
  list_2 = [
83
93
  item
84
94
  for item in pd.read_html(StringIO(res.text), header=0, index_col=0)[4]
85
- .iloc[1, :].iloc[2]
95
+ .iloc[1, :]
96
+ .iloc[2]
86
97
  .split(" ")
87
98
  if item != ""
88
99
  ]
@@ -6,6 +6,7 @@ Desc: Economic Research from Federal Reserve Bank of St. Louis
6
6
  https://research.stlouisfed.org/econ/mccracken/fred-databases/
7
7
  FRED-MD and FRED-QD are large macroeconomic databases designed for the empirical analysis of “big data.” The datasets of monthly and quarterly observations mimic the coverage of datasets already used in the literature, but they add three appealing features. They are updated in real-time through the FRED database. They are publicly accessible, facilitating the replication of empirical work. And they relieve the researcher of the task of incorporating data changes and revisions (a task accomplished by the data desk at the Federal Reserve Bank of St. Louis).
8
8
  """
9
+
9
10
  import pandas as pd
10
11
 
11
12
 
@@ -17,7 +18,9 @@ def fred_md(date: str = "2020-01") -> pd.DataFrame:
17
18
  :return: Monthly Data
18
19
  :rtype: pandas.DataFrame
19
20
  """
20
- url = f"https://s3.amazonaws.com/files.fred.stlouisfed.org/fred-md/monthly/{date}.csv"
21
+ url = (
22
+ f"https://s3.amazonaws.com/files.fred.stlouisfed.org/fred-md/monthly/{date}.csv"
23
+ )
21
24
  temp_df = pd.read_csv(url)
22
25
  return temp_df
23
26
 
@@ -4,6 +4,7 @@
4
4
  Date: 2024/1/20 20:51
5
5
  Desc: 修大成主页-Risk Lab-Realized Volatility; Oxford-Man Institute of Quantitative Finance Realized Library
6
6
  """
7
+
7
8
  import json
8
9
 
9
10
  import pandas as pd
@@ -64,11 +65,8 @@ def article_oman_rv(symbol: str = "FTSE", index: str = "rk_th2") -> pd.DataFrame
64
65
  res = requests.get(url)
65
66
  soup = BeautifulSoup(res.text, "lxml")
66
67
  soup_text = soup.find("p").get_text()
67
- data_json = json.loads(soup_text[soup_text.find("{"): soup_text.rfind("};") + 1])
68
+ data_json = json.loads(soup_text[soup_text.find("{") : soup_text.rfind("};") + 1])
68
69
  date_list = data_json[f".{symbol}"]["dates"]
69
- title_fore = data_json[f".{symbol}"][index]["name"]
70
- title_last = data_json[f".{symbol}"][index]["measure"]
71
- title_list = title_fore + "-" + title_last
72
70
  temp_df = pd.DataFrame([date_list, data_json[f".{symbol}"][index]["data"]]).T
73
71
  temp_df.index = pd.to_datetime(temp_df.iloc[:, 0], unit="ms")
74
72
  temp_df = temp_df.iloc[:, 1]
@@ -107,10 +105,7 @@ def article_oman_rv_short(symbol: str = "FTSE") -> pd.DataFrame:
107
105
  res = requests.get(url, headers=headers, verify=False)
108
106
  soup = BeautifulSoup(res.text, "lxml")
109
107
  soup_text = soup.find("p").get_text()
110
- data_json = json.loads(soup_text[soup_text.find("{"): soup_text.rfind("}") + 1])
111
- title_fore = data_json[f".{symbol}"]["name"]
112
- title_last = data_json[f".{symbol}"]["measure"]
113
- title_list = title_fore + "-" + title_last
108
+ data_json = json.loads(soup_text[soup_text.find("{") : soup_text.rfind("}") + 1])
114
109
  temp_df = pd.DataFrame(data_json[f".{symbol}"]["data"])
115
110
  temp_df.index = pd.to_datetime(temp_df.iloc[:, 0], unit="ms")
116
111
  temp_df = temp_df.iloc[:, 1]
@@ -5,6 +5,7 @@ Date: 2023/9/12 16:50
5
5
  Desc: 新浪财经-债券-可转债
6
6
  https://money.finance.sina.com.cn/bond/info/sz128039.html
7
7
  """
8
+
8
9
  from io import StringIO
9
10
 
10
11
  import pandas as pd
@@ -4,6 +4,7 @@
4
4
  Date: 2022/9/20 17:46
5
5
  Desc: 中国债券信息网-中债指数-中债指数族系-总指数-综合类指数
6
6
  """
7
+
7
8
  import pandas as pd
8
9
  import requests
9
10
 
@@ -58,17 +59,17 @@ def bond_new_composite_index_cbond(
58
59
  url = "https://yield.chinabond.com.cn/cbweb-mn/indices/singleIndexQuery"
59
60
  params = {
60
61
  "indexid": "8a8b2ca0332abed20134ea76d8885831",
61
- "": "",
62
+ "": "", # noqa: F601
62
63
  "qxlxt": period_map[period],
63
- "": "",
64
+ "": "", # noqa: F601
64
65
  "ltcslx": "",
65
- "": "",
66
- "zslxt": indicator_map[indicator],
67
- "": "",
68
- "zslxt": indicator_map[indicator],
69
- "": "",
66
+ "": "", # noqa: F601
67
+ "zslxt": indicator_map[indicator], # noqa: F601
68
+ "": "", # noqa: F601
69
+ "zslxt": indicator_map[indicator], # noqa: F601
70
+ "": "", # noqa: F601
70
71
  "lx": "1",
71
- "": "",
72
+ "": "", # noqa: F601
72
73
  "locale": "",
73
74
  }
74
75
  r = requests.post(url, params=params)
@@ -79,8 +80,12 @@ def bond_new_composite_index_cbond(
79
80
  )
80
81
  temp_df.reset_index(inplace=True)
81
82
  temp_df.columns = ["date", "value"]
82
- temp_df['date'] = temp_df['date'].astype(float)
83
- temp_df["date"] = pd.to_datetime(temp_df["date"], unit="ms", errors="coerce", utc=True).dt.tz_convert("Asia/Shanghai").dt.date
83
+ temp_df["date"] = temp_df["date"].astype(float)
84
+ temp_df["date"] = (
85
+ pd.to_datetime(temp_df["date"], unit="ms", errors="coerce", utc=True)
86
+ .dt.tz_convert("Asia/Shanghai")
87
+ .dt.date
88
+ )
84
89
  temp_df["value"] = pd.to_numeric(temp_df["value"], errors="coerce")
85
90
  return temp_df
86
91
 
@@ -135,13 +140,13 @@ def bond_composite_index_cbond(
135
140
  url = "https://yield.chinabond.com.cn/cbweb-mn/indices/singleIndexQuery"
136
141
  params = {
137
142
  "indexid": "2c90818811afed8d0111c0c672b31578",
138
- "": "",
143
+ "": "", # noqa: F601
139
144
  "qxlxt": period_map[period],
140
- "": "",
145
+ "": "", # noqa: F601
141
146
  "zslxt": indicator_map[indicator],
142
- "": "",
147
+ "": "", # noqa: F601
143
148
  "lx": "1",
144
- "": "",
149
+ "": "", # noqa: F601
145
150
  "locale": "",
146
151
  }
147
152
  r = requests.post(url, params=params)
akshare/bond/bond_em.py CHANGED
@@ -5,6 +5,7 @@ Date: 2023/12/4 14:00
5
5
  Desc: 东方财富网-数据中心-经济数据-中美国债收益率
6
6
  https://data.eastmoney.com/cjsj/zmgzsyl.html
7
7
  """
8
+
8
9
  import pandas as pd
9
10
  import requests
10
11
  from tqdm import tqdm
@@ -30,7 +31,6 @@ def bond_zh_us_rate(start_date: str = "19901219") -> pd.DataFrame:
30
31
  "ps": "500",
31
32
  "pageNo": "1",
32
33
  "pageNum": "1",
33
- "_": "1615791534490",
34
34
  }
35
35
  r = requests.get(url, params=params)
36
36
  data_json = r.json()
@@ -47,14 +47,13 @@ def bond_zh_us_rate(start_date: str = "19901219") -> pd.DataFrame:
47
47
  "ps": "500",
48
48
  "pageNo": page,
49
49
  "pageNum": page,
50
- "_": "1615791534490",
51
50
  }
52
51
  r = requests.get(url, params=params)
53
52
  data_json = r.json()
54
53
  temp_df = pd.DataFrame(data_json["result"]["data"])
55
54
  for col in temp_df.columns:
56
55
  if temp_df[col].isnull().all(): # 检查列是否包含 None 或 NaN
57
- temp_df[col] = pd.to_numeric(temp_df[col], errors='coerce')
56
+ temp_df[col] = pd.to_numeric(temp_df[col], errors="coerce")
58
57
  if big_df.empty:
59
58
  big_df = temp_df
60
59
  else:
@@ -62,7 +61,7 @@ def bond_zh_us_rate(start_date: str = "19901219") -> pd.DataFrame:
62
61
 
63
62
  temp_date_list = pd.to_datetime(big_df["SOLAR_DATE"]).dt.date.to_list()
64
63
  if pd.to_datetime(start_date) in pd.date_range(
65
- temp_date_list[-1], temp_date_list[0]
64
+ temp_date_list[-1], temp_date_list[0]
66
65
  ):
67
66
  break
68
67
 
@@ -102,21 +101,41 @@ def bond_zh_us_rate(start_date: str = "19901219") -> pd.DataFrame:
102
101
  ]
103
102
  ]
104
103
  big_df["日期"] = pd.to_datetime(big_df["日期"], errors="coerce")
105
- big_df["中国国债收益率2年"] = pd.to_numeric(big_df["中国国债收益率2年"], errors="coerce")
106
- big_df["中国国债收益率5年"] = pd.to_numeric(big_df["中国国债收益率5年"], errors="coerce")
107
- big_df["中国国债收益率10年"] = pd.to_numeric(big_df["中国国债收益率10年"], errors="coerce")
108
- big_df["中国国债收益率30年"] = pd.to_numeric(big_df["中国国债收益率30年"], errors="coerce")
109
- big_df["中国国债收益率10年-2年"] = pd.to_numeric(big_df["中国国债收益率10年-2年"], errors="coerce")
104
+ big_df["中国国债收益率2年"] = pd.to_numeric(
105
+ big_df["中国国债收益率2年"], errors="coerce"
106
+ )
107
+ big_df["中国国债收益率5年"] = pd.to_numeric(
108
+ big_df["中国国债收益率5年"], errors="coerce"
109
+ )
110
+ big_df["中国国债收益率10年"] = pd.to_numeric(
111
+ big_df["中国国债收益率10年"], errors="coerce"
112
+ )
113
+ big_df["中国国债收益率30年"] = pd.to_numeric(
114
+ big_df["中国国债收益率30年"], errors="coerce"
115
+ )
116
+ big_df["中国国债收益率10年-2年"] = pd.to_numeric(
117
+ big_df["中国国债收益率10年-2年"], errors="coerce"
118
+ )
110
119
  big_df["中国GDP年增率"] = pd.to_numeric(big_df["中国GDP年增率"], errors="coerce")
111
- big_df["美国国债收益率2年"] = pd.to_numeric(big_df["美国国债收益率2年"], errors="coerce")
112
- big_df["美国国债收益率5年"] = pd.to_numeric(big_df["美国国债收益率5年"], errors="coerce")
113
- big_df["美国国债收益率10年"] = pd.to_numeric(big_df["美国国债收益率10年"], errors="coerce")
114
- big_df["美国国债收益率30年"] = pd.to_numeric(big_df["美国国债收益率30年"], errors="coerce")
115
- big_df["美国国债收益率10年-2年"] = pd.to_numeric(big_df["美国国债收益率10年-2年"], errors="coerce")
120
+ big_df["美国国债收益率2年"] = pd.to_numeric(
121
+ big_df["美国国债收益率2年"], errors="coerce"
122
+ )
123
+ big_df["美国国债收益率5年"] = pd.to_numeric(
124
+ big_df["美国国债收益率5年"], errors="coerce"
125
+ )
126
+ big_df["美国国债收益率10年"] = pd.to_numeric(
127
+ big_df["美国国债收益率10年"], errors="coerce"
128
+ )
129
+ big_df["美国国债收益率30年"] = pd.to_numeric(
130
+ big_df["美国国债收益率30年"], errors="coerce"
131
+ )
132
+ big_df["美国国债收益率10年-2年"] = pd.to_numeric(
133
+ big_df["美国国债收益率10年-2年"], errors="coerce"
134
+ )
116
135
  big_df["美国GDP年增率"] = pd.to_numeric(big_df["美国GDP年增率"], errors="coerce")
117
136
  big_df.sort_values("日期", inplace=True)
118
137
  big_df.set_index(["日期"], inplace=True)
119
- big_df = big_df[pd.to_datetime(start_date):]
138
+ big_df = big_df[pd.to_datetime(start_date) :]
120
139
  big_df.reset_index(inplace=True)
121
140
  big_df["日期"] = pd.to_datetime(big_df["日期"]).dt.date
122
141
  return big_df
@@ -5,13 +5,14 @@ Date: 2022/3/5 12:55
5
5
  Desc: 上登债券信息网-债券成交概览
6
6
  http://bond.sse.com.cn/data/statistics/overview/turnover/
7
7
  """
8
+
8
9
  from io import BytesIO
9
10
 
10
11
  import pandas as pd
11
12
  import requests
12
13
 
13
14
 
14
- def bond_cash_summary_sse(date: str = '20210111') -> pd.DataFrame:
15
+ def bond_cash_summary_sse(date: str = "20210111") -> pd.DataFrame:
15
16
  """
16
17
  上登债券信息网-市场数据-市场统计-市场概览-债券现券市场概览
17
18
  http://bond.sse.com.cn/data/statistics/overview/bondow/
@@ -20,33 +21,33 @@ def bond_cash_summary_sse(date: str = '20210111') -> pd.DataFrame:
20
21
  :return: 债券成交概览
21
22
  :rtype: pandas.DataFrame
22
23
  """
23
- url = 'http://query.sse.com.cn/commonExcelDd.do'
24
+ url = "http://query.sse.com.cn/commonExcelDd.do"
24
25
  headers = {
25
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
26
- 'Referer': 'http://bond.sse.com.cn/',
27
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
26
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
27
+ "Referer": "http://bond.sse.com.cn/",
28
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
28
29
  }
29
30
  params = {
30
- 'sqlId': 'COMMON_SSEBOND_SCSJ_SCTJ_SCGL_ZQXQSCGL_CX_L',
31
- 'TRADE_DATE': f'{date[:4]}-{date[4:6]}-{date[6:]}',
31
+ "sqlId": "COMMON_SSEBOND_SCSJ_SCTJ_SCGL_ZQXQSCGL_CX_L",
32
+ "TRADE_DATE": f"{date[:4]}-{date[4:6]}-{date[6:]}",
32
33
  }
33
34
  r = requests.get(url, params=params, headers=headers)
34
35
  temp_df = pd.read_excel(BytesIO(r.content), engine="xlrd")
35
36
  temp_df.columns = [
36
- '债券现货',
37
- '托管只数',
38
- '托管市值',
39
- '托管面值',
40
- '数据日期',
37
+ "债券现货",
38
+ "托管只数",
39
+ "托管市值",
40
+ "托管面值",
41
+ "数据日期",
41
42
  ]
42
- temp_df['托管只数'] = pd.to_numeric(temp_df['托管只数'])
43
- temp_df['托管市值'] = pd.to_numeric(temp_df['托管市值'])
44
- temp_df['托管面值'] = pd.to_numeric(temp_df['托管面值'])
45
- temp_df['数据日期'] = pd.to_datetime(temp_df['数据日期']).dt.date
43
+ temp_df["托管只数"] = pd.to_numeric(temp_df["托管只数"])
44
+ temp_df["托管市值"] = pd.to_numeric(temp_df["托管市值"])
45
+ temp_df["托管面值"] = pd.to_numeric(temp_df["托管面值"])
46
+ temp_df["数据日期"] = pd.to_datetime(temp_df["数据日期"]).dt.date
46
47
  return temp_df
47
48
 
48
49
 
49
- def bond_deal_summary_sse(date: str = '20210104') -> pd.DataFrame:
50
+ def bond_deal_summary_sse(date: str = "20210104") -> pd.DataFrame:
50
51
  """
51
52
  上登债券信息网-市场数据-市场统计-市场概览-债券成交概览
52
53
  http://bond.sse.com.cn/data/statistics/overview/turnover/
@@ -55,37 +56,37 @@ def bond_deal_summary_sse(date: str = '20210104') -> pd.DataFrame:
55
56
  :return: 债券成交概览
56
57
  :rtype: pandas.DataFrame
57
58
  """
58
- url = 'http://query.sse.com.cn/commonExcelDd.do'
59
+ url = "http://query.sse.com.cn/commonExcelDd.do"
59
60
  headers = {
60
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
61
- 'Referer': 'http://bond.sse.com.cn/',
62
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'
61
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
62
+ "Referer": "http://bond.sse.com.cn/",
63
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36",
63
64
  }
64
65
  params = {
65
- 'sqlId': 'COMMON_SSEBOND_SCSJ_SCTJ_SCGL_ZQCJGL_CX_L',
66
- 'TRADE_DATE': f'{date[:4]}-{date[4:6]}-{date[6:]}',
66
+ "sqlId": "COMMON_SSEBOND_SCSJ_SCTJ_SCGL_ZQCJGL_CX_L",
67
+ "TRADE_DATE": f"{date[:4]}-{date[4:6]}-{date[6:]}",
67
68
  }
68
69
  r = requests.get(url, params=params, headers=headers)
69
70
  temp_df = pd.read_excel(BytesIO(r.content))
70
71
  temp_df.columns = [
71
- '债券类型',
72
- '当日成交笔数',
73
- '当日成交金额',
74
- '当年成交笔数',
75
- '当年成交金额',
76
- '数据日期',
72
+ "债券类型",
73
+ "当日成交笔数",
74
+ "当日成交金额",
75
+ "当年成交笔数",
76
+ "当年成交金额",
77
+ "数据日期",
77
78
  ]
78
- temp_df['当日成交笔数'] = pd.to_numeric(temp_df['当日成交笔数'])
79
- temp_df['当日成交金额'] = pd.to_numeric(temp_df['当日成交金额'])
80
- temp_df['当年成交笔数'] = pd.to_numeric(temp_df['当年成交笔数'])
81
- temp_df['当年成交金额'] = pd.to_numeric(temp_df['当年成交金额'])
82
- temp_df['数据日期'] = pd.to_datetime(temp_df['数据日期']).dt.date
79
+ temp_df["当日成交笔数"] = pd.to_numeric(temp_df["当日成交笔数"])
80
+ temp_df["当日成交金额"] = pd.to_numeric(temp_df["当日成交金额"])
81
+ temp_df["当年成交笔数"] = pd.to_numeric(temp_df["当年成交笔数"])
82
+ temp_df["当年成交金额"] = pd.to_numeric(temp_df["当年成交金额"])
83
+ temp_df["数据日期"] = pd.to_datetime(temp_df["数据日期"]).dt.date
83
84
  return temp_df
84
85
 
85
86
 
86
- if __name__ == '__main__':
87
- bond_cash_summary_sse_df = bond_cash_summary_sse(date='20210111')
87
+ if __name__ == "__main__":
88
+ bond_cash_summary_sse_df = bond_cash_summary_sse(date="20210111")
88
89
  print(bond_cash_summary_sse_df)
89
90
 
90
- bond_summary_sse_df = bond_deal_summary_sse(date='20210111')
91
+ bond_summary_sse_df = bond_deal_summary_sse(date="20210111")
91
92
  print(bond_summary_sse_df)
@@ -105,7 +105,6 @@ def _code_id_map() -> dict:
105
105
  "fid": "f12",
106
106
  "fs": "m:1 t:2,m:1 t:23",
107
107
  "fields": "f3,f12",
108
- "_": "1623833739532",
109
108
  }
110
109
  temp_df = fetch_paginated_data(url, params)
111
110
  temp_df["market_id"] = 1
@@ -122,7 +121,6 @@ def _code_id_map() -> dict:
122
121
  "fid": "f3",
123
122
  "fs": "m:0 t:6,m:0 t:80",
124
123
  "fields": "f3,f12",
125
- "_": "1623833739532",
126
124
  }
127
125
  temp_df_sz = fetch_paginated_data(url, params)
128
126
  temp_df_sz["sz_id"] = 0
@@ -282,7 +280,6 @@ def bond_zh_hs_cov_pre_min(symbol: str = "sh113570") -> pd.DataFrame:
282
280
  "iscr": "1",
283
281
  "iscca": "0",
284
282
  "secid": f"{market_type[symbol[:2]]}.{symbol[2:]}",
285
- "_": "1623766962675",
286
283
  }
287
284
  r = requests.get(url, params=params)
288
285
  data_json = r.json()
@@ -485,7 +482,6 @@ def bond_cov_comparison() -> pd.DataFrame:
485
482
  "fs": "b:MK0354",
486
483
  "fields": "f1,f152,f2,f3,f12,f13,f14,f227,f228,f229,f230,f231,f232,f233,f234,"
487
484
  "f235,f236,f237,f238,f239,f240,f241,f242,f26,f243",
488
- "_": "1590386857527",
489
485
  }
490
486
  temp_df = fetch_paginated_data(url, params)
491
487
  temp_df.columns = [
@@ -574,7 +570,6 @@ def bond_zh_cov_info(
574
570
  "source": "WEB",
575
571
  "client": "WEB",
576
572
  "filter": f'(SECURITY_CODE="{symbol}")',
577
- "_": "1654952140613",
578
573
  }
579
574
  if indicator == "基本信息":
580
575
  params.update(
@@ -647,7 +642,6 @@ def bond_zh_cov_value_analysis(symbol: str = "113527") -> pd.DataFrame:
647
642
  "filter": f'(zcode="{symbol}")',
648
643
  "p": "1",
649
644
  "ps": "8000",
650
- "_": "1648629088839",
651
645
  }
652
646
  r = requests.get(url, params=params)
653
647
  data_json = r.json()
akshare/bond/cons.py CHANGED
@@ -4,35 +4,40 @@
4
4
  Date: 2019/10/20 10:21
5
5
  Desc: 债券配置文件
6
6
  """
7
+
7
8
  # bond-cov-sina
8
9
  zh_sina_bond_hs_cov_url = "http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeDataSimple"
9
10
  zh_sina_bond_hs_cov_count_url = "http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeStockCountSimple"
10
- zh_sina_bond_hs_cov_hist_url = "https://finance.sina.com.cn/realstock/company/{}/hisdata/klc_kl.js?d={}"
11
+ zh_sina_bond_hs_cov_hist_url = (
12
+ "https://finance.sina.com.cn/realstock/company/{}/hisdata/klc_kl.js?d={}"
13
+ )
11
14
  zh_sina_bond_hs_cov_payload = {
12
15
  "page": "1",
13
16
  "num": "80",
14
17
  "sort": "symbol",
15
18
  "asc": "1",
16
19
  "node": "hskzz_z",
17
- "_s_r_a": "page"
20
+ "_s_r_a": "page",
18
21
  }
19
22
 
20
23
  # bond-sina
21
24
  zh_sina_bond_hs_url = "http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeData"
22
25
  zh_sina_bond_hs_count_url = "http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/Market_Center.getHQNodeStockCountSimple"
23
- zh_sina_bond_hs_hist_url = "https://finance.sina.com.cn/realstock/company/{}/hisdata/klc_kl.js?d={}"
26
+ zh_sina_bond_hs_hist_url = (
27
+ "https://finance.sina.com.cn/realstock/company/{}/hisdata/klc_kl.js?d={}"
28
+ )
24
29
  zh_sina_bond_hs_payload = {
25
30
  "page": "1",
26
31
  "num": "80",
27
32
  "sort": "symbol",
28
33
  "asc": "1",
29
34
  "node": "hs_z",
30
- "_s_r_a": "page"
35
+ "_s_r_a": "page",
31
36
  }
32
37
 
33
38
  # headers
34
39
  SHORT_HEADERS = {
35
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36'
40
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36"
36
41
  }
37
42
 
38
43
  # quote
@@ -45,9 +50,7 @@ MARKET_QUOTE_PAYLOAD = {
45
50
  }
46
51
 
47
52
  # trade
48
- MARKET_TRADE_URL = "http://www.chinamoney.com.cn/ags/ms/cm-u-md-bond/CbtPri?lang=cn&flag=1&bondName="
49
- MARKET_TRADE_PAYLOAD = {
50
- "lang": "cn",
51
- "flag": "1",
52
- "bondName": ""
53
- }
53
+ MARKET_TRADE_URL = (
54
+ "http://www.chinamoney.com.cn/ags/ms/cm-u-md-bond/CbtPri?lang=cn&flag=1&bondName="
55
+ )
56
+ MARKET_TRADE_PAYLOAD = {"lang": "cn", "flag": "1", "bondName": ""}
@@ -2,5 +2,5 @@
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
4
  Date: 2020/10/23 13:51
5
- Desc:
5
+ Desc:
6
6
  """