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,31 +1,85 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2024/3/4 14:30
4
+ Date: 2024/12/2 15:20
5
5
  Desc: 宏观数据-中国
6
6
  """
7
+
8
+ import datetime
7
9
  import json
8
10
  import math
9
11
  import time
10
12
 
11
13
  import pandas as pd
12
14
  import requests
13
- from tqdm import tqdm
14
15
 
15
16
  from akshare.economic.cons import (
16
- JS_CHINA_CPI_YEARLY_URL,
17
- JS_CHINA_CPI_MONTHLY_URL,
18
- JS_CHINA_M2_YEARLY_URL,
19
- JS_CHINA_PPI_YEARLY_URL,
20
- JS_CHINA_PMI_YEARLY_URL,
21
- JS_CHINA_GDP_YEARLY_URL,
22
- JS_CHINA_CX_PMI_YEARLY_URL,
23
- JS_CHINA_FX_RESERVES_YEARLY_URL,
24
17
  JS_CHINA_ENERGY_DAILY_URL,
25
- JS_CHINA_NON_MAN_PMI_MONTHLY_URL,
26
- JS_CHINA_CX_SERVICE_PMI_YEARLY_URL,
27
18
  )
28
19
  from akshare.utils import demjson
20
+ from akshare.utils.tqdm import get_tqdm
21
+
22
+
23
+ def __macro_china_base_func(symbol: str, params: dict) -> pd.DataFrame:
24
+ """
25
+ 金十数据中心-经济指标-美国-基础函数
26
+ https://datacenter.jin10.com/economic
27
+ :return: 美国经济指标数据
28
+ :rtype: pandas.DataFrame
29
+ """
30
+ import warnings
31
+
32
+ warnings.filterwarnings(action="ignore", category=FutureWarning)
33
+ headers = {
34
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
35
+ "Chrome/107.0.0.0 Safari/537.36",
36
+ "x-app-id": "rU6QIu7JHe2gOUeR",
37
+ "x-csrf-token": "x-csrf-token",
38
+ "x-version": "1.0.0",
39
+ }
40
+ url = "https://datacenter-api.jin10.com/reports/list_v2"
41
+ params = params
42
+ big_df = pd.DataFrame()
43
+ while True:
44
+ r = requests.get(url, params=params, headers=headers)
45
+ data_json = r.json()
46
+ if not data_json["data"]["values"]:
47
+ break
48
+ temp_df = pd.DataFrame(data_json["data"]["values"])
49
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
50
+ last_date_str = temp_df.iat[-1, 0]
51
+ last_date_str = (
52
+ (
53
+ datetime.datetime.strptime(last_date_str, "%Y-%m-%d")
54
+ - datetime.timedelta(days=1)
55
+ )
56
+ .date()
57
+ .isoformat()
58
+ )
59
+ params.update({"max_date": f"{last_date_str}"})
60
+ big_df.columns = [
61
+ "日期",
62
+ "今值",
63
+ "预测值",
64
+ "前值",
65
+ ]
66
+ big_df["商品"] = symbol
67
+ big_df = big_df[
68
+ [
69
+ "商品",
70
+ "日期",
71
+ "今值",
72
+ "预测值",
73
+ "前值",
74
+ ]
75
+ ]
76
+ big_df["日期"] = pd.to_datetime(big_df["日期"], errors="coerce").dt.date
77
+ big_df["今值"] = pd.to_numeric(big_df["今值"], errors="coerce")
78
+ big_df["预测值"] = pd.to_numeric(big_df["预测值"], errors="coerce")
79
+ big_df["前值"] = pd.to_numeric(big_df["前值"], errors="coerce")
80
+ big_df.sort_values(["日期"], inplace=True)
81
+ big_df.reset_index(inplace=True, drop=True)
82
+ return big_df
29
83
 
30
84
 
31
85
  # 企业商品价格指数
@@ -38,7 +92,9 @@ def macro_china_qyspjg() -> pd.DataFrame:
38
92
  """
39
93
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
40
94
  params = {
41
- "columns": "REPORT_DATE,TIME,BASE,BASE_SAME,BASE_SEQUENTIAL,FARM_BASE,FARM_BASE_SAME,FARM_BASE_SEQUENTIAL,MINERAL_BASE,MINERAL_BASE_SAME,MINERAL_BASE_SEQUENTIAL,ENERGY_BASE,ENERGY_BASE_SAME,ENERGY_BASE_SEQUENTIAL",
95
+ "columns": "REPORT_DATE,TIME,BASE,BASE_SAME,BASE_SEQUENTIAL,FARM_BASE,FARM_BASE_SAME,"
96
+ "FARM_BASE_SEQUENTIAL,MINERAL_BASE,MINERAL_BASE_SAME,MINERAL_BASE_SEQUENTIAL,"
97
+ "ENERGY_BASE,ENERGY_BASE_SAME,ENERGY_BASE_SEQUENTIAL",
42
98
  "pageNumber": "1",
43
99
  "pageSize": "2000",
44
100
  "sortColumns": "REPORT_DATE",
@@ -92,17 +148,33 @@ def macro_china_qyspjg() -> pd.DataFrame:
92
148
  ]
93
149
  ]
94
150
  temp_df["总指数-指数值"] = pd.to_numeric(temp_df["总指数-指数值"], errors="coerce")
95
- temp_df["总指数-同比增长"] = pd.to_numeric(temp_df["总指数-同比增长"], errors="coerce")
96
- temp_df["总指数-环比增长"] = pd.to_numeric(temp_df["总指数-环比增长"], errors="coerce")
151
+ temp_df["总指数-同比增长"] = pd.to_numeric(
152
+ temp_df["总指数-同比增长"], errors="coerce"
153
+ )
154
+ temp_df["总指数-环比增长"] = pd.to_numeric(
155
+ temp_df["总指数-环比增长"], errors="coerce"
156
+ )
97
157
  temp_df["农产品-指数值"] = pd.to_numeric(temp_df["农产品-指数值"], errors="coerce")
98
- temp_df["农产品-同比增长"] = pd.to_numeric(temp_df["农产品-同比增长"], errors="coerce")
99
- temp_df["农产品-环比增长"] = pd.to_numeric(temp_df["农产品-环比增长"], errors="coerce")
158
+ temp_df["农产品-同比增长"] = pd.to_numeric(
159
+ temp_df["农产品-同比增长"], errors="coerce"
160
+ )
161
+ temp_df["农产品-环比增长"] = pd.to_numeric(
162
+ temp_df["农产品-环比增长"], errors="coerce"
163
+ )
100
164
  temp_df["矿产品-指数值"] = pd.to_numeric(temp_df["矿产品-指数值"], errors="coerce")
101
- temp_df["矿产品-同比增长"] = pd.to_numeric(temp_df["矿产品-同比增长"], errors="coerce")
102
- temp_df["矿产品-环比增长"] = pd.to_numeric(temp_df["矿产品-环比增长"], errors="coerce")
165
+ temp_df["矿产品-同比增长"] = pd.to_numeric(
166
+ temp_df["矿产品-同比增长"], errors="coerce"
167
+ )
168
+ temp_df["矿产品-环比增长"] = pd.to_numeric(
169
+ temp_df["矿产品-环比增长"], errors="coerce"
170
+ )
103
171
  temp_df["煤油电-指数值"] = pd.to_numeric(temp_df["煤油电-指数值"], errors="coerce")
104
- temp_df["煤油电-同比增长"] = pd.to_numeric(temp_df["煤油电-同比增长"], errors="coerce")
105
- temp_df["煤油电-环比增长"] = pd.to_numeric(temp_df["煤油电-环比增长"], errors="coerce")
172
+ temp_df["煤油电-同比增长"] = pd.to_numeric(
173
+ temp_df["煤油电-同比增长"], errors="coerce"
174
+ )
175
+ temp_df["煤油电-环比增长"] = pd.to_numeric(
176
+ temp_df["煤油电-环比增长"], errors="coerce"
177
+ )
106
178
  return temp_df
107
179
 
108
180
 
@@ -116,7 +188,8 @@ def macro_china_fdi() -> pd.DataFrame:
116
188
  """
117
189
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
118
190
  params = {
119
- "columns": "REPORT_DATE,TIME,ACTUAL_FOREIGN,ACTUAL_FOREIGN_SAME,ACTUAL_FOREIGN_SEQUENTIAL,ACTUAL_FOREIGN_ACCUMULATE,FOREIGN_ACCUMULATE_SAME",
191
+ "columns": "REPORT_DATE,TIME,ACTUAL_FOREIGN,ACTUAL_FOREIGN_SAME,ACTUAL_FOREIGN_SEQUENTIAL,"
192
+ "ACTUAL_FOREIGN_ACCUMULATE,FOREIGN_ACCUMULATE_SAME",
120
193
  "pageNumber": "1",
121
194
  "pageSize": "2000",
122
195
  "sortColumns": "REPORT_DATE",
@@ -157,6 +230,7 @@ def macro_china_fdi() -> pd.DataFrame:
157
230
  temp_df["当月-环比增长"] = pd.to_numeric(temp_df["当月-环比增长"], errors="coerce")
158
231
  temp_df["累计"] = pd.to_numeric(temp_df["累计"], errors="coerce")
159
232
  temp_df["累计-同比增长"] = pd.to_numeric(temp_df["累计-同比增长"], errors="coerce")
233
+ temp_df.sort_values(["月份"], ignore_index=True, inplace=True)
160
234
  return temp_df
161
235
 
162
236
 
@@ -164,7 +238,7 @@ def macro_china_fdi() -> pd.DataFrame:
164
238
  def macro_china_shrzgm() -> pd.DataFrame:
165
239
  """
166
240
  商务数据中心-国内贸易-社会融资规模增量统计
167
- http://data.mofcom.gov.cn/gnmy/shrzgm.shtml
241
+ https://data.mofcom.gov.cn/gnmy/shrzgm.shtml
168
242
  :return: 社会融资规模增量统计
169
243
  :rtype: pandas.DataFrame
170
244
  """
@@ -196,12 +270,20 @@ def macro_china_shrzgm() -> pd.DataFrame:
196
270
  "其中-非金融企业境内股票融资",
197
271
  ]
198
272
  ]
199
- temp_df["社会融资规模增量"] = pd.to_numeric(temp_df["社会融资规模增量"], errors="coerce")
200
- temp_df["其中-人民币贷款"] = pd.to_numeric(temp_df["其中-人民币贷款"], errors="coerce")
201
- temp_df["其中-委托贷款外币贷款"] = pd.to_numeric(temp_df["其中-委托贷款外币贷款"], errors="coerce")
273
+ temp_df["社会融资规模增量"] = pd.to_numeric(
274
+ temp_df["社会融资规模增量"], errors="coerce"
275
+ )
276
+ temp_df["其中-人民币贷款"] = pd.to_numeric(
277
+ temp_df["其中-人民币贷款"], errors="coerce"
278
+ )
279
+ temp_df["其中-委托贷款外币贷款"] = pd.to_numeric(
280
+ temp_df["其中-委托贷款外币贷款"], errors="coerce"
281
+ )
202
282
  temp_df["其中-委托贷款"] = pd.to_numeric(temp_df["其中-委托贷款"], errors="coerce")
203
283
  temp_df["其中-信托贷款"] = pd.to_numeric(temp_df["其中-信托贷款"], errors="coerce")
204
- temp_df["其中-未贴现银行承兑汇票"] = pd.to_numeric(temp_df["其中-未贴现银行承兑汇票"], errors="coerce")
284
+ temp_df["其中-未贴现银行承兑汇票"] = pd.to_numeric(
285
+ temp_df["其中-未贴现银行承兑汇票"], errors="coerce"
286
+ )
205
287
  temp_df["其中-企业债券"] = pd.to_numeric(temp_df["其中-企业债券"], errors="coerce")
206
288
  temp_df["其中-非金融企业境内股票融资"] = pd.to_numeric(
207
289
  temp_df["其中-非金融企业境内股票融资"], errors="coerce"
@@ -227,7 +309,7 @@ def macro_china_urban_unemployment() -> pd.DataFrame:
227
309
  "wds": "[]",
228
310
  "dfwds": '[{"wdcode":"zb","valuecode":"A0E01"},{"wdcode":"sj","valuecode":"LAST72"}]',
229
311
  "k1": "1691326382042",
230
- 'h': '1'
312
+ "h": "1",
231
313
  }
232
314
  r = requests.get(url, params=params, verify=False)
233
315
  r.encoding = "utf-8"
@@ -245,6 +327,7 @@ def macro_china_urban_unemployment() -> pd.DataFrame:
245
327
  temp_df.columns = ["date", "item", "value"]
246
328
  temp_df["item"] = temp_df["item"].map(code_item_map)
247
329
  temp_df["value"] = pd.to_numeric(temp_df["value"], errors="coerce")
330
+ temp_df.sort_values(by=["date"], ignore_index=True, inplace=True)
248
331
  return temp_df
249
332
 
250
333
 
@@ -257,53 +340,13 @@ def macro_china_gdp_yearly() -> pd.DataFrame:
257
340
  :rtype: pandas.DataFrame
258
341
  """
259
342
  t = time.time()
260
- r = requests.get(
261
- JS_CHINA_GDP_YEARLY_URL.format(
262
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
263
- )
264
- )
265
- json_data = json.loads(r.text[r.text.find("{"): r.text.rfind("}") + 1])
266
- date_list = [item["date"] for item in json_data["list"]]
267
- value_list = [item["datas"]["中国GDP年率报告"] for item in json_data["list"]]
268
- value_df = pd.DataFrame(value_list)
269
- value_df.columns = json_data["kinds"]
270
- value_df.index = pd.to_datetime(date_list)
271
- temp_df = value_df["今值(%)"]
272
- url = "https://datacenter-api.jin10.com/reports/list_v2"
273
343
  params = {
274
344
  "max_date": "",
275
345
  "category": "ec",
276
346
  "attr_id": "57",
277
347
  "_": str(int(round(t * 1000))),
278
348
  }
279
- headers = {
280
- "accept": "*/*",
281
- "accept-encoding": "gzip, deflate, br",
282
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
283
- "cache-control": "no-cache",
284
- "origin": "https://datacenter.jin10.com",
285
- "pragma": "no-cache",
286
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
287
- "sec-fetch-dest": "empty",
288
- "sec-fetch-mode": "cors",
289
- "sec-fetch-site": "same-site",
290
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
291
- "x-app-id": "rU6QIu7JHe2gOUeR",
292
- "x-csrf-token": "",
293
- "x-version": "1.0.0",
294
- }
295
- r = requests.get(url, params=params, headers=headers)
296
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
297
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
298
- temp_se = temp_se.iloc[:, 1]
299
- temp_df = pd.concat([temp_df, temp_se])
300
- temp_df.dropna(inplace=True)
301
- temp_df.sort_index(inplace=True)
302
- temp_df = temp_df.reset_index()
303
- temp_df.drop_duplicates(subset="index", inplace=True)
304
- temp_df.columns = ["date", "value"]
305
- temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
306
- temp_df["value"] = pd.to_numeric(temp_df["value"])
349
+ temp_df = __macro_china_base_func(symbol="中国GDP年率报告", params=params)
307
350
  return temp_df
308
351
 
309
352
 
@@ -316,52 +359,13 @@ def macro_china_cpi_yearly() -> pd.DataFrame:
316
359
  :rtype: pandas.DataFrame
317
360
  """
318
361
  t = time.time()
319
- res = requests.get(
320
- JS_CHINA_CPI_YEARLY_URL.format(
321
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
322
- )
323
- )
324
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
325
- date_list = [item["date"] for item in json_data["list"]]
326
- value_list = [item["datas"]["中国CPI年率报告"] for item in json_data["list"]]
327
- value_df = pd.DataFrame(value_list)
328
- value_df.columns = json_data["kinds"]
329
- value_df["date"] = pd.to_datetime(date_list)
330
- temp_df = value_df[["date", "今值(%)"]]
331
- temp_df.columns = ["date", "value"]
332
- url = "https://datacenter-api.jin10.com/reports/list_v2"
333
362
  params = {
334
363
  "max_date": "",
335
364
  "category": "ec",
336
365
  "attr_id": "56",
337
366
  "_": str(int(round(t * 1000))),
338
367
  }
339
- headers = {
340
- "accept": "*/*",
341
- "accept-encoding": "gzip, deflate, br",
342
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
343
- "cache-control": "no-cache",
344
- "origin": "https://datacenter.jin10.com",
345
- "pragma": "no-cache",
346
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
347
- "sec-fetch-dest": "empty",
348
- "sec-fetch-mode": "cors",
349
- "sec-fetch-site": "same-site",
350
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
351
- "x-app-id": "rU6QIu7JHe2gOUeR",
352
- "x-csrf-token": "",
353
- "x-version": "1.0.0",
354
- }
355
- r = requests.get(url, params=params, headers=headers)
356
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
357
- temp_se.columns = ["date", "value"]
358
- temp_df = pd.concat([temp_df, temp_se], ignore_index=True)
359
- temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
360
- temp_df.dropna(inplace=True)
361
- temp_df.sort_values(["date"], inplace=True)
362
- temp_df.drop_duplicates(subset="date", inplace=True)
363
- temp_df.reset_index(inplace=True, drop=True)
364
- temp_df["value"] = pd.to_numeric(temp_df["value"], errors="coerce")
368
+ temp_df = __macro_china_base_func(symbol="中国CPI年率报告", params=params)
365
369
  return temp_df
366
370
 
367
371
 
@@ -371,58 +375,16 @@ def macro_china_cpi_monthly() -> pd.DataFrame:
371
375
  中国月度 CPI 数据, 数据区间从 19960201-至今
372
376
  https://datacenter.jin10.com/reportType/dc_chinese_cpi_mom
373
377
  :return: 中国月度 CPI 数据
374
- :rtype: pandas.Series
378
+ :rtype: pandas.DataFrame
375
379
  """
376
380
  t = time.time()
377
- res = requests.get(
378
- JS_CHINA_CPI_MONTHLY_URL.format(
379
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
380
- )
381
- )
382
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
383
- date_list = [item["date"] for item in json_data["list"]]
384
- value_list = [item["datas"]["中国CPI月率报告"] for item in json_data["list"]]
385
- value_df = pd.DataFrame(value_list)
386
- value_df.columns = json_data["kinds"]
387
- value_df.index = pd.to_datetime(date_list)
388
- temp_df = value_df["今值(%)"]
389
- url = "https://datacenter-api.jin10.com/reports/list_v2"
390
381
  params = {
391
382
  "max_date": "",
392
383
  "category": "ec",
393
384
  "attr_id": "72",
394
385
  "_": str(int(round(t * 1000))),
395
386
  }
396
- headers = {
397
- "accept": "*/*",
398
- "accept-encoding": "gzip, deflate, br",
399
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
400
- "cache-control": "no-cache",
401
- "origin": "https://datacenter.jin10.com",
402
- "pragma": "no-cache",
403
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
404
- "sec-fetch-dest": "empty",
405
- "sec-fetch-mode": "cors",
406
- "sec-fetch-site": "same-site",
407
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
408
- "x-app-id": "rU6QIu7JHe2gOUeR",
409
- "x-csrf-token": "",
410
- "x-version": "1.0.0",
411
- }
412
- r = requests.get(url, params=params, headers=headers)
413
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
414
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
415
- temp_se = temp_se.iloc[:, 1]
416
- temp_df = pd.concat([temp_df, temp_se])
417
- temp_df.dropna(inplace=True)
418
- temp_df.sort_index(inplace=True)
419
- temp_df = temp_df.reset_index()
420
- temp_df.drop_duplicates(subset="index", inplace=True)
421
- temp_df.set_index("index", inplace=True)
422
- temp_df = temp_df.squeeze()
423
- temp_df.index.name = None
424
- temp_df.name = "cpi"
425
- temp_df = temp_df.astype("float")
387
+ temp_df = __macro_china_base_func(symbol="中国CPI月率报告", params=params)
426
388
  return temp_df
427
389
 
428
390
 
@@ -431,119 +393,38 @@ def macro_china_ppi_yearly() -> pd.DataFrame:
431
393
  """
432
394
  中国年度 PPI 数据, 数据区间从 19950801-至今
433
395
  https://datacenter.jin10.com/reportType/dc_chinese_ppi_yoy
434
- :return: 中国年度PPI数据
435
- :rtype: pandas.Series
396
+ :return: 中国年度 PPI 数据
397
+ :rtype: pandas.DataFrame
436
398
  """
437
399
  t = time.time()
438
- res = requests.get(
439
- JS_CHINA_PPI_YEARLY_URL.format(
440
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
441
- )
442
- )
443
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
444
- date_list = [item["date"] for item in json_data["list"]]
445
- value_list = [item["datas"]["中国PPI年率报告"] for item in json_data["list"]]
446
- value_df = pd.DataFrame(value_list)
447
- value_df.columns = json_data["kinds"]
448
- value_df.index = pd.to_datetime(date_list)
449
- temp_df = value_df["今值(%)"]
450
- url = "https://datacenter-api.jin10.com/reports/list_v2"
451
400
  params = {
452
401
  "max_date": "",
453
402
  "category": "ec",
454
403
  "attr_id": "60",
455
404
  "_": str(int(round(t * 1000))),
456
405
  }
457
- headers = {
458
- "accept": "*/*",
459
- "accept-encoding": "gzip, deflate, br",
460
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
461
- "cache-control": "no-cache",
462
- "origin": "https://datacenter.jin10.com",
463
- "pragma": "no-cache",
464
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
465
- "sec-fetch-dest": "empty",
466
- "sec-fetch-mode": "cors",
467
- "sec-fetch-site": "same-site",
468
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
469
- "x-app-id": "rU6QIu7JHe2gOUeR",
470
- "x-csrf-token": "",
471
- "x-version": "1.0.0",
472
- }
473
- r = requests.get(url, params=params, headers=headers)
474
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
475
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
476
- temp_se = temp_se.iloc[:, 1]
477
- temp_df = pd.concat([temp_df, temp_se])
478
- temp_df.dropna(inplace=True)
479
- temp_df.sort_index(inplace=True)
480
- temp_df = temp_df.reset_index()
481
- temp_df.drop_duplicates(subset="index", inplace=True)
482
- temp_df.set_index("index", inplace=True)
483
- temp_df = temp_df.squeeze()
484
- temp_df.index.name = None
485
- temp_df.name = "ppi"
486
- temp_df = temp_df.astype("float")
406
+ temp_df = __macro_china_base_func(symbol="中国PPI年率报告", params=params)
487
407
  return temp_df
488
408
 
489
409
 
490
410
  # 金十数据中心-经济指标-中国-贸易状况-以美元计算出口年率报告
491
411
  def macro_china_exports_yoy() -> pd.DataFrame:
492
412
  """
493
- 中国以美元计算出口年率报告, 数据区间从19820201-至今
413
+ 中国以美元计算出口年率报告, 数据区间从 19820201-至今
494
414
  https://datacenter.jin10.com/reportType/dc_chinese_exports_yoy
495
- https://cdn.jin10.com/dc/reports/dc_chinese_exports_yoy_all.js?v=1578754453
496
- :return: 中国以美元计算出口年率报告-今值(%)
497
- :rtype: pandas.Series
415
+ :return: 中国以美元计算出口年率报告
416
+ :rtype: pandas.DataFrame
498
417
  """
499
418
  t = time.time()
500
- res = requests.get(
501
- f"https://cdn.jin10.com/dc/reports/dc_chinese_exports_yoy_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
502
- )
503
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
504
- date_list = [item["date"] for item in json_data["list"]]
505
- value_list = [item["datas"]["中国以美元计算出口年率报告"] for item in json_data["list"]]
506
- value_df = pd.DataFrame(value_list)
507
- value_df.columns = json_data["kinds"]
508
- value_df.index = pd.to_datetime(date_list)
509
- temp_df = value_df["今值(%)"]
510
- url = "https://datacenter-api.jin10.com/reports/list_v2"
511
419
  params = {
512
420
  "max_date": "",
513
421
  "category": "ec",
514
422
  "attr_id": "66",
515
423
  "_": str(int(round(t * 1000))),
516
424
  }
517
- headers = {
518
- "accept": "*/*",
519
- "accept-encoding": "gzip, deflate, br",
520
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
521
- "cache-control": "no-cache",
522
- "origin": "https://datacenter.jin10.com",
523
- "pragma": "no-cache",
524
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
525
- "sec-fetch-dest": "empty",
526
- "sec-fetch-mode": "cors",
527
- "sec-fetch-site": "same-site",
528
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
529
- "x-app-id": "rU6QIu7JHe2gOUeR",
530
- "x-csrf-token": "",
531
- "x-version": "1.0.0",
532
- }
533
- r = requests.get(url, params=params, headers=headers)
534
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
535
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
536
- temp_se = temp_se.iloc[:, 1]
537
- temp_df = pd.concat([temp_df, temp_se])
538
- temp_df.dropna(inplace=True)
539
- temp_df.sort_index(inplace=True)
540
- temp_df = temp_df.reset_index()
541
- temp_df.drop_duplicates(subset="index", inplace=True)
542
- temp_df.set_index("index", inplace=True)
543
- temp_df = temp_df.squeeze()
544
- temp_df.index.name = None
545
- temp_df.name = "china_exports_yoy"
546
- temp_df = temp_df.astype(float)
425
+ temp_df = __macro_china_base_func(
426
+ symbol="中国以美元计算出口年率报告", params=params
427
+ )
547
428
  return temp_df
548
429
 
549
430
 
@@ -553,57 +434,19 @@ def macro_china_imports_yoy() -> pd.DataFrame:
553
434
  中国以美元计算进口年率报告, 数据区间从 19960201-至今
554
435
  https://datacenter.jin10.com/reportType/dc_chinese_imports_yoy
555
436
  https://cdn.jin10.com/dc/reports/dc_chinese_imports_yoy_all.js?v=1578754588
556
- :return: 中国以美元计算进口年率报告-今值(%)
557
- :rtype: pandas.Series
437
+ :return: 中国以美元计算进口年率报告
438
+ :rtype: pandas.DataFrame
558
439
  """
559
440
  t = time.time()
560
- res = requests.get(
561
- f"https://cdn.jin10.com/dc/reports/dc_chinese_imports_yoy_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
562
- )
563
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
564
- date_list = [item["date"] for item in json_data["list"]]
565
- value_list = [item["datas"]["中国以美元计算进口年率报告"] for item in json_data["list"]]
566
- value_df = pd.DataFrame(value_list)
567
- value_df.columns = json_data["kinds"]
568
- value_df.index = pd.to_datetime(date_list)
569
- temp_df = value_df["今值(%)"]
570
- url = "https://datacenter-api.jin10.com/reports/list_v2"
571
441
  params = {
572
442
  "max_date": "",
573
443
  "category": "ec",
574
444
  "attr_id": "77",
575
445
  "_": str(int(round(t * 1000))),
576
446
  }
577
- headers = {
578
- "accept": "*/*",
579
- "accept-encoding": "gzip, deflate, br",
580
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
581
- "cache-control": "no-cache",
582
- "origin": "https://datacenter.jin10.com",
583
- "pragma": "no-cache",
584
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
585
- "sec-fetch-dest": "empty",
586
- "sec-fetch-mode": "cors",
587
- "sec-fetch-site": "same-site",
588
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
589
- "x-app-id": "rU6QIu7JHe2gOUeR",
590
- "x-csrf-token": "",
591
- "x-version": "1.0.0",
592
- }
593
- r = requests.get(url, params=params, headers=headers)
594
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
595
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
596
- temp_se = temp_se.iloc[:, 1]
597
- temp_df = pd.concat([temp_df, temp_se])
598
- temp_df.dropna(inplace=True)
599
- temp_df.sort_index(inplace=True)
600
- temp_df = temp_df.reset_index()
601
- temp_df.drop_duplicates(subset="index", inplace=True)
602
- temp_df.set_index("index", inplace=True)
603
- temp_df = temp_df.squeeze()
604
- temp_df.index.name = None
605
- temp_df.name = "china_imports_yoy"
606
- temp_df = temp_df.astype(float)
447
+ temp_df = __macro_china_base_func(
448
+ symbol="中国以美元计算进口年率报告", params=params
449
+ )
607
450
  return temp_df
608
451
 
609
452
 
@@ -613,57 +456,17 @@ def macro_china_trade_balance() -> pd.DataFrame:
613
456
  中国以美元计算贸易帐报告, 数据区间从 19810201-至今
614
457
  https://datacenter.jin10.com/reportType/dc_chinese_trade_balance
615
458
  https://cdn.jin10.com/dc/reports/dc_chinese_trade_balance_all.js?v=1578754677
616
- :return: 中国以美元计算贸易帐报告-今值(亿美元)
617
- :rtype: pandas.Series
459
+ :return: 中国以美元计算贸易帐报告
460
+ :rtype: pandas.DataFrame
618
461
  """
619
462
  t = time.time()
620
- res = requests.get(
621
- f"https://cdn.jin10.com/dc/reports/dc_chinese_trade_balance_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
622
- )
623
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
624
- date_list = [item["date"] for item in json_data["list"]]
625
- value_list = [item["datas"]["中国以美元计算贸易帐报告"] for item in json_data["list"]]
626
- value_df = pd.DataFrame(value_list)
627
- value_df.columns = json_data["kinds"]
628
- value_df.index = pd.to_datetime(date_list)
629
- temp_df = value_df["今值(亿美元)"]
630
- url = "https://datacenter-api.jin10.com/reports/list_v2"
631
463
  params = {
632
464
  "max_date": "",
633
465
  "category": "ec",
634
466
  "attr_id": "61",
635
467
  "_": str(int(round(t * 1000))),
636
468
  }
637
- headers = {
638
- "accept": "*/*",
639
- "accept-encoding": "gzip, deflate, br",
640
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
641
- "cache-control": "no-cache",
642
- "origin": "https://datacenter.jin10.com",
643
- "pragma": "no-cache",
644
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
645
- "sec-fetch-dest": "empty",
646
- "sec-fetch-mode": "cors",
647
- "sec-fetch-site": "same-site",
648
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
649
- "x-app-id": "rU6QIu7JHe2gOUeR",
650
- "x-csrf-token": "",
651
- "x-version": "1.0.0",
652
- }
653
- r = requests.get(url, params=params, headers=headers)
654
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
655
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
656
- temp_se = temp_se.iloc[:, 1]
657
- temp_df = pd.concat([temp_df, temp_se])
658
- temp_df.dropna(inplace=True)
659
- temp_df.sort_index(inplace=True)
660
- temp_df = temp_df.reset_index()
661
- temp_df.drop_duplicates(subset="index", inplace=True)
662
- temp_df.set_index("index", inplace=True)
663
- temp_df = temp_df.squeeze()
664
- temp_df.index.name = None
665
- temp_df.name = "china_trade_balance"
666
- temp_df = temp_df.astype(float)
469
+ temp_df = __macro_china_base_func(symbol="中国以美元计算贸易帐报告", params=params)
667
470
  return temp_df
668
471
 
669
472
 
@@ -673,179 +476,57 @@ def macro_china_industrial_production_yoy() -> pd.DataFrame:
673
476
  中国规模以上工业增加值年率报告, 数据区间从19900301-至今
674
477
  https://datacenter.jin10.com/reportType/dc_chinese_industrial_production_yoy
675
478
  https://cdn.jin10.com/dc/reports/dc_chinese_industrial_production_yoy_all.js?v=1578754779
676
- :return: 中国规模以上工业增加值年率报告-今值(%)
677
- :rtype: pandas.Series
479
+ :return: 中国规模以上工业增加值年率报告
480
+ :rtype: pandas.DataFrame
678
481
  """
679
482
  t = time.time()
680
- res = requests.get(
681
- f"https://cdn.jin10.com/dc/reports/dc_chinese_industrial_production_yoy_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
682
- )
683
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
684
- date_list = [item["date"] for item in json_data["list"]]
685
- value_list = [item["datas"]["中国规模以上工业增加值年率报告"] for item in json_data["list"]]
686
- value_df = pd.DataFrame(value_list)
687
- value_df.columns = json_data["kinds"]
688
- value_df.index = pd.to_datetime(date_list)
689
- temp_df = value_df["今值(%)"]
690
- url = "https://datacenter-api.jin10.com/reports/list_v2"
691
483
  params = {
692
484
  "max_date": "",
693
485
  "category": "ec",
694
486
  "attr_id": "58",
695
487
  "_": str(int(round(t * 1000))),
696
488
  }
697
- headers = {
698
- "accept": "*/*",
699
- "accept-encoding": "gzip, deflate, br",
700
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
701
- "cache-control": "no-cache",
702
- "origin": "https://datacenter.jin10.com",
703
- "pragma": "no-cache",
704
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
705
- "sec-fetch-dest": "empty",
706
- "sec-fetch-mode": "cors",
707
- "sec-fetch-site": "same-site",
708
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
709
- "x-app-id": "rU6QIu7JHe2gOUeR",
710
- "x-csrf-token": "",
711
- "x-version": "1.0.0",
712
- }
713
- r = requests.get(url, params=params, headers=headers)
714
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
715
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
716
- temp_se = temp_se.iloc[:, 1]
717
- temp_df = pd.concat([temp_df, temp_se])
718
- temp_df.dropna(inplace=True)
719
- temp_df.sort_index(inplace=True)
720
- temp_df = temp_df.reset_index()
721
- temp_df.drop_duplicates(subset="index", inplace=True)
722
- temp_df.set_index("index", inplace=True)
723
- temp_df = temp_df.squeeze()
724
- temp_df.index.name = None
725
- temp_df.name = "china_industrial_production_yoy"
726
- temp_df = temp_df.astype(float)
489
+ temp_df = __macro_china_base_func(
490
+ symbol="中国规模以上工业增加值年率报告", params=params
491
+ )
727
492
  return temp_df
728
493
 
729
494
 
730
495
  # 金十数据中心-经济指标-中国-产业指标-官方制造业PMI
731
496
  def macro_china_pmi_yearly() -> pd.DataFrame:
732
497
  """
733
- 中国年度 PMI 数据, 数据区间从20050201-至今
498
+ 中国年度 PMI 数据, 数据区间从 20050201-至今
734
499
  https://datacenter.jin10.com/reportType/dc_chinese_manufacturing_pmi
735
- https://cdn.jin10.com/dc/reports/dc_chinese_manufacturing_pmi_all.js?v=1578817858
736
- :return: pandas.Series
500
+ :return: 中国年度 PMI 数据
501
+ :return: pandas.DataFrame
737
502
  """
738
503
  t = time.time()
739
- res = requests.get(
740
- JS_CHINA_PMI_YEARLY_URL.format(
741
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
742
- )
743
- )
744
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
745
- date_list = [item["date"] for item in json_data["list"]]
746
- value_list = [item["datas"]["中国官方制造业PMI报告"] for item in json_data["list"]]
747
- value_df = pd.DataFrame(value_list)
748
- value_df.columns = json_data["kinds"]
749
- value_df.index = pd.to_datetime(date_list)
750
- temp_df = value_df["今值"]
751
- url = "https://datacenter-api.jin10.com/reports/list_v2"
752
504
  params = {
753
- "max_date": "",
754
505
  "category": "ec",
755
506
  "attr_id": "65",
507
+ "max_date": "",
756
508
  "_": str(int(round(t * 1000))),
757
509
  }
758
- headers = {
759
- "accept": "*/*",
760
- "accept-encoding": "gzip, deflate, br",
761
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
762
- "cache-control": "no-cache",
763
- "origin": "https://datacenter.jin10.com",
764
- "pragma": "no-cache",
765
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
766
- "sec-fetch-dest": "empty",
767
- "sec-fetch-mode": "cors",
768
- "sec-fetch-site": "same-site",
769
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
770
- "x-app-id": "rU6QIu7JHe2gOUeR",
771
- "x-csrf-token": "",
772
- "x-version": "1.0.0",
773
- }
774
- r = requests.get(url, params=params, headers=headers)
775
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
776
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
777
- temp_se = temp_se.iloc[:, 1]
778
- temp_df = pd.concat([temp_df, temp_se])
779
- temp_df.dropna(inplace=True)
780
- temp_df.sort_index(inplace=True)
781
- temp_df = temp_df.reset_index()
782
- temp_df.drop_duplicates(subset="index", inplace=True)
783
- temp_df.set_index("index", inplace=True)
784
- temp_df = temp_df.squeeze()
785
- temp_df.index.name = None
786
- temp_df.name = "pmi"
787
- temp_df = temp_df.astype(float)
510
+ temp_df = __macro_china_base_func(symbol="中国官方制造业PMI", params=params)
788
511
  return temp_df
789
512
 
790
513
 
791
514
  # 金十数据中心-经济指标-中国-产业指标-财新制造业PMI终值
792
515
  def macro_china_cx_pmi_yearly() -> pd.DataFrame:
793
516
  """
794
- 中国年度财新PMI数据, 数据区间从 20120120-至今
517
+ 中国年度财新 PMI 数据, 数据区间从 20120120-至今
795
518
  https://datacenter.jin10.com/reportType/dc_chinese_caixin_manufacturing_pmi
796
- https://cdn.jin10.com/dc/reports/dc_chinese_caixin_manufacturing_pmi_all.js?v=1578818009
797
- :return: pandas.Series
519
+ :return: 中国年度财新 PMI 数据
520
+ :return: pandas.DataFrame
798
521
  """
799
522
  t = time.time()
800
- res = requests.get(
801
- JS_CHINA_CX_PMI_YEARLY_URL.format(
802
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
803
- )
804
- )
805
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
806
- date_list = [item["date"] for item in json_data["list"]]
807
- value_list = [item["datas"]["中国财新制造业PMI终值报告"] for item in json_data["list"]]
808
- value_df = pd.DataFrame(value_list)
809
- value_df.columns = json_data["kinds"]
810
- value_df.index = pd.to_datetime(date_list)
811
- temp_df = value_df["今值"]
812
- url = "https://datacenter-api.jin10.com/reports/list_v2"
813
523
  params = {
814
524
  "max_date": "",
815
525
  "category": "ec",
816
526
  "attr_id": "73",
817
527
  "_": str(int(round(t * 1000))),
818
528
  }
819
- headers = {
820
- "accept": "*/*",
821
- "accept-encoding": "gzip, deflate, br",
822
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
823
- "cache-control": "no-cache",
824
- "origin": "https://datacenter.jin10.com",
825
- "pragma": "no-cache",
826
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
827
- "sec-fetch-dest": "empty",
828
- "sec-fetch-mode": "cors",
829
- "sec-fetch-site": "same-site",
830
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
831
- "x-app-id": "rU6QIu7JHe2gOUeR",
832
- "x-csrf-token": "",
833
- "x-version": "1.0.0",
834
- }
835
- r = requests.get(url, params=params, headers=headers)
836
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
837
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
838
- temp_se = temp_se.iloc[:, 1]
839
- temp_df = pd.concat([temp_df, temp_se])
840
- temp_df.dropna(inplace=True)
841
- temp_df.sort_index(inplace=True)
842
- temp_df = temp_df.reset_index()
843
- temp_df.drop_duplicates(subset="index", inplace=True)
844
- temp_df.set_index("index", inplace=True)
845
- temp_df = temp_df.squeeze()
846
- temp_df.index.name = None
847
- temp_df.name = "cx_pmi"
848
- temp_df = temp_df.astype(float)
529
+ temp_df = __macro_china_base_func(symbol="中国财新制造业PMI终值报告", params=params)
849
530
  return temp_df
850
531
 
851
532
 
@@ -855,58 +536,16 @@ def macro_china_cx_services_pmi_yearly() -> pd.DataFrame:
855
536
  中国财新服务业PMI报告, 数据区间从 20120405-至今
856
537
  https://datacenter.jin10.com/reportType/dc_chinese_caixin_services_pmi
857
538
  https://cdn.jin10.com/dc/reports/dc_chinese_caixin_services_pmi_all.js?v=1578818109
858
- :return: pandas.Series
539
+ :return: pandas.DataFrame
859
540
  """
860
541
  t = time.time()
861
- res = requests.get(
862
- JS_CHINA_CX_SERVICE_PMI_YEARLY_URL.format(
863
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
864
- )
865
- )
866
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
867
- date_list = [item["date"] for item in json_data["list"]]
868
- value_list = [item["datas"]["中国财新服务业PMI报告"] for item in json_data["list"]]
869
- value_df = pd.DataFrame(value_list)
870
- value_df.columns = json_data["kinds"]
871
- value_df.index = pd.to_datetime(date_list)
872
- temp_df = value_df["今值"]
873
- url = "https://datacenter-api.jin10.com/reports/list_v2"
874
542
  params = {
875
543
  "max_date": "",
876
544
  "category": "ec",
877
545
  "attr_id": "67",
878
546
  "_": str(int(round(t * 1000))),
879
547
  }
880
- headers = {
881
- "accept": "*/*",
882
- "accept-encoding": "gzip, deflate, br",
883
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
884
- "cache-control": "no-cache",
885
- "origin": "https://datacenter.jin10.com",
886
- "pragma": "no-cache",
887
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
888
- "sec-fetch-dest": "empty",
889
- "sec-fetch-mode": "cors",
890
- "sec-fetch-site": "same-site",
891
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
892
- "x-app-id": "rU6QIu7JHe2gOUeR",
893
- "x-csrf-token": "",
894
- "x-version": "1.0.0",
895
- }
896
- r = requests.get(url, params=params, headers=headers)
897
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
898
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
899
- temp_se = temp_se.iloc[:, 1]
900
- temp_df = pd.concat([temp_df, temp_se])
901
- temp_df.dropna(inplace=True)
902
- temp_df.sort_index(inplace=True)
903
- temp_df = temp_df.reset_index()
904
- temp_df.drop_duplicates(subset="index", inplace=True)
905
- temp_df.set_index("index", inplace=True)
906
- temp_df = temp_df.squeeze()
907
- temp_df.index.name = None
908
- temp_df.name = "cx_services_pmi"
909
- temp_df = temp_df.astype(float)
548
+ temp_df = __macro_china_base_func(symbol="中国财新服务业PMI报告", params=params)
910
549
  return temp_df
911
550
 
912
551
 
@@ -915,59 +554,17 @@ def macro_china_non_man_pmi() -> pd.DataFrame:
915
554
  """
916
555
  中国官方非制造业 PMI, 数据区间从 20160101-至今
917
556
  https://datacenter.jin10.com/reportType/dc_chinese_non_manufacturing_pmi
918
- https://cdn.jin10.com/dc/reports/dc_chinese_non_manufacturing_pmi_all.js?v=1578818248
919
- :return: pandas.Series
557
+ :return: 中国官方非制造业 PMI
558
+ :return: pandas.DataFrame
920
559
  """
921
560
  t = time.time()
922
- res = requests.get(
923
- JS_CHINA_NON_MAN_PMI_MONTHLY_URL.format(
924
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
925
- )
926
- )
927
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
928
- date_list = [item["date"] for item in json_data["list"]]
929
- value_list = [item["datas"]["中国官方非制造业PMI报告"] for item in json_data["list"]]
930
- value_df = pd.DataFrame(value_list)
931
- value_df.columns = json_data["kinds"]
932
- value_df.index = pd.to_datetime(date_list)
933
- temp_df = value_df["今值"]
934
- url = "https://datacenter-api.jin10.com/reports/list_v2"
935
561
  params = {
936
562
  "max_date": "",
937
563
  "category": "ec",
938
564
  "attr_id": "75",
939
565
  "_": str(int(round(t * 1000))),
940
566
  }
941
- headers = {
942
- "accept": "*/*",
943
- "accept-encoding": "gzip, deflate, br",
944
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
945
- "cache-control": "no-cache",
946
- "origin": "https://datacenter.jin10.com",
947
- "pragma": "no-cache",
948
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
949
- "sec-fetch-dest": "empty",
950
- "sec-fetch-mode": "cors",
951
- "sec-fetch-site": "same-site",
952
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
953
- "x-app-id": "rU6QIu7JHe2gOUeR",
954
- "x-csrf-token": "",
955
- "x-version": "1.0.0",
956
- }
957
- r = requests.get(url, params=params, headers=headers)
958
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
959
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
960
- temp_se = temp_se.iloc[:, 1]
961
- temp_df = pd.concat([temp_df, temp_se])
962
- temp_df.dropna(inplace=True)
963
- temp_df.sort_index(inplace=True)
964
- temp_df = temp_df.reset_index()
965
- temp_df.drop_duplicates(subset="index", inplace=True)
966
- temp_df.set_index("index", inplace=True)
967
- temp_df = temp_df.squeeze()
968
- temp_df.index.name = None
969
- temp_df.name = "non_pmi"
970
- temp_df = temp_df.astype(float)
567
+ temp_df = __macro_china_base_func(symbol="中国官方非制造业PMI报告", params=params)
971
568
  return temp_df
972
569
 
973
570
 
@@ -976,59 +573,17 @@ def macro_china_fx_reserves_yearly() -> pd.DataFrame:
976
573
  """
977
574
  中国年度外汇储备数据, 数据区间从 20140115-至今
978
575
  https://datacenter.jin10.com/reportType/dc_chinese_fx_reserves
979
- https://cdn.jin10.com/dc/reports/dc_chinese_fx_reserves_all.js?v=1578818365
980
- :return: pandas.Series
576
+ :return: 中国年度外汇储备数据
577
+ :return: pandas.DataFrame
981
578
  """
982
579
  t = time.time()
983
- res = requests.get(
984
- JS_CHINA_FX_RESERVES_YEARLY_URL.format(
985
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
986
- )
987
- )
988
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
989
- date_list = [item["date"] for item in json_data["list"]]
990
- value_list = [item["datas"]["中国外汇储备报告"] for item in json_data["list"]]
991
- value_df = pd.DataFrame(value_list)
992
- value_df.columns = json_data["kinds"]
993
- value_df.index = pd.to_datetime(date_list)
994
- temp_df = value_df["今值(亿美元)"]
995
- url = "https://datacenter-api.jin10.com/reports/list_v2"
996
580
  params = {
997
581
  "max_date": "",
998
582
  "category": "ec",
999
583
  "attr_id": "76",
1000
584
  "_": str(int(round(t * 1000))),
1001
585
  }
1002
- headers = {
1003
- "accept": "*/*",
1004
- "accept-encoding": "gzip, deflate, br",
1005
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1006
- "cache-control": "no-cache",
1007
- "origin": "https://datacenter.jin10.com",
1008
- "pragma": "no-cache",
1009
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1010
- "sec-fetch-dest": "empty",
1011
- "sec-fetch-mode": "cors",
1012
- "sec-fetch-site": "same-site",
1013
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
1014
- "x-app-id": "rU6QIu7JHe2gOUeR",
1015
- "x-csrf-token": "",
1016
- "x-version": "1.0.0",
1017
- }
1018
- r = requests.get(url, params=params, headers=headers)
1019
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1020
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1021
- temp_se = temp_se.iloc[:, 1]
1022
- temp_df = pd.concat([temp_df, temp_se])
1023
- temp_df.dropna(inplace=True)
1024
- temp_df.sort_index(inplace=True)
1025
- temp_df = temp_df.reset_index()
1026
- temp_df.drop_duplicates(subset="index", inplace=True)
1027
- temp_df.set_index("index", inplace=True)
1028
- temp_df = temp_df.squeeze()
1029
- temp_df.index.name = None
1030
- temp_df.name = "fx_reserves"
1031
- temp_df = temp_df.astype(float)
586
+ temp_df = __macro_china_base_func(symbol="中国外汇储备报告", params=params)
1032
587
  return temp_df
1033
588
 
1034
589
 
@@ -1037,59 +592,17 @@ def macro_china_m2_yearly() -> pd.DataFrame:
1037
592
  """
1038
593
  中国年度 M2 数据, 数据区间从 19980201-至今
1039
594
  https://datacenter.jin10.com/reportType/dc_chinese_m2_money_supply_yoy
1040
- https://cdn.jin10.com/dc/reports/dc_chinese_m2_money_supply_yoy_all.js?v=1578818474
1041
- :return: pandas.Series
595
+ :return: 中国年度 M2 数据
596
+ :return: pandas.DataFrame
1042
597
  """
1043
598
  t = time.time()
1044
- res = requests.get(
1045
- JS_CHINA_M2_YEARLY_URL.format(
1046
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
1047
- )
1048
- )
1049
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
1050
- date_list = [item["date"] for item in json_data["list"]]
1051
- value_list = [item["datas"]["中国M2货币供应年率报告"] for item in json_data["list"]]
1052
- value_df = pd.DataFrame(value_list)
1053
- value_df.columns = json_data["kinds"]
1054
- value_df.index = pd.to_datetime(date_list)
1055
- temp_df = value_df["今值(%)"]
1056
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1057
599
  params = {
1058
600
  "max_date": "",
1059
601
  "category": "ec",
1060
602
  "attr_id": "59",
1061
603
  "_": str(int(round(t * 1000))),
1062
604
  }
1063
- headers = {
1064
- "accept": "*/*",
1065
- "accept-encoding": "gzip, deflate, br",
1066
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1067
- "cache-control": "no-cache",
1068
- "origin": "https://datacenter.jin10.com",
1069
- "pragma": "no-cache",
1070
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1071
- "sec-fetch-dest": "empty",
1072
- "sec-fetch-mode": "cors",
1073
- "sec-fetch-site": "same-site",
1074
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
1075
- "x-app-id": "rU6QIu7JHe2gOUeR",
1076
- "x-csrf-token": "",
1077
- "x-version": "1.0.0",
1078
- }
1079
- r = requests.get(url, params=params, headers=headers)
1080
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1081
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1082
- temp_se = temp_se.iloc[:, 1]
1083
- temp_df = pd.concat([temp_df, temp_se])
1084
- temp_df.dropna(inplace=True)
1085
- temp_df.sort_index(inplace=True)
1086
- temp_df = temp_df.reset_index()
1087
- temp_df.drop_duplicates(subset="index", inplace=True)
1088
- temp_df.set_index("index", inplace=True)
1089
- temp_df = temp_df.squeeze()
1090
- temp_df.index.name = None
1091
- temp_df.name = "gpd"
1092
- temp_df = temp_df.astype("float")
605
+ temp_df = __macro_china_base_func(symbol="中国M2货币供应年率报告", params=params)
1093
606
  return temp_df
1094
607
 
1095
608
 
@@ -1100,40 +613,42 @@ def macro_china_shibor_all() -> pd.DataFrame:
1100
613
  https://datacenter.jin10.com/reportType/dc_shibor
1101
614
  https://cdn.jin10.com/dc/reports/dc_shibor_all.js?v=1578755058
1102
615
  :return: 上海银行业同业拆借报告-今值(%)
1103
- :rtype: pandas.Series
616
+ :rtype: pandas.DataFrame
1104
617
  """
618
+ import numpy as np
619
+
1105
620
  t = time.time()
1106
621
  params = {"_": t}
1107
622
  res = requests.get(
1108
- "https://cdn.jin10.com/data_center/reports/il_1.json", params=params
623
+ url="https://cdn.jin10.com/data_center/reports/il_1.json", params=params
1109
624
  )
1110
625
  json_data = res.json()
1111
626
  temp_df = pd.DataFrame(json_data["values"]).T
1112
627
  big_df = pd.DataFrame()
1113
628
  temp_df.fillna(value="--", inplace=True)
1114
- big_df["O/N_定价"] = temp_df["O/N"].apply(lambda x: x[0])
1115
- big_df["O/N_涨跌幅"] = temp_df["O/N"].apply(lambda x: x[1])
1116
- big_df["1W_定价"] = temp_df["1W"].apply(lambda x: x[0])
1117
- big_df["1W_涨跌幅"] = temp_df["1W"].apply(lambda x: x[1])
1118
- big_df["2W_定价"] = temp_df["2W"].apply(lambda x: x[0])
1119
- big_df["2W_涨跌幅"] = temp_df["2W"].apply(lambda x: x[1])
1120
- big_df["1M_定价"] = temp_df["1M"].apply(lambda x: x[0])
1121
- big_df["1M_涨跌幅"] = temp_df["1M"].apply(lambda x: x[1])
1122
- big_df["3M_定价"] = temp_df["3M"].apply(lambda x: x[0])
1123
- big_df["3M_涨跌幅"] = temp_df["3M"].apply(lambda x: x[1])
1124
- big_df["6M_定价"] = temp_df["6M"].apply(lambda x: x[0])
1125
- big_df["6M_涨跌幅"] = temp_df["6M"].apply(lambda x: x[1])
1126
- big_df["9M_定价"] = temp_df["9M"].apply(lambda x: x[0])
1127
- big_df["9M_涨跌幅"] = temp_df["9M"].apply(lambda x: x[1])
1128
- big_df["1Y_定价"] = temp_df["1Y"].apply(lambda x: x[0])
1129
- big_df["1Y_涨跌幅"] = temp_df["1Y"].apply(lambda x: x[1])
1130
- # big_df["ON_定价"] = temp_df["ON"].apply(lambda x: x[0])
1131
- # big_df["ON_涨跌幅"] = temp_df["ON"].apply(lambda x: x[1])
1132
- # big_df["2M_定价"] = temp_df["2M"].apply(lambda x: x[0])
1133
- # big_df["2M_涨跌幅"] = temp_df["2M"].apply(lambda x: x[1])
1134
- big_df = big_df.apply(lambda x: x.replace("-", pd.NA))
1135
- big_df = big_df.apply(lambda x: x.replace([None], pd.NA))
629
+ big_df["O/N-定价"] = temp_df["O/N"].apply(lambda x: x[0])
630
+ big_df["O/N-涨跌幅"] = temp_df["O/N"].apply(lambda x: x[1])
631
+ big_df["1W-定价"] = temp_df["1W"].apply(lambda x: x[0])
632
+ big_df["1W-涨跌幅"] = temp_df["1W"].apply(lambda x: x[1])
633
+ big_df["2W-定价"] = temp_df["2W"].apply(lambda x: x[0])
634
+ big_df["2W-涨跌幅"] = temp_df["2W"].apply(lambda x: x[1])
635
+ big_df["1M-定价"] = temp_df["1M"].apply(lambda x: x[0])
636
+ big_df["1M-涨跌幅"] = temp_df["1M"].apply(lambda x: x[1])
637
+ big_df["3M-定价"] = temp_df["3M"].apply(lambda x: x[0])
638
+ big_df["3M-涨跌幅"] = temp_df["3M"].apply(lambda x: x[1])
639
+ big_df["6M-定价"] = temp_df["6M"].apply(lambda x: x[0])
640
+ big_df["6M-涨跌幅"] = temp_df["6M"].apply(lambda x: x[1])
641
+ big_df["9M-定价"] = temp_df["9M"].apply(lambda x: x[0])
642
+ big_df["9M-涨跌幅"] = temp_df["9M"].apply(lambda x: x[1])
643
+ big_df["1Y-定价"] = temp_df["1Y"].apply(lambda x: x[0])
644
+ big_df["1Y-涨跌幅"] = temp_df["1Y"].apply(lambda x: x[1])
645
+ big_df = big_df.apply(lambda x: x.replace("-", np.nan))
646
+ big_df = big_df.apply(lambda x: x.replace([None], np.nan))
647
+ for item in big_df.columns:
648
+ big_df[item] = pd.to_numeric(big_df[item], errors="coerce")
1136
649
  big_df.sort_index(inplace=True)
650
+ big_df.reset_index(inplace=True)
651
+ big_df.rename(columns={"index": "日期"}, inplace=True)
1137
652
  return big_df
1138
653
 
1139
654
 
@@ -1144,78 +659,42 @@ def macro_china_hk_market_info() -> pd.DataFrame:
1144
659
  https://datacenter.jin10.com/reportType/dc_hk_market_info
1145
660
  https://cdn.jin10.com/dc/reports/dc_hk_market_info_all.js?v=1578755471
1146
661
  :return: 香港同业拆借报告-今值(%)
1147
- :rtype: pandas.Series
662
+ :rtype: pandas.DataFrame
1148
663
  """
664
+ import numpy as np
665
+
1149
666
  t = time.time()
1150
667
  params = {"_": t}
1151
668
  res = requests.get(
1152
- "https://cdn.jin10.com/data_center/reports/il_2.json", params=params
669
+ url="https://cdn.jin10.com/data_center/reports/il_2.json", params=params
1153
670
  )
1154
671
  json_data = res.json()
1155
672
  temp_df = pd.DataFrame(json_data["values"]).T
1156
673
  big_df = pd.DataFrame()
1157
674
  temp_df.fillna(value="--", inplace=True)
1158
- # big_df["O/N_定价"] = temp_df["O/N"].apply(lambda x: x[0])
1159
- # big_df["O/N_涨跌幅"] = temp_df["O/N"].apply(lambda x: x[1])
1160
- big_df["1W_定价"] = temp_df["1W"].apply(lambda x: x[0])
1161
- big_df["1W_涨跌幅"] = temp_df["1W"].apply(lambda x: x[1])
1162
- big_df["2W_定价"] = temp_df["2W"].apply(lambda x: x[0])
1163
- big_df["2W_涨跌幅"] = temp_df["2W"].apply(lambda x: x[1])
1164
- big_df["1M_定价"] = temp_df["1M"].apply(lambda x: x[0])
1165
- big_df["1M_涨跌幅"] = temp_df["1M"].apply(lambda x: x[1])
1166
- big_df["3M_定价"] = temp_df["3M"].apply(lambda x: x[0])
1167
- big_df["3M_涨跌幅"] = temp_df["3M"].apply(lambda x: x[1])
1168
- big_df["6M_定价"] = temp_df["6M"].apply(lambda x: x[0])
1169
- big_df["6M_涨跌幅"] = temp_df["6M"].apply(lambda x: x[1])
1170
- # big_df["9M_定价"] = temp_df["9M"].apply(lambda x: x[0])
1171
- # big_df["9M_涨跌幅"] = temp_df["9M"].apply(lambda x: x[1])
1172
- big_df["1Y_定价"] = temp_df["1Y"].apply(lambda x: x[0])
1173
- big_df["1Y_涨跌幅"] = temp_df["1Y"].apply(lambda x: x[1])
1174
- big_df["ON_定价"] = temp_df["ON"].apply(lambda x: x[0])
1175
- big_df["ON_涨跌幅"] = temp_df["ON"].apply(lambda x: x[1])
1176
- big_df["2M_定价"] = temp_df["2M"].apply(lambda x: x[0])
1177
- big_df["2M_涨跌幅"] = temp_df["2M"].apply(lambda x: x[1])
1178
- big_df = big_df.apply(lambda x: x.replace("-", pd.NA))
1179
- big_df = big_df.apply(lambda x: x.replace([None], pd.NA))
675
+ big_df["1W-定价"] = temp_df["1W"].apply(lambda x: x[0])
676
+ big_df["1W-涨跌幅"] = temp_df["1W"].apply(lambda x: x[1])
677
+ big_df["2W-定价"] = temp_df["2W"].apply(lambda x: x[0])
678
+ big_df["2W-涨跌幅"] = temp_df["2W"].apply(lambda x: x[1])
679
+ big_df["1M-定价"] = temp_df["1M"].apply(lambda x: x[0])
680
+ big_df["1M-涨跌幅"] = temp_df["1M"].apply(lambda x: x[1])
681
+ big_df["3M-定价"] = temp_df["3M"].apply(lambda x: x[0])
682
+ big_df["3M-涨跌幅"] = temp_df["3M"].apply(lambda x: x[1])
683
+ big_df["6M-定价"] = temp_df["6M"].apply(lambda x: x[0])
684
+ big_df["6M-涨跌幅"] = temp_df["6M"].apply(lambda x: x[1])
685
+ big_df["1Y-定价"] = temp_df["1Y"].apply(lambda x: x[0])
686
+ big_df["1Y-涨跌幅"] = temp_df["1Y"].apply(lambda x: x[1])
687
+ big_df["ON-定价"] = temp_df["ON"].apply(lambda x: x[0])
688
+ big_df["ON-涨跌幅"] = temp_df["ON"].apply(lambda x: x[1])
689
+ big_df["2M-定价"] = temp_df["2M"].apply(lambda x: x[0])
690
+ big_df["2M-涨跌幅"] = temp_df["2M"].apply(lambda x: x[1])
691
+ big_df = big_df.apply(lambda x: x.replace("-", np.nan))
692
+ big_df = big_df.apply(lambda x: x.replace([None], np.nan))
693
+ for item in big_df.columns:
694
+ big_df[item] = pd.to_numeric(big_df[item], errors="coerce")
1180
695
  big_df.sort_index(inplace=True)
1181
696
  big_df.reset_index(inplace=True)
1182
- big_df.columns = [
1183
- "日期",
1184
- "1W_定价",
1185
- "1W_涨跌幅",
1186
- "2W_定价",
1187
- "2W_涨跌幅",
1188
- "1M_定价",
1189
- "1M_涨跌幅",
1190
- "3M_定价",
1191
- "3M_涨跌幅",
1192
- "6M_定价",
1193
- "6M_涨跌幅",
1194
- "1Y_定价",
1195
- "1Y_涨跌幅",
1196
- "ON_定价",
1197
- "ON_涨跌幅",
1198
- "2M_定价",
1199
- "2M_涨跌幅",
1200
- ]
1201
-
1202
- big_df["1W_定价"] = pd.to_numeric(big_df["1W_定价"])
1203
- big_df["1W_涨跌幅"] = pd.to_numeric(big_df["1W_涨跌幅"])
1204
- big_df["2W_定价"] = pd.to_numeric(big_df["2W_定价"])
1205
- big_df["2W_涨跌幅"] = pd.to_numeric(big_df["2W_涨跌幅"])
1206
- big_df["1M_定价"] = pd.to_numeric(big_df["1M_定价"])
1207
- big_df["1M_涨跌幅"] = pd.to_numeric(big_df["1M_涨跌幅"])
1208
- big_df["3M_定价"] = pd.to_numeric(big_df["3M_定价"])
1209
- big_df["3M_涨跌幅"] = pd.to_numeric(big_df["3M_涨跌幅"])
1210
- big_df["6M_定价"] = pd.to_numeric(big_df["6M_定价"])
1211
- big_df["6M_涨跌幅"] = pd.to_numeric(big_df["6M_涨跌幅"])
1212
- big_df["1Y_定价"] = pd.to_numeric(big_df["1Y_定价"])
1213
- big_df["1Y_涨跌幅"] = pd.to_numeric(big_df["1Y_涨跌幅"])
1214
- big_df["ON_定价"] = pd.to_numeric(big_df["ON_定价"])
1215
- big_df["ON_涨跌幅"] = pd.to_numeric(big_df["ON_涨跌幅"])
1216
- big_df["2M_定价"] = pd.to_numeric(big_df["2M_定价"])
1217
- big_df["2M_涨跌幅"] = pd.to_numeric(big_df["2M_涨跌幅"])
1218
-
697
+ big_df.rename(columns={"index": "日期"}, inplace=True)
1219
698
  return big_df
1220
699
 
1221
700
 
@@ -1224,20 +703,7 @@ def macro_china_daily_energy() -> pd.DataFrame:
1224
703
  """
1225
704
  中国日度沿海六大电库存数据, 数据区间从20160101-至今
1226
705
  https://datacenter.jin10.com/reportType/dc_qihuo_energy_report
1227
- https://cdn.jin10.com/dc/reports/dc_qihuo_energy_report_all.js?v=1578819100
1228
- :return: pandas.Series
1229
- 沿海六大电库存 日耗 存煤可用天数
1230
- 2016-01-01 1167.60 64.20 18.19
1231
- 2016-01-02 1162.90 63.40 18.34
1232
- 2016-01-03 1160.80 62.60 18.54
1233
- 2016-01-04 1185.30 57.60 20.58
1234
- 2016-01-05 1150.20 57.20 20.11
1235
- ... ... ...
1236
- 2019-05-17 1639.47 61.71 26.56
1237
- 2019-05-21 1591.92 62.67 25.40
1238
- 2019-05-22 1578.63 59.54 26.51
1239
- 2019-05-24 1671.83 60.65 27.56
1240
- 2019-06-21 1786.64 66.57 26.84
706
+ :return: pandas.DataFrame
1241
707
  """
1242
708
  t = time.time()
1243
709
  res = requests.get(
@@ -1245,15 +711,20 @@ def macro_china_daily_energy() -> pd.DataFrame:
1245
711
  str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
1246
712
  )
1247
713
  )
1248
- json_data = json.loads(res.text[res.text.find("{"): res.text.rfind("}") + 1])
714
+ json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1249
715
  date_list = [item["date"] for item in json_data["list"]]
1250
- value_list = [item["datas"]["沿海六大电厂库存动态报告"] for item in json_data["list"]]
716
+ value_list = [
717
+ item["datas"]["沿海六大电厂库存动态报告"] for item in json_data["list"]
718
+ ]
1251
719
  value_df = pd.DataFrame(value_list)
1252
720
  value_df.columns = json_data["kinds"]
1253
721
  value_df.index = pd.to_datetime(date_list)
1254
722
  temp_df = value_df[["沿海六大电库存", "日耗", "存煤可用天数"]]
1255
723
  temp_df.name = "energy"
1256
724
  temp_df = temp_df.astype(float)
725
+ temp_df.reset_index(inplace=True)
726
+ temp_df.rename(columns={"index": "日期"}, inplace=True)
727
+ temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
1257
728
  return temp_df
1258
729
 
1259
730
 
@@ -1295,32 +766,64 @@ def macro_china_rmb() -> pd.DataFrame:
1295
766
  big_df["瑞郎/人民币_涨跌幅"] = temp_df["瑞郎/人民币"].apply(lambda x: x[1])
1296
767
  big_df["加元/人民币_中间价"] = temp_df["加元/人民币"].apply(lambda x: x[0])
1297
768
  big_df["加元/人民币_涨跌幅"] = temp_df["加元/人民币"].apply(lambda x: x[1])
1298
- big_df["人民币/马来西亚林吉特_中间价"] = temp_df["人民币/马来西亚林吉特"].apply(lambda x: x[0])
1299
- big_df["人民币/马来西亚林吉特_涨跌幅"] = temp_df["人民币/马来西亚林吉特"].apply(lambda x: x[1])
1300
- big_df["人民币/俄罗斯卢布_中间价"] = temp_df["人民币/俄罗斯卢布"].apply(lambda x: x[0])
1301
- big_df["人民币/俄罗斯卢布_涨跌幅"] = temp_df["人民币/俄罗斯卢布"].apply(lambda x: x[1])
769
+ big_df["人民币/马来西亚林吉特_中间价"] = temp_df["人民币/马来西亚林吉特"].apply(
770
+ lambda x: x[0]
771
+ )
772
+ big_df["人民币/马来西亚林吉特_涨跌幅"] = temp_df["人民币/马来西亚林吉特"].apply(
773
+ lambda x: x[1]
774
+ )
775
+ big_df["人民币/俄罗斯卢布_中间价"] = temp_df["人民币/俄罗斯卢布"].apply(
776
+ lambda x: x[0]
777
+ )
778
+ big_df["人民币/俄罗斯卢布_涨跌幅"] = temp_df["人民币/俄罗斯卢布"].apply(
779
+ lambda x: x[1]
780
+ )
1302
781
  big_df["人民币/南非兰特_中间价"] = temp_df["人民币/南非兰特"].apply(lambda x: x[0])
1303
782
  big_df["人民币/南非兰特_涨跌幅"] = temp_df["人民币/南非兰特"].apply(lambda x: x[1])
1304
783
  big_df["人民币/韩元_中间价"] = temp_df["人民币/韩元"].apply(lambda x: x[0])
1305
784
  big_df["人民币/韩元_涨跌幅"] = temp_df["人民币/韩元"].apply(lambda x: x[1])
1306
- big_df["人民币/阿联酋迪拉姆_中间价"] = temp_df["人民币/阿联酋迪拉姆"].apply(lambda x: x[0])
1307
- big_df["人民币/阿联酋迪拉姆_涨跌幅"] = temp_df["人民币/阿联酋迪拉姆"].apply(lambda x: x[1])
1308
- big_df["人民币/沙特里亚尔_中间价"] = temp_df["人民币/沙特里亚尔"].apply(lambda x: x[0])
1309
- big_df["人民币/沙特里亚尔_涨跌幅"] = temp_df["人民币/沙特里亚尔"].apply(lambda x: x[1])
1310
- big_df["人民币/匈牙利福林_中间价"] = temp_df["人民币/匈牙利福林"].apply(lambda x: x[0])
1311
- big_df["人民币/匈牙利福林_涨跌幅"] = temp_df["人民币/匈牙利福林"].apply(lambda x: x[1])
1312
- big_df["人民币/波兰兹罗提_中间价"] = temp_df["人民币/波兰兹罗提"].apply(lambda x: x[0])
1313
- big_df["人民币/波兰兹罗提_涨跌幅"] = temp_df["人民币/波兰兹罗提"].apply(lambda x: x[1])
785
+ big_df["人民币/阿联酋迪拉姆_中间价"] = temp_df["人民币/阿联酋迪拉姆"].apply(
786
+ lambda x: x[0]
787
+ )
788
+ big_df["人民币/阿联酋迪拉姆_涨跌幅"] = temp_df["人民币/阿联酋迪拉姆"].apply(
789
+ lambda x: x[1]
790
+ )
791
+ big_df["人民币/沙特里亚尔_中间价"] = temp_df["人民币/沙特里亚尔"].apply(
792
+ lambda x: x[0]
793
+ )
794
+ big_df["人民币/沙特里亚尔_涨跌幅"] = temp_df["人民币/沙特里亚尔"].apply(
795
+ lambda x: x[1]
796
+ )
797
+ big_df["人民币/匈牙利福林_中间价"] = temp_df["人民币/匈牙利福林"].apply(
798
+ lambda x: x[0]
799
+ )
800
+ big_df["人民币/匈牙利福林_涨跌幅"] = temp_df["人民币/匈牙利福林"].apply(
801
+ lambda x: x[1]
802
+ )
803
+ big_df["人民币/波兰兹罗提_中间价"] = temp_df["人民币/波兰兹罗提"].apply(
804
+ lambda x: x[0]
805
+ )
806
+ big_df["人民币/波兰兹罗提_涨跌幅"] = temp_df["人民币/波兰兹罗提"].apply(
807
+ lambda x: x[1]
808
+ )
1314
809
  big_df["人民币/丹麦克朗_中间价"] = temp_df["人民币/丹麦克朗"].apply(lambda x: x[0])
1315
810
  big_df["人民币/丹麦克朗_涨跌幅"] = temp_df["人民币/丹麦克朗"].apply(lambda x: x[1])
1316
811
  big_df["人民币/瑞典克朗_中间价"] = temp_df["人民币/瑞典克朗"].apply(lambda x: x[0])
1317
812
  big_df["人民币/瑞典克朗_涨跌幅"] = temp_df["人民币/瑞典克朗"].apply(lambda x: x[1])
1318
813
  big_df["人民币/挪威克朗_中间价"] = temp_df["人民币/挪威克朗"].apply(lambda x: x[0])
1319
814
  big_df["人民币/挪威克朗_涨跌幅"] = temp_df["人民币/挪威克朗"].apply(lambda x: x[1])
1320
- big_df["人民币/土耳其里拉_中间价"] = temp_df["人民币/土耳其里拉"].apply(lambda x: x[0])
1321
- big_df["人民币/土耳其里拉_涨跌幅"] = temp_df["人民币/土耳其里拉"].apply(lambda x: x[1])
1322
- big_df["人民币/墨西哥比索_中间价"] = temp_df["人民币/墨西哥比索"].apply(lambda x: x[0])
1323
- big_df["人民币/墨西哥比索_涨跌幅"] = temp_df["人民币/墨西哥比索"].apply(lambda x: x[1])
815
+ big_df["人民币/土耳其里拉_中间价"] = temp_df["人民币/土耳其里拉"].apply(
816
+ lambda x: x[0]
817
+ )
818
+ big_df["人民币/土耳其里拉_涨跌幅"] = temp_df["人民币/土耳其里拉"].apply(
819
+ lambda x: x[1]
820
+ )
821
+ big_df["人民币/墨西哥比索_中间价"] = temp_df["人民币/墨西哥比索"].apply(
822
+ lambda x: x[0]
823
+ )
824
+ big_df["人民币/墨西哥比索_涨跌幅"] = temp_df["人民币/墨西哥比索"].apply(
825
+ lambda x: x[1]
826
+ )
1324
827
  big_df["人民币/泰铢_定价"] = temp_df["人民币/泰铢"].apply(lambda x: x[0])
1325
828
  big_df["人民币/泰铢_涨跌幅"] = temp_df["人民币/泰铢"].apply(lambda x: x[1])
1326
829
  big_df = big_df.apply(lambda x: x.replace("-", pd.NA))
@@ -1339,42 +842,28 @@ def macro_china_market_margin_sz() -> pd.DataFrame:
1339
842
  深圳融资融券报告, 数据区间从20100331-至今
1340
843
  https://datacenter.jin10.com/reportType/dc_market_margin_sz
1341
844
  :return: pandas.DataFrame
1342
- 融资买入额(元) 融资余额(元) 融券卖出量(股) 融券余量(股) 融券余额(元) \
1343
- 2010-03-31 684569 670796 4000 3900 70895
1344
- 2010-04-08 6713260 14467758 2100 3100 56023
1345
- 2010-04-09 9357095 19732998 6700 5400 108362
1346
- 2010-04-12 10406563 24813027 2200 1000 8100
1347
- 2010-04-15 16607172 47980287 4200 5200 97676
1348
- ... ... ... ... ...
1349
- 2019-12-12 25190412075 423457288662 29769255 209557883 2504593151
1350
- 2019-12-13 29636811209 423422868505 32820867 206092170 2509424768
1351
- 2019-12-16 39166060634 428851154451 44000215 217123568 2647520178
1352
- 2019-12-17 46930557203 433966722200 40492711 220945538 2750371397
1353
- 2019-12-18 41043515833 438511398249 39150376 224554586 2761303194
1354
- 融资融券余额(元)
1355
- 2010-03-31 741691
1356
- 2010-04-08 14523781
1357
- 2010-04-09 19841360
1358
- 2010-04-12 24821127
1359
- 2010-04-15 48077963
1360
- ...
1361
- 2019-12-12 425961881813
1362
- 2019-12-13 425932293273
1363
- 2019-12-16 431498674629
1364
- 2019-12-17 436717093597
1365
- 2019-12-18 441272701443
1366
845
  """
1367
846
  t = time.time()
1368
847
  params = {"_": t}
1369
848
  res = requests.get(
1370
- "https://cdn.jin10.com/data_center/reports/fs_2.json", params=params
849
+ url="https://cdn.jin10.com/data_center/reports/fs_2.json", params=params
1371
850
  )
1372
851
  json_data = res.json()
1373
852
  temp_df = pd.DataFrame(json_data["values"]).T
1374
- temp_df.columns = ["融资买入额", "融资余额", "融券卖出量", "融券余量", "融券余额", "融资融券余额"]
853
+ temp_df.columns = [
854
+ "融资买入额",
855
+ "融资余额",
856
+ "融券卖出量",
857
+ "融券余量",
858
+ "融券余额",
859
+ "融资融券余额",
860
+ ]
1375
861
  temp_df.sort_index(inplace=True)
1376
862
  temp_df.index = pd.to_datetime(temp_df.index)
1377
863
  temp_df = temp_df.astype("float")
864
+ temp_df.reset_index(inplace=True)
865
+ temp_df.rename(columns={"index": "日期"}, inplace=True)
866
+ temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
1378
867
  return temp_df
1379
868
 
1380
869
 
@@ -1392,15 +881,23 @@ def macro_china_market_margin_sh() -> pd.DataFrame:
1392
881
  json_data = r.json()
1393
882
  temp_df = pd.DataFrame(json_data["values"]).T
1394
883
  temp_df.reset_index(inplace=True)
1395
- temp_df.columns = ["日期", "融资买入额", "融资余额", "融券卖出量", "融券余量", "融券余额", "融资融券余额"]
884
+ temp_df.columns = [
885
+ "日期",
886
+ "融资买入额",
887
+ "融资余额",
888
+ "融券卖出量",
889
+ "融券余量",
890
+ "融券余额",
891
+ "融资融券余额",
892
+ ]
1396
893
  temp_df.sort_values(by=["日期"], inplace=True, ignore_index=True)
1397
- temp_df['日期'] = pd.to_datetime(temp_df['日期'], errors="coerce").dt.date
1398
- temp_df['融资买入额'] = pd.to_numeric(temp_df['融资买入额'], errors="coerce")
1399
- temp_df['融资余额'] = pd.to_numeric(temp_df['融资余额'], errors="coerce")
1400
- temp_df['融券卖出量'] = pd.to_numeric(temp_df['融券卖出量'], errors="coerce")
1401
- temp_df['融券余量'] = pd.to_numeric(temp_df['融券余量'], errors="coerce")
1402
- temp_df['融券余额'] = pd.to_numeric(temp_df['融券余额'], errors="coerce")
1403
- temp_df['融资融券余额'] = pd.to_numeric(temp_df['融资融券余额'], errors="coerce")
894
+ temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
895
+ temp_df["融资买入额"] = pd.to_numeric(temp_df["融资买入额"], errors="coerce")
896
+ temp_df["融资余额"] = pd.to_numeric(temp_df["融资余额"], errors="coerce")
897
+ temp_df["融券卖出量"] = pd.to_numeric(temp_df["融券卖出量"], errors="coerce")
898
+ temp_df["融券余量"] = pd.to_numeric(temp_df["融券余量"], errors="coerce")
899
+ temp_df["融券余额"] = pd.to_numeric(temp_df["融券余额"], errors="coerce")
900
+ temp_df["融资融券余额"] = pd.to_numeric(temp_df["融资融券余额"], errors="coerce")
1404
901
  return temp_df
1405
902
 
1406
903
 
@@ -1414,7 +911,7 @@ def macro_china_au_report() -> pd.DataFrame:
1414
911
  t = time.time()
1415
912
  params = {"_": t}
1416
913
  res = requests.get(
1417
- "https://cdn.jin10.com/data_center/reports/sge.json", params=params
914
+ url="https://cdn.jin10.com/data_center/reports/sge.json", params=params
1418
915
  )
1419
916
  json_data = res.json()
1420
917
  big_df = pd.DataFrame()
@@ -1471,6 +968,10 @@ def macro_china_lpr() -> pd.DataFrame:
1471
968
  :return: LPR品种详细数据
1472
969
  :rtype: pandas.DataFrame
1473
970
  """
971
+ import warnings
972
+
973
+ warnings.filterwarnings(action="ignore", category=FutureWarning)
974
+
1474
975
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
1475
976
  params = {
1476
977
  "reportName": "RPTA_WEB_RATE",
@@ -1489,26 +990,27 @@ def macro_china_lpr() -> pd.DataFrame:
1489
990
  data_json = r.json()
1490
991
  total_page = data_json["result"]["pages"]
1491
992
  big_df = pd.DataFrame()
993
+ tqdm = get_tqdm()
1492
994
  for page in tqdm(range(1, total_page + 1), leave=False):
1493
995
  params.update({"pageNumber": page})
1494
996
  r = requests.get(url, params=params)
1495
997
  data_json = r.json()
1496
998
  temp_df = pd.DataFrame(data_json["result"]["data"])
1497
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
999
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
1498
1000
 
1499
1001
  big_df["TRADE_DATE"] = pd.to_datetime(big_df["TRADE_DATE"], errors="coerce").dt.date
1500
1002
  big_df["LPR1Y"] = pd.to_numeric(big_df["LPR1Y"], errors="coerce")
1501
1003
  big_df["LPR5Y"] = pd.to_numeric(big_df["LPR5Y"], errors="coerce")
1502
1004
  big_df["RATE_1"] = pd.to_numeric(big_df["RATE_1"], errors="coerce")
1503
1005
  big_df["RATE_2"] = pd.to_numeric(big_df["RATE_2"], errors="coerce")
1504
- big_df.sort_values(["TRADE_DATE"], inplace=True)
1006
+ big_df.sort_values(by=["TRADE_DATE"], inplace=True)
1505
1007
  big_df.reset_index(inplace=True, drop=True)
1506
1008
  return big_df
1507
1009
 
1508
1010
 
1509
1011
  # 中国-新房价指数
1510
1012
  def macro_china_new_house_price(
1511
- city_first: str = "北京", city_second: str = "上海"
1013
+ city_first: str = "北京", city_second: str = "上海"
1512
1014
  ) -> pd.DataFrame:
1513
1015
  """
1514
1016
  中国-新房价指数
@@ -1523,7 +1025,8 @@ def macro_china_new_house_price(
1523
1025
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
1524
1026
  params = {
1525
1027
  "reportName": "RPT_ECONOMY_HOUSE_PRICE",
1526
- "columns": "REPORT_DATE,CITY,FIRST_COMHOUSE_SAME,FIRST_COMHOUSE_SEQUENTIAL,FIRST_COMHOUSE_BASE,SECOND_HOUSE_SAME,SECOND_HOUSE_SEQUENTIAL,SECOND_HOUSE_BASE,REPORT_DAY",
1028
+ "columns": "REPORT_DATE,CITY,FIRST_COMHOUSE_SAME,FIRST_COMHOUSE_SEQUENTIAL,FIRST_COMHOUSE_BASE,"
1029
+ "SECOND_HOUSE_SAME,SECOND_HOUSE_SEQUENTIAL,SECOND_HOUSE_BASE,REPORT_DAY",
1527
1030
  "filter": f'(CITY in ("{city_first}","{city_second}"))',
1528
1031
  "pageNumber": "1",
1529
1032
  "pageSize": "500",
@@ -1545,8 +1048,8 @@ def macro_china_new_house_price(
1545
1048
  "新建商品住宅价格指数-同比",
1546
1049
  "新建商品住宅价格指数-环比",
1547
1050
  "新建商品住宅价格指数-定基",
1548
- "二手住宅价格指数-环比",
1549
1051
  "二手住宅价格指数-同比",
1052
+ "二手住宅价格指数-环比",
1550
1053
  "二手住宅价格指数-定基",
1551
1054
  "-",
1552
1055
  ]
@@ -1557,18 +1060,31 @@ def macro_china_new_house_price(
1557
1060
  "新建商品住宅价格指数-同比",
1558
1061
  "新建商品住宅价格指数-环比",
1559
1062
  "新建商品住宅价格指数-定基",
1560
- "二手住宅价格指数-环比",
1561
1063
  "二手住宅价格指数-同比",
1064
+ "二手住宅价格指数-环比",
1562
1065
  "二手住宅价格指数-定基",
1563
1066
  ]
1564
1067
  ]
1565
- temp_df["日期"] = pd.to_datetime(temp_df["日期"]).dt.date
1566
- temp_df["新建商品住宅价格指数-同比"] = pd.to_numeric(temp_df["新建商品住宅价格指数-同比"], errors="coerce")
1567
- temp_df["新建商品住宅价格指数-环比"] = pd.to_numeric(temp_df["新建商品住宅价格指数-环比"], errors="coerce")
1568
- temp_df["新建商品住宅价格指数-定基"] = pd.to_numeric(temp_df["新建商品住宅价格指数-定基"], errors="coerce")
1569
- temp_df["二手住宅价格指数-环比"] = pd.to_numeric(temp_df["二手住宅价格指数-环比"], errors="coerce")
1570
- temp_df["二手住宅价格指数-同比"] = pd.to_numeric(temp_df["二手住宅价格指数-同比"], errors="coerce")
1571
- temp_df["二手住宅价格指数-定基"] = pd.to_numeric(temp_df["二手住宅价格指数-定基"], errors="coerce")
1068
+ temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
1069
+ temp_df["新建商品住宅价格指数-同比"] = pd.to_numeric(
1070
+ temp_df["新建商品住宅价格指数-同比"], errors="coerce"
1071
+ )
1072
+ temp_df["新建商品住宅价格指数-环比"] = pd.to_numeric(
1073
+ temp_df["新建商品住宅价格指数-环比"], errors="coerce"
1074
+ )
1075
+ temp_df["新建商品住宅价格指数-定基"] = pd.to_numeric(
1076
+ temp_df["新建商品住宅价格指数-定基"], errors="coerce"
1077
+ )
1078
+ temp_df["二手住宅价格指数-环比"] = pd.to_numeric(
1079
+ temp_df["二手住宅价格指数-环比"], errors="coerce"
1080
+ )
1081
+ temp_df["二手住宅价格指数-同比"] = pd.to_numeric(
1082
+ temp_df["二手住宅价格指数-同比"], errors="coerce"
1083
+ )
1084
+ temp_df["二手住宅价格指数-定基"] = pd.to_numeric(
1085
+ temp_df["二手住宅价格指数-定基"], errors="coerce"
1086
+ )
1087
+ temp_df.sort_values(["日期"], ignore_index=True, inplace=True)
1572
1088
  return temp_df
1573
1089
 
1574
1090
 
@@ -1582,7 +1098,8 @@ def macro_china_enterprise_boom_index() -> pd.DataFrame:
1582
1098
  """
1583
1099
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
1584
1100
  params = {
1585
- "columns": "REPORT_DATE,TIME,BOOM_INDEX,FAITH_INDEX,BOOM_INDEX_SAME,BOOM_INDEX_SEQUENTIAL,FAITH_INDEX_SAME,FAITH_INDEX_SEQUENTIAL",
1101
+ "columns": "REPORT_DATE,TIME,BOOM_INDEX,FAITH_INDEX,BOOM_INDEX_SAME,BOOM_INDEX_SEQUENTIAL,"
1102
+ "FAITH_INDEX_SAME,FAITH_INDEX_SEQUENTIAL",
1586
1103
  "pageNumber": "1",
1587
1104
  "pageSize": "500",
1588
1105
  "sortColumns": "REPORT_DATE",
@@ -1619,12 +1136,24 @@ def macro_china_enterprise_boom_index() -> pd.DataFrame:
1619
1136
  "企业家信心指数-环比",
1620
1137
  ]
1621
1138
  ]
1622
- temp_df["企业景气指数-指数"] = pd.to_numeric(temp_df["企业景气指数-指数"], errors="coerce")
1623
- temp_df["企业家信心指数-指数"] = pd.to_numeric(temp_df["企业家信心指数-指数"], errors="coerce")
1624
- temp_df["企业景气指数-同比"] = pd.to_numeric(temp_df["企业景气指数-同比"], errors="coerce")
1625
- temp_df["企业景气指数-环比"] = pd.to_numeric(temp_df["企业景气指数-环比"], errors="coerce")
1626
- temp_df["企业家信心指数-同比"] = pd.to_numeric(temp_df["企业家信心指数-同比"], errors="coerce")
1627
- temp_df["企业家信心指数-环比"] = pd.to_numeric(temp_df["企业家信心指数-环比"], errors="coerce")
1139
+ temp_df["企业景气指数-指数"] = pd.to_numeric(
1140
+ temp_df["企业景气指数-指数"], errors="coerce"
1141
+ )
1142
+ temp_df["企业家信心指数-指数"] = pd.to_numeric(
1143
+ temp_df["企业家信心指数-指数"], errors="coerce"
1144
+ )
1145
+ temp_df["企业景气指数-同比"] = pd.to_numeric(
1146
+ temp_df["企业景气指数-同比"], errors="coerce"
1147
+ )
1148
+ temp_df["企业景气指数-环比"] = pd.to_numeric(
1149
+ temp_df["企业景气指数-环比"], errors="coerce"
1150
+ )
1151
+ temp_df["企业家信心指数-同比"] = pd.to_numeric(
1152
+ temp_df["企业家信心指数-同比"], errors="coerce"
1153
+ )
1154
+ temp_df["企业家信心指数-环比"] = pd.to_numeric(
1155
+ temp_df["企业家信心指数-环比"], errors="coerce"
1156
+ )
1628
1157
  return temp_df
1629
1158
 
1630
1159
 
@@ -1679,7 +1208,8 @@ def macro_china_bank_financing() -> pd.DataFrame:
1679
1208
  "pageSize": "1000",
1680
1209
  "pageNumber": "1",
1681
1210
  "reportName": "RPT_INDUSTRY_INDEX",
1682
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1211
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1212
+ "CHANGERATE_2Y,CHANGERATE_3Y",
1683
1213
  "filter": '(INDICATOR_ID="EMI01516267")',
1684
1214
  "source": "WEB",
1685
1215
  "client": "WEB",
@@ -1724,7 +1254,8 @@ def macro_china_insurance_income() -> pd.DataFrame:
1724
1254
  "pageSize": "1000",
1725
1255
  "pageNumber": "1",
1726
1256
  "reportName": "RPT_INDUSTRY_INDEX",
1727
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1257
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1258
+ "CHANGERATE_2Y,CHANGERATE_3Y",
1728
1259
  "filter": '(INDICATOR_ID="EMM00088870")',
1729
1260
  "source": "WEB",
1730
1261
  "client": "WEB",
@@ -1769,7 +1300,8 @@ def macro_china_mobile_number() -> pd.DataFrame:
1769
1300
  "pageSize": "1000",
1770
1301
  "pageNumber": "1",
1771
1302
  "reportName": "RPT_INDUSTRY_INDEX",
1772
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1303
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1304
+ "CHANGERATE_2Y,CHANGERATE_3Y",
1773
1305
  "filter": '(INDICATOR_ID="EMI00225823")',
1774
1306
  "source": "WEB",
1775
1307
  "client": "WEB",
@@ -1815,7 +1347,8 @@ def macro_china_vegetable_basket() -> pd.DataFrame:
1815
1347
  "pageSize": "500",
1816
1348
  "pageNumber": "1",
1817
1349
  "reportName": "RPT_INDUSTRY_INDEX",
1818
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1350
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1351
+ "CHANGERATE_2Y,CHANGERATE_3Y",
1819
1352
  "filter": '(INDICATOR_ID="EMI00009275")',
1820
1353
  "source": "WEB",
1821
1354
  "client": "WEB",
@@ -1824,6 +1357,7 @@ def macro_china_vegetable_basket() -> pd.DataFrame:
1824
1357
  data_json = r.json()
1825
1358
  total_page = data_json["result"]["pages"]
1826
1359
  big_df = pd.DataFrame()
1360
+ tqdm = get_tqdm()
1827
1361
  for page in tqdm(range(1, total_page + 1), leave=False):
1828
1362
  params.update({"pageNumber": page})
1829
1363
  r = requests.get(url, params=params)
@@ -1868,7 +1402,8 @@ def macro_china_agricultural_product() -> pd.DataFrame:
1868
1402
  "pageSize": "500",
1869
1403
  "pageNumber": "1",
1870
1404
  "reportName": "RPT_INDUSTRY_INDEX",
1871
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1405
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1406
+ "CHANGERATE_2Y,CHANGERATE_3Y",
1872
1407
  "filter": '(INDICATOR_ID="EMI00009274")',
1873
1408
  "source": "WEB",
1874
1409
  "client": "WEB",
@@ -1877,6 +1412,7 @@ def macro_china_agricultural_product() -> pd.DataFrame:
1877
1412
  data_json = r.json()
1878
1413
  total_page = data_json["result"]["pages"]
1879
1414
  big_df = pd.DataFrame()
1415
+ tqdm = get_tqdm()
1880
1416
  for page in tqdm(range(1, total_page + 1), leave=False):
1881
1417
  params.update({"pageNumber": page})
1882
1418
  r = requests.get(url, params=params)
@@ -1921,7 +1457,8 @@ def macro_china_agricultural_index() -> pd.DataFrame:
1921
1457
  "pageSize": "500",
1922
1458
  "pageNumber": "1",
1923
1459
  "reportName": "RPT_INDUSTRY_INDEX",
1924
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1460
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1461
+ "CHANGERATE_2Y,CHANGERATE_3Y",
1925
1462
  "filter": '(INDICATOR_ID="EMI00662543")',
1926
1463
  "source": "WEB",
1927
1464
  "client": "WEB",
@@ -1930,6 +1467,7 @@ def macro_china_agricultural_index() -> pd.DataFrame:
1930
1467
  data_json = r.json()
1931
1468
  total_page = data_json["result"]["pages"]
1932
1469
  big_df = pd.DataFrame()
1470
+ tqdm = get_tqdm()
1933
1471
  for page in tqdm(range(1, total_page + 1), leave=False):
1934
1472
  params.update({"pageNumber": page})
1935
1473
  r = requests.get(url, params=params)
@@ -1974,7 +1512,8 @@ def macro_china_energy_index() -> pd.DataFrame:
1974
1512
  "pageSize": "500",
1975
1513
  "pageNumber": "1",
1976
1514
  "reportName": "RPT_INDUSTRY_INDEX",
1977
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1515
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1516
+ "CHANGERATE_2Y,CHANGERATE_3Y",
1978
1517
  "filter": '(INDICATOR_ID="EMI00662539")',
1979
1518
  "source": "WEB",
1980
1519
  "client": "WEB",
@@ -1983,6 +1522,7 @@ def macro_china_energy_index() -> pd.DataFrame:
1983
1522
  data_json = r.json()
1984
1523
  total_page = data_json["result"]["pages"]
1985
1524
  big_df = pd.DataFrame()
1525
+ tqdm = get_tqdm()
1986
1526
  for page in tqdm(range(1, total_page + 1), leave=False):
1987
1527
  params.update({"pageNumber": page})
1988
1528
  r = requests.get(url, params=params)
@@ -2027,7 +1567,8 @@ def macro_china_commodity_price_index() -> pd.DataFrame:
2027
1567
  "pageSize": "500",
2028
1568
  "pageNumber": "1",
2029
1569
  "reportName": "RPT_INDUSTRY_INDEX",
2030
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1570
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1571
+ "CHANGERATE_2Y,CHANGERATE_3Y",
2031
1572
  "filter": '(INDICATOR_ID="EMI00662535")',
2032
1573
  "source": "WEB",
2033
1574
  "client": "WEB",
@@ -2036,6 +1577,7 @@ def macro_china_commodity_price_index() -> pd.DataFrame:
2036
1577
  data_json = r.json()
2037
1578
  total_page = data_json["result"]["pages"]
2038
1579
  big_df = pd.DataFrame()
1580
+ tqdm = get_tqdm()
2039
1581
  for page in tqdm(range(1, total_page + 1), leave=False):
2040
1582
  params.update({"pageNumber": page})
2041
1583
  r = requests.get(url, params=params)
@@ -2080,7 +1622,8 @@ def macro_global_sox_index() -> pd.DataFrame:
2080
1622
  "pageSize": "500",
2081
1623
  "pageNumber": "1",
2082
1624
  "reportName": "RPT_INDUSTRY_INDEX",
2083
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1625
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1626
+ "CHANGERATE_2Y,CHANGERATE_3Y",
2084
1627
  "filter": '(INDICATOR_ID="EMI00055562")',
2085
1628
  "source": "WEB",
2086
1629
  "client": "WEB",
@@ -2089,6 +1632,7 @@ def macro_global_sox_index() -> pd.DataFrame:
2089
1632
  data_json = r.json()
2090
1633
  total_page = data_json["result"]["pages"]
2091
1634
  big_df = pd.DataFrame()
1635
+ tqdm = get_tqdm()
2092
1636
  for page in tqdm(range(1, total_page + 1), leave=False):
2093
1637
  params.update({"pageNumber": page})
2094
1638
  r = requests.get(url, params=params)
@@ -2133,7 +1677,8 @@ def macro_china_yw_electronic_index() -> pd.DataFrame:
2133
1677
  "pageSize": "500",
2134
1678
  "pageNumber": "1",
2135
1679
  "reportName": "RPT_INDUSTRY_INDEX",
2136
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1680
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1681
+ "CHANGERATE_2Y,CHANGERATE_3Y",
2137
1682
  "filter": '(INDICATOR_ID="EMI00055551")',
2138
1683
  "source": "WEB",
2139
1684
  "client": "WEB",
@@ -2142,6 +1687,7 @@ def macro_china_yw_electronic_index() -> pd.DataFrame:
2142
1687
  data_json = r.json()
2143
1688
  total_page = data_json["result"]["pages"]
2144
1689
  big_df = pd.DataFrame()
1690
+ tqdm = get_tqdm()
2145
1691
  for page in tqdm(range(1, total_page + 1), leave=False):
2146
1692
  params.update({"pageNumber": page})
2147
1693
  r = requests.get(url, params=params)
@@ -2179,6 +1725,9 @@ def macro_china_construction_index() -> pd.DataFrame:
2179
1725
  :return: 建材指数
2180
1726
  :rtype: pandas.DataFrame
2181
1727
  """
1728
+ import warnings
1729
+
1730
+ warnings.filterwarnings(action="ignore", category=FutureWarning)
2182
1731
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
2183
1732
  params = {
2184
1733
  "sortColumns": "REPORT_DATE",
@@ -2186,7 +1735,8 @@ def macro_china_construction_index() -> pd.DataFrame:
2186
1735
  "pageSize": "500",
2187
1736
  "pageNumber": "1",
2188
1737
  "reportName": "RPT_INDUSTRY_INDEX",
2189
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1738
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,"
1739
+ "CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
2190
1740
  "filter": '(INDICATOR_ID="EMI00662541")',
2191
1741
  "source": "WEB",
2192
1742
  "client": "WEB",
@@ -2195,12 +1745,13 @@ def macro_china_construction_index() -> pd.DataFrame:
2195
1745
  data_json = r.json()
2196
1746
  total_page = data_json["result"]["pages"]
2197
1747
  big_df = pd.DataFrame()
1748
+ tqdm = get_tqdm()
2198
1749
  for page in tqdm(range(1, total_page + 1), leave=False):
2199
1750
  params.update({"pageNumber": page})
2200
1751
  r = requests.get(url, params=params)
2201
1752
  data_json = r.json()
2202
1753
  temp_df = pd.DataFrame(data_json["result"]["data"])
2203
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
1754
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
2204
1755
  big_df.drop_duplicates(inplace=True)
2205
1756
  big_df.columns = [
2206
1757
  "日期",
@@ -2212,15 +1763,15 @@ def macro_china_construction_index() -> pd.DataFrame:
2212
1763
  "近2年涨跌幅",
2213
1764
  "近3年涨跌幅",
2214
1765
  ]
2215
- big_df["日期"] = pd.to_datetime(big_df["日期"]).dt.date
2216
- big_df["最新值"] = pd.to_numeric(big_df["最新值"])
2217
- big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"])
2218
- big_df["近3月涨跌幅"] = pd.to_numeric(big_df["近3月涨跌幅"])
2219
- big_df["近6月涨跌幅"] = pd.to_numeric(big_df["近6月涨跌幅"])
2220
- big_df["近1年涨跌幅"] = pd.to_numeric(big_df["近1年涨跌幅"])
2221
- big_df["近2年涨跌幅"] = pd.to_numeric(big_df["近2年涨跌幅"])
2222
- big_df["近3年涨跌幅"] = pd.to_numeric(big_df["近3年涨跌幅"])
2223
- big_df.sort_values(["日期"], inplace=True)
1766
+ big_df["日期"] = pd.to_datetime(big_df["日期"], errors="coerce").dt.date
1767
+ big_df["最新值"] = pd.to_numeric(big_df["最新值"], errors="coerce")
1768
+ big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"], errors="coerce")
1769
+ big_df["近3月涨跌幅"] = pd.to_numeric(big_df["近3月涨跌幅"], errors="coerce")
1770
+ big_df["近6月涨跌幅"] = pd.to_numeric(big_df["近6月涨跌幅"], errors="coerce")
1771
+ big_df["近1年涨跌幅"] = pd.to_numeric(big_df["近1年涨跌幅"], errors="coerce")
1772
+ big_df["近2年涨跌幅"] = pd.to_numeric(big_df["近2年涨跌幅"], errors="coerce")
1773
+ big_df["近3年涨跌幅"] = pd.to_numeric(big_df["近3年涨跌幅"], errors="coerce")
1774
+ big_df.sort_values(by=["日期"], inplace=True)
2224
1775
  big_df.reset_index(inplace=True, drop=True)
2225
1776
  return big_df
2226
1777
 
@@ -2239,7 +1790,8 @@ def macro_china_construction_price_index() -> pd.DataFrame:
2239
1790
  "pageSize": "500",
2240
1791
  "pageNumber": "1",
2241
1792
  "reportName": "RPT_INDUSTRY_INDEX",
2242
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1793
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1794
+ "CHANGERATE_2Y,CHANGERATE_3Y",
2243
1795
  "filter": '(INDICATOR_ID="EMI00237146")',
2244
1796
  "source": "WEB",
2245
1797
  "client": "WEB",
@@ -2248,6 +1800,7 @@ def macro_china_construction_price_index() -> pd.DataFrame:
2248
1800
  data_json = r.json()
2249
1801
  total_page = data_json["result"]["pages"]
2250
1802
  big_df = pd.DataFrame()
1803
+ tqdm = get_tqdm()
2251
1804
  for page in tqdm(range(1, total_page + 1), leave=False):
2252
1805
  params.update({"pageNumber": page})
2253
1806
  r = requests.get(url, params=params)
@@ -2292,7 +1845,8 @@ def macro_china_lpi_index() -> pd.DataFrame:
2292
1845
  "pageSize": "500",
2293
1846
  "pageNumber": "1",
2294
1847
  "reportName": "RPT_INDUSTRY_INDEX",
2295
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1848
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1849
+ "CHANGERATE_2Y,CHANGERATE_3Y",
2296
1850
  "filter": '(INDICATOR_ID="EMI00352262")',
2297
1851
  "source": "WEB",
2298
1852
  "client": "WEB",
@@ -2301,6 +1855,7 @@ def macro_china_lpi_index() -> pd.DataFrame:
2301
1855
  data_json = r.json()
2302
1856
  total_page = data_json["result"]["pages"]
2303
1857
  big_df = pd.DataFrame()
1858
+ tqdm = get_tqdm()
2304
1859
  for page in tqdm(range(1, total_page + 1), leave=False):
2305
1860
  params.update({"pageNumber": page})
2306
1861
  r = requests.get(url, params=params)
@@ -2345,7 +1900,8 @@ def macro_china_bdti_index() -> pd.DataFrame:
2345
1900
  "pageSize": "500",
2346
1901
  "pageNumber": "1",
2347
1902
  "reportName": "RPT_INDUSTRY_INDEX",
2348
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1903
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1904
+ "CHANGERATE_2Y,CHANGERATE_3Y",
2349
1905
  "filter": '(INDICATOR_ID="EMI00107668")',
2350
1906
  "source": "WEB",
2351
1907
  "client": "WEB",
@@ -2354,6 +1910,7 @@ def macro_china_bdti_index() -> pd.DataFrame:
2354
1910
  data_json = r.json()
2355
1911
  total_page = data_json["result"]["pages"]
2356
1912
  big_df = pd.DataFrame()
1913
+ tqdm = get_tqdm()
2357
1914
  for page in tqdm(range(1, total_page + 1), leave=False):
2358
1915
  params.update({"pageNumber": page})
2359
1916
  r = requests.get(url, params=params)
@@ -2398,7 +1955,8 @@ def macro_china_bsi_index() -> pd.DataFrame:
2398
1955
  "pageSize": "500",
2399
1956
  "pageNumber": "1",
2400
1957
  "reportName": "RPT_INDUSTRY_INDEX",
2401
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
1958
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
1959
+ "CHANGERATE_2Y,CHANGERATE_3Y",
2402
1960
  "filter": '(INDICATOR_ID="EMI00107667")',
2403
1961
  "source": "WEB",
2404
1962
  "client": "WEB",
@@ -2407,6 +1965,7 @@ def macro_china_bsi_index() -> pd.DataFrame:
2407
1965
  data_json = r.json()
2408
1966
  total_page = data_json["result"]["pages"]
2409
1967
  big_df = pd.DataFrame()
1968
+ tqdm = get_tqdm()
2410
1969
  for page in tqdm(range(1, total_page + 1), leave=False):
2411
1970
  params.update({"pageNumber": page})
2412
1971
  r = requests.get(url, params=params)
@@ -2440,6 +1999,8 @@ def macro_china_bsi_index() -> pd.DataFrame:
2440
1999
  def _em_macro_1(em_id) -> pd.DataFrame:
2441
2000
  """
2442
2001
  东财宏观数据的一种通用函数
2002
+ :return: 处理后的数据
2003
+ :rtype: pandas.DataFrame
2443
2004
  """
2444
2005
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
2445
2006
  ind_id = '"' + em_id + '"'
@@ -2449,7 +2010,8 @@ def _em_macro_1(em_id) -> pd.DataFrame:
2449
2010
  "pageSize": "500",
2450
2011
  "pageNumber": "1",
2451
2012
  "reportName": "RPT_INDUSTRY_INDEX",
2452
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
2013
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,"
2014
+ "CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
2453
2015
  "filter": "(INDICATOR_ID=" + ind_id + ")",
2454
2016
  "source": "WEB",
2455
2017
  "client": "WEB",
@@ -2458,6 +2020,7 @@ def _em_macro_1(em_id) -> pd.DataFrame:
2458
2020
  data_json = r.json()
2459
2021
  total_page = data_json["result"]["pages"]
2460
2022
  big_df = pd.DataFrame()
2023
+ tqdm = get_tqdm()
2461
2024
  for page in tqdm(range(1, total_page + 1), leave=False):
2462
2025
  params.update({"pageNumber": page})
2463
2026
  r = requests.get(url, params=params)
@@ -2475,15 +2038,15 @@ def _em_macro_1(em_id) -> pd.DataFrame:
2475
2038
  "近2年涨跌幅",
2476
2039
  "近3年涨跌幅",
2477
2040
  ]
2478
- big_df["日期"] = pd.to_datetime(big_df["日期"]).dt.date
2479
- big_df["最新值"] = pd.to_numeric(big_df["最新值"])
2480
- big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"])
2481
- big_df["近3月涨跌幅"] = pd.to_numeric(big_df["近3月涨跌幅"])
2482
- big_df["近6月涨跌幅"] = pd.to_numeric(big_df["近6月涨跌幅"])
2483
- big_df["近1年涨跌幅"] = pd.to_numeric(big_df["近1年涨跌幅"])
2484
- big_df["近2年涨跌幅"] = pd.to_numeric(big_df["近2年涨跌幅"])
2485
- big_df["近3年涨跌幅"] = pd.to_numeric(big_df["近3年涨跌幅"])
2486
- big_df.sort_values(["日期"], inplace=True)
2041
+ big_df["日期"] = pd.to_datetime(big_df["日期"], errors="coerce").dt.date
2042
+ big_df["最新值"] = pd.to_numeric(big_df["最新值"], errors="coerce")
2043
+ big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"], errors="coerce")
2044
+ big_df["近3月涨跌幅"] = pd.to_numeric(big_df["近3月涨跌幅"], errors="coerce")
2045
+ big_df["近6月涨跌幅"] = pd.to_numeric(big_df["近6月涨跌幅"], errors="coerce")
2046
+ big_df["近1年涨跌幅"] = pd.to_numeric(big_df["近1年涨跌幅"], errors="coerce")
2047
+ big_df["近2年涨跌幅"] = pd.to_numeric(big_df["近2年涨跌幅"], errors="coerce")
2048
+ big_df["近3年涨跌幅"] = pd.to_numeric(big_df["近3年涨跌幅"], errors="coerce")
2049
+ big_df.sort_values(by=["日期"], inplace=True)
2487
2050
  big_df.reset_index(inplace=True, drop=True)
2488
2051
  return big_df
2489
2052
 
@@ -2541,7 +2104,8 @@ def macro_china_new_financial_credit() -> pd.DataFrame:
2541
2104
  """
2542
2105
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
2543
2106
  params = {
2544
- "columns": "REPORT_DATE,TIME,RMB_LOAN,RMB_LOAN_SAME,RMB_LOAN_SEQUENTIAL,RMB_LOAN_ACCUMULATE,LOAN_ACCUMULATE_SAME",
2107
+ "columns": "REPORT_DATE,TIME,RMB_LOAN,RMB_LOAN_SAME,RMB_LOAN_SEQUENTIAL,"
2108
+ "RMB_LOAN_ACCUMULATE,LOAN_ACCUMULATE_SAME",
2545
2109
  "pageNumber": "1",
2546
2110
  "pageSize": "2000",
2547
2111
  "sortColumns": "REPORT_DATE",
@@ -2558,8 +2122,18 @@ def macro_china_new_financial_credit() -> pd.DataFrame:
2558
2122
  data_json = r.json()
2559
2123
  temp_df = pd.DataFrame(data_json["result"]["data"])
2560
2124
 
2561
- temp_df.columns = ["-", "月份", "当月", "当月-同比增长", "当月-环比增长", "累计", "累计-同比增长"]
2562
- temp_df = temp_df[["月份", "当月", "当月-同比增长", "当月-环比增长", "累计", "累计-同比增长"]]
2125
+ temp_df.columns = [
2126
+ "-",
2127
+ "月份",
2128
+ "当月",
2129
+ "当月-同比增长",
2130
+ "当月-环比增长",
2131
+ "累计",
2132
+ "累计-同比增长",
2133
+ ]
2134
+ temp_df = temp_df[
2135
+ ["月份", "当月", "当月-同比增长", "当月-环比增长", "累计", "累计-同比增长"]
2136
+ ]
2563
2137
 
2564
2138
  temp_df["当月"] = pd.to_numeric(temp_df["当月"], errors="coerce")
2565
2139
  temp_df["当月-同比增长"] = pd.to_numeric(temp_df["当月-同比增长"], errors="coerce")
@@ -2579,10 +2153,12 @@ def macro_china_fx_gold() -> pd.DataFrame:
2579
2153
  """
2580
2154
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
2581
2155
  headers = {
2582
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
2156
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
2157
+ "Chrome/81.0.4044.138 Safari/537.36",
2583
2158
  }
2584
2159
  params = {
2585
- "columns": "REPORT_DATE,TIME,GOLD_RESERVES,GOLD_RESERVES_SAME,GOLD_RESERVES_SEQUENTIAL,FOREX,FOREX_SAME,FOREX_SEQUENTIAL",
2160
+ "columns": "REPORT_DATE,TIME,GOLD_RESERVES,GOLD_RESERVES_SAME,"
2161
+ "GOLD_RESERVES_SEQUENTIAL,FOREX,FOREX_SAME,FOREX_SEQUENTIAL",
2586
2162
  "pageNumber": "1",
2587
2163
  "pageSize": "1000",
2588
2164
  "sortColumns": "REPORT_DATE",
@@ -2619,13 +2195,19 @@ def macro_china_fx_gold() -> pd.DataFrame:
2619
2195
  "国家外汇储备-环比",
2620
2196
  ]
2621
2197
  ]
2622
- temp_df["国家外汇储备-数值"] = pd.to_numeric(temp_df["国家外汇储备-数值"])
2623
- temp_df["国家外汇储备-同比"] = pd.to_numeric(temp_df["国家外汇储备-同比"])
2624
- temp_df["国家外汇储备-环比"] = pd.to_numeric(temp_df["国家外汇储备-环比"])
2625
- temp_df["黄金储备-数值"] = pd.to_numeric(temp_df["黄金储备-数值"])
2626
- temp_df["黄金储备-同比"] = pd.to_numeric(temp_df["黄金储备-同比"])
2627
- temp_df["黄金储备-环比"] = pd.to_numeric(temp_df["黄金储备-环比"])
2628
- temp_df.sort_values(["月份"], inplace=True, ignore_index=True)
2198
+ temp_df["国家外汇储备-数值"] = pd.to_numeric(
2199
+ temp_df["国家外汇储备-数值"], errors="coerce"
2200
+ )
2201
+ temp_df["国家外汇储备-同比"] = pd.to_numeric(
2202
+ temp_df["国家外汇储备-同比"], errors="coerce"
2203
+ )
2204
+ temp_df["国家外汇储备-环比"] = pd.to_numeric(
2205
+ temp_df["国家外汇储备-环比"], errors="coerce"
2206
+ )
2207
+ temp_df["黄金储备-数值"] = pd.to_numeric(temp_df["黄金储备-数值"], errors="coerce")
2208
+ temp_df["黄金储备-同比"] = pd.to_numeric(temp_df["黄金储备-同比"], errors="coerce")
2209
+ temp_df["黄金储备-环比"] = pd.to_numeric(temp_df["黄金储备-环比"], errors="coerce")
2210
+ temp_df.sort_values(by=["月份"], inplace=True, ignore_index=True)
2629
2211
  return temp_df
2630
2212
 
2631
2213
 
@@ -2638,11 +2220,13 @@ def macro_china_stock_market_cap() -> pd.DataFrame:
2638
2220
  """
2639
2221
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
2640
2222
  headers = {
2641
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
2223
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
2224
+ "Chrome/81.0.4044.138 Safari/537.36",
2642
2225
  }
2643
2226
  params = {
2644
2227
  "reportName": "RPT_ECONOMY_STOCK_STATISTICS",
2645
- "columns": "REPORT_DATE,TIME,TOTAL_SHARES_SH,TOTAL_MARKE_SH,DEAL_AMOUNT_SH,VOLUME_SH,HIGH_INDEX_SH,LOW_INDEX_SH,TOTAL_SZARES_SZ,TOTAL_MARKE_SZ,DEAL_AMOUNT_SZ,VOLUME_SZ,HIGH_INDEX_SZ,LOW_INDEX_SZ",
2228
+ "columns": "REPORT_DATE,TIME,TOTAL_SHARES_SH,TOTAL_MARKE_SH,DEAL_AMOUNT_SH,VOLUME_SH,HIGH_INDEX_SH,"
2229
+ "LOW_INDEX_SH,TOTAL_SZARES_SZ,TOTAL_MARKE_SZ,DEAL_AMOUNT_SZ,VOLUME_SZ,HIGH_INDEX_SZ,LOW_INDEX_SZ",
2646
2230
  "sortColumns": "REPORT_DATE",
2647
2231
  "sortTypes": "-1",
2648
2232
  "pageNumber": "1",
@@ -2687,18 +2271,30 @@ def macro_china_stock_market_cap() -> pd.DataFrame:
2687
2271
  "A股最低综合股价指数-深圳",
2688
2272
  ]
2689
2273
  ]
2690
- temp_df["发行总股本-上海"] = pd.to_numeric(temp_df["发行总股本-上海"], errors="coerce")
2691
- temp_df["发行总股本-深圳"] = pd.to_numeric(temp_df["发行总股本-深圳"], errors="coerce")
2274
+ temp_df["发行总股本-上海"] = pd.to_numeric(
2275
+ temp_df["发行总股本-上海"], errors="coerce"
2276
+ )
2277
+ temp_df["发行总股本-深圳"] = pd.to_numeric(
2278
+ temp_df["发行总股本-深圳"], errors="coerce"
2279
+ )
2692
2280
  temp_df["市价总值-上海"] = pd.to_numeric(temp_df["市价总值-上海"], errors="coerce")
2693
2281
  temp_df["市价总值-深圳"] = pd.to_numeric(temp_df["市价总值-深圳"], errors="coerce")
2694
2282
  temp_df["成交金额-上海"] = pd.to_numeric(temp_df["成交金额-上海"], errors="coerce")
2695
2283
  temp_df["成交金额-深圳"] = pd.to_numeric(temp_df["成交金额-深圳"], errors="coerce")
2696
2284
  temp_df["成交量-上海"] = pd.to_numeric(temp_df["成交量-上海"], errors="coerce")
2697
2285
  temp_df["成交量-深圳"] = pd.to_numeric(temp_df["成交量-深圳"], errors="coerce")
2698
- temp_df["A股最高综合股价指数-上海"] = pd.to_numeric(temp_df["A股最高综合股价指数-上海"], errors="coerce")
2699
- temp_df["A股最高综合股价指数-深圳"] = pd.to_numeric(temp_df["A股最高综合股价指数-深圳"], errors="coerce")
2700
- temp_df["A股最低综合股价指数-上海"] = pd.to_numeric(temp_df["A股最低综合股价指数-上海"], errors="coerce")
2701
- temp_df["A股最低综合股价指数-深圳"] = pd.to_numeric(temp_df["A股最低综合股价指数-深圳"], errors="coerce")
2286
+ temp_df["A股最高综合股价指数-上海"] = pd.to_numeric(
2287
+ temp_df["A股最高综合股价指数-上海"], errors="coerce"
2288
+ )
2289
+ temp_df["A股最高综合股价指数-深圳"] = pd.to_numeric(
2290
+ temp_df["A股最高综合股价指数-深圳"], errors="coerce"
2291
+ )
2292
+ temp_df["A股最低综合股价指数-上海"] = pd.to_numeric(
2293
+ temp_df["A股最低综合股价指数-上海"], errors="coerce"
2294
+ )
2295
+ temp_df["A股最低综合股价指数-深圳"] = pd.to_numeric(
2296
+ temp_df["A股最低综合股价指数-深圳"], errors="coerce"
2297
+ )
2702
2298
  return temp_df
2703
2299
 
2704
2300
 
@@ -2711,7 +2307,8 @@ def macro_china_money_supply() -> pd.DataFrame:
2711
2307
  """
2712
2308
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
2713
2309
  params = {
2714
- "columns": "REPORT_DATE,TIME,BASIC_CURRENCY,BASIC_CURRENCY_SAME,BASIC_CURRENCY_SEQUENTIAL,CURRENCY,CURRENCY_SAME,CURRENCY_SEQUENTIAL,FREE_CASH,FREE_CASH_SAME,FREE_CASH_SEQUENTIAL",
2310
+ "columns": "REPORT_DATE,TIME,BASIC_CURRENCY,BASIC_CURRENCY_SAME,BASIC_CURRENCY_SEQUENTIAL,CURRENCY,"
2311
+ "CURRENCY_SAME,CURRENCY_SEQUENTIAL,FREE_CASH,FREE_CASH_SAME,FREE_CASH_SEQUENTIAL",
2715
2312
  "pageNumber": "1",
2716
2313
  "pageSize": "2000",
2717
2314
  "sortColumns": "REPORT_DATE",
@@ -2755,15 +2352,33 @@ def macro_china_money_supply() -> pd.DataFrame:
2755
2352
  ]
2756
2353
  ]
2757
2354
 
2758
- temp_df["货币和准货币(M2)-数量(亿元)"] = pd.to_numeric(temp_df["货币和准货币(M2)-数量(亿元)"])
2759
- temp_df["货币和准货币(M2)-同比增长"] = pd.to_numeric(temp_df["货币和准货币(M2)-同比增长"])
2760
- temp_df["货币和准货币(M2)-环比增长"] = pd.to_numeric(temp_df["货币和准货币(M2)-环比增长"])
2761
- temp_df["货币(M1)-数量(亿元)"] = pd.to_numeric(temp_df["货币(M1)-数量(亿元)"])
2762
- temp_df["货币(M1)-同比增长"] = pd.to_numeric(temp_df["货币(M1)-同比增长"])
2763
- temp_df["货币(M1)-环比增长"] = pd.to_numeric(temp_df["货币(M1)-环比增长"])
2764
- temp_df["流通中的现金(M0)-数量(亿元)"] = pd.to_numeric(temp_df["流通中的现金(M0)-数量(亿元)"])
2765
- temp_df["流通中的现金(M0)-同比增长"] = pd.to_numeric(temp_df["流通中的现金(M0)-同比增长"])
2766
- temp_df["流通中的现金(M0)-环比增长"] = pd.to_numeric(temp_df["流通中的现金(M0)-环比增长"])
2355
+ temp_df["货币和准货币(M2)-数量(亿元)"] = pd.to_numeric(
2356
+ temp_df["货币和准货币(M2)-数量(亿元)"], errors="coerce"
2357
+ )
2358
+ temp_df["货币和准货币(M2)-同比增长"] = pd.to_numeric(
2359
+ temp_df["货币和准货币(M2)-同比增长"], errors="coerce"
2360
+ )
2361
+ temp_df["货币和准货币(M2)-环比增长"] = pd.to_numeric(
2362
+ temp_df["货币和准货币(M2)-环比增长"], errors="coerce"
2363
+ )
2364
+ temp_df["货币(M1)-数量(亿元)"] = pd.to_numeric(
2365
+ temp_df["货币(M1)-数量(亿元)"], errors="coerce"
2366
+ )
2367
+ temp_df["货币(M1)-同比增长"] = pd.to_numeric(
2368
+ temp_df["货币(M1)-同比增长"], errors="coerce"
2369
+ )
2370
+ temp_df["货币(M1)-环比增长"] = pd.to_numeric(
2371
+ temp_df["货币(M1)-环比增长"], errors="coerce"
2372
+ )
2373
+ temp_df["流通中的现金(M0)-数量(亿元)"] = pd.to_numeric(
2374
+ temp_df["流通中的现金(M0)-数量(亿元)"], errors="coerce"
2375
+ )
2376
+ temp_df["流通中的现金(M0)-同比增长"] = pd.to_numeric(
2377
+ temp_df["流通中的现金(M0)-同比增长"], errors="coerce"
2378
+ )
2379
+ temp_df["流通中的现金(M0)-环比增长"] = pd.to_numeric(
2380
+ temp_df["流通中的现金(M0)-环比增长"], errors="coerce"
2381
+ )
2767
2382
  return temp_df
2768
2383
 
2769
2384
 
@@ -2776,7 +2391,9 @@ def macro_china_cpi() -> pd.DataFrame:
2776
2391
  """
2777
2392
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
2778
2393
  params = {
2779
- "columns": "REPORT_DATE,TIME,NATIONAL_SAME,NATIONAL_BASE,NATIONAL_SEQUENTIAL,NATIONAL_ACCUMULATE,CITY_SAME,CITY_BASE,CITY_SEQUENTIAL,CITY_ACCUMULATE,RURAL_SAME,RURAL_BASE,RURAL_SEQUENTIAL,RURAL_ACCUMULATE",
2394
+ "columns": "REPORT_DATE,TIME,NATIONAL_SAME,NATIONAL_BASE,NATIONAL_SEQUENTIAL,NATIONAL_ACCUMULATE,"
2395
+ "CITY_SAME,CITY_BASE,CITY_SEQUENTIAL,CITY_ACCUMULATE,RURAL_SAME,"
2396
+ "RURAL_BASE,RURAL_SEQUENTIAL,RURAL_ACCUMULATE",
2780
2397
  "pageNumber": "1",
2781
2398
  "pageSize": "2000",
2782
2399
  "sortColumns": "REPORT_DATE",
@@ -2850,7 +2467,8 @@ def macro_china_gdp() -> pd.DataFrame:
2850
2467
  """
2851
2468
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
2852
2469
  params = {
2853
- "columns": "REPORT_DATE,TIME,DOMESTICL_PRODUCT_BASE,FIRST_PRODUCT_BASE,SECOND_PRODUCT_BASE,THIRD_PRODUCT_BASE,SUM_SAME,FIRST_SAME,SECOND_SAME,THIRD_SAME",
2470
+ "columns": "REPORT_DATE,TIME,DOMESTICL_PRODUCT_BASE,FIRST_PRODUCT_BASE,SECOND_PRODUCT_BASE,"
2471
+ "THIRD_PRODUCT_BASE,SUM_SAME,FIRST_SAME,SECOND_SAME,THIRD_SAME",
2854
2472
  "pageNumber": "1",
2855
2473
  "pageSize": "2000",
2856
2474
  "sortColumns": "REPORT_DATE",
@@ -2891,14 +2509,30 @@ def macro_china_gdp() -> pd.DataFrame:
2891
2509
  "第三产业-同比增长",
2892
2510
  ]
2893
2511
  ]
2894
- temp_df["国内生产总值-绝对值"] = pd.to_numeric(temp_df["国内生产总值-绝对值"], errors="coerce")
2895
- temp_df["国内生产总值-同比增长"] = pd.to_numeric(temp_df["国内生产总值-同比增长"], errors="coerce")
2896
- temp_df["第一产业-绝对值"] = pd.to_numeric(temp_df["第一产业-绝对值"], errors="coerce")
2897
- temp_df["第一产业-同比增长"] = pd.to_numeric(temp_df["第一产业-同比增长"], errors="coerce")
2898
- temp_df["第二产业-绝对值"] = pd.to_numeric(temp_df["第二产业-绝对值"], errors="coerce")
2899
- temp_df["第二产业-同比增长"] = pd.to_numeric(temp_df["第二产业-同比增长"], errors="coerce")
2900
- temp_df["第三产业-绝对值"] = pd.to_numeric(temp_df["第三产业-绝对值"], errors="coerce")
2901
- temp_df["第三产业-同比增长"] = pd.to_numeric(temp_df["第三产业-同比增长"], errors="coerce")
2512
+ temp_df["国内生产总值-绝对值"] = pd.to_numeric(
2513
+ temp_df["国内生产总值-绝对值"], errors="coerce"
2514
+ )
2515
+ temp_df["国内生产总值-同比增长"] = pd.to_numeric(
2516
+ temp_df["国内生产总值-同比增长"], errors="coerce"
2517
+ )
2518
+ temp_df["第一产业-绝对值"] = pd.to_numeric(
2519
+ temp_df["第一产业-绝对值"], errors="coerce"
2520
+ )
2521
+ temp_df["第一产业-同比增长"] = pd.to_numeric(
2522
+ temp_df["第一产业-同比增长"], errors="coerce"
2523
+ )
2524
+ temp_df["第二产业-绝对值"] = pd.to_numeric(
2525
+ temp_df["第二产业-绝对值"], errors="coerce"
2526
+ )
2527
+ temp_df["第二产业-同比增长"] = pd.to_numeric(
2528
+ temp_df["第二产业-同比增长"], errors="coerce"
2529
+ )
2530
+ temp_df["第三产业-绝对值"] = pd.to_numeric(
2531
+ temp_df["第三产业-绝对值"], errors="coerce"
2532
+ )
2533
+ temp_df["第三产业-同比增长"] = pd.to_numeric(
2534
+ temp_df["第三产业-同比增长"], errors="coerce"
2535
+ )
2902
2536
  return temp_df
2903
2537
 
2904
2538
 
@@ -2991,9 +2625,13 @@ def macro_china_pmi() -> pd.DataFrame:
2991
2625
  ]
2992
2626
  ]
2993
2627
  temp_df["制造业-指数"] = pd.to_numeric(temp_df["制造业-指数"], errors="coerce")
2994
- temp_df["制造业-同比增长"] = pd.to_numeric(temp_df["制造业-同比增长"], errors="coerce")
2628
+ temp_df["制造业-同比增长"] = pd.to_numeric(
2629
+ temp_df["制造业-同比增长"], errors="coerce"
2630
+ )
2995
2631
  temp_df["非制造业-指数"] = pd.to_numeric(temp_df["非制造业-指数"], errors="coerce")
2996
- temp_df["非制造业-同比增长"] = pd.to_numeric(temp_df["非制造业-同比增长"], errors="coerce")
2632
+ temp_df["非制造业-同比增长"] = pd.to_numeric(
2633
+ temp_df["非制造业-同比增长"], errors="coerce"
2634
+ )
2997
2635
  return temp_df
2998
2636
 
2999
2637
 
@@ -3056,7 +2694,9 @@ def macro_china_hgjck() -> pd.DataFrame:
3056
2694
  """
3057
2695
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
3058
2696
  params = {
3059
- "columns": "REPORT_DATE,TIME,EXIT_BASE,IMPORT_BASE,EXIT_BASE_SAME,IMPORT_BASE_SAME,EXIT_BASE_SEQUENTIAL,IMPORT_BASE_SEQUENTIAL,EXIT_ACCUMULATE,IMPORT_ACCUMULATE,EXIT_ACCUMULATE_SAME,IMPORT_ACCUMULATE_SAME",
2697
+ "columns": "REPORT_DATE,TIME,EXIT_BASE,IMPORT_BASE,EXIT_BASE_SAME,IMPORT_BASE_SAME,"
2698
+ "EXIT_BASE_SEQUENTIAL,IMPORT_BASE_SEQUENTIAL,EXIT_ACCUMULATE,"
2699
+ "IMPORT_ACCUMULATE,EXIT_ACCUMULATE_SAME,IMPORT_ACCUMULATE_SAME",
3060
2700
  "pageNumber": "1",
3061
2701
  "pageSize": "2000",
3062
2702
  "sortColumns": "REPORT_DATE",
@@ -3104,16 +2744,36 @@ def macro_china_hgjck() -> pd.DataFrame:
3104
2744
  "累计进口额-同比增长",
3105
2745
  ]
3106
2746
  ]
3107
- temp_df["当月出口额-金额"] = pd.to_numeric(temp_df["当月出口额-金额"], errors="coerce")
3108
- temp_df["当月出口额-同比增长"] = pd.to_numeric(temp_df["当月出口额-同比增长"], errors="coerce")
3109
- temp_df["当月出口额-环比增长"] = pd.to_numeric(temp_df["当月出口额-环比增长"], errors="coerce")
3110
- temp_df["当月进口额-金额"] = pd.to_numeric(temp_df["当月进口额-金额"], errors="coerce")
3111
- temp_df["当月进口额-同比增长"] = pd.to_numeric(temp_df["当月进口额-同比增长"], errors="coerce")
3112
- temp_df["当月进口额-环比增长"] = pd.to_numeric(temp_df["当月进口额-环比增长"], errors="coerce")
3113
- temp_df["累计出口额-金额"] = pd.to_numeric(temp_df["累计出口额-金额"], errors="coerce")
3114
- temp_df["累计出口额-同比增长"] = pd.to_numeric(temp_df["累计出口额-同比增长"], errors="coerce")
3115
- temp_df["累计进口额-金额"] = pd.to_numeric(temp_df["累计进口额-金额"], errors="coerce")
3116
- temp_df["累计进口额-同比增长"] = pd.to_numeric(temp_df["累计进口额-同比增长"], errors="coerce")
2747
+ temp_df["当月出口额-金额"] = pd.to_numeric(
2748
+ temp_df["当月出口额-金额"], errors="coerce"
2749
+ )
2750
+ temp_df["当月出口额-同比增长"] = pd.to_numeric(
2751
+ temp_df["当月出口额-同比增长"], errors="coerce"
2752
+ )
2753
+ temp_df["当月出口额-环比增长"] = pd.to_numeric(
2754
+ temp_df["当月出口额-环比增长"], errors="coerce"
2755
+ )
2756
+ temp_df["当月进口额-金额"] = pd.to_numeric(
2757
+ temp_df["当月进口额-金额"], errors="coerce"
2758
+ )
2759
+ temp_df["当月进口额-同比增长"] = pd.to_numeric(
2760
+ temp_df["当月进口额-同比增长"], errors="coerce"
2761
+ )
2762
+ temp_df["当月进口额-环比增长"] = pd.to_numeric(
2763
+ temp_df["当月进口额-环比增长"], errors="coerce"
2764
+ )
2765
+ temp_df["累计出口额-金额"] = pd.to_numeric(
2766
+ temp_df["累计出口额-金额"], errors="coerce"
2767
+ )
2768
+ temp_df["累计出口额-同比增长"] = pd.to_numeric(
2769
+ temp_df["累计出口额-同比增长"], errors="coerce"
2770
+ )
2771
+ temp_df["累计进口额-金额"] = pd.to_numeric(
2772
+ temp_df["累计进口额-金额"], errors="coerce"
2773
+ )
2774
+ temp_df["累计进口额-同比增长"] = pd.to_numeric(
2775
+ temp_df["累计进口额-同比增长"], errors="coerce"
2776
+ )
3117
2777
  return temp_df
3118
2778
 
3119
2779
 
@@ -3281,7 +2941,9 @@ def macro_china_xfzxx() -> pd.DataFrame:
3281
2941
  """
3282
2942
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
3283
2943
  params = {
3284
- "columns": "REPORT_DATE,TIME,CONSUMERS_FAITH_INDEX,FAITH_INDEX_SAME,FAITH_INDEX_SEQUENTIAL,CONSUMERS_ASTIS_INDEX,ASTIS_INDEX_SAME,ASTIS_INDEX_SEQUENTIAL,CONSUMERS_EXPECT_INDEX,EXPECT_INDEX_SAME,EXPECT_INDEX_SEQUENTIAL",
2944
+ "columns": "REPORT_DATE,TIME,CONSUMERS_FAITH_INDEX,FAITH_INDEX_SAME,FAITH_INDEX_SEQUENTIAL,"
2945
+ "CONSUMERS_ASTIS_INDEX,ASTIS_INDEX_SAME,ASTIS_INDEX_SEQUENTIAL,CONSUMERS_EXPECT_INDEX,"
2946
+ "EXPECT_INDEX_SAME,EXPECT_INDEX_SEQUENTIAL",
3285
2947
  "pageNumber": "1",
3286
2948
  "pageSize": "2000",
3287
2949
  "sortColumns": "REPORT_DATE",
@@ -3326,15 +2988,33 @@ def macro_china_xfzxx() -> pd.DataFrame:
3326
2988
  ]
3327
2989
  ]
3328
2990
 
3329
- temp_df["消费者信心指数-指数值"] = pd.to_numeric(temp_df["消费者信心指数-指数值"], errors="coerce")
3330
- temp_df["消费者信心指数-同比增长"] = pd.to_numeric(temp_df["消费者信心指数-同比增长"], errors="coerce")
3331
- temp_df["消费者信心指数-环比增长"] = pd.to_numeric(temp_df["消费者信心指数-环比增长"], errors="coerce")
3332
- temp_df["消费者满意指数-指数值"] = pd.to_numeric(temp_df["消费者满意指数-指数值"], errors="coerce")
3333
- temp_df["消费者满意指数-同比增长"] = pd.to_numeric(temp_df["消费者满意指数-同比增长"], errors="coerce")
3334
- temp_df["消费者满意指数-环比增长"] = pd.to_numeric(temp_df["消费者满意指数-环比增长"], errors="coerce")
3335
- temp_df["消费者预期指数-指数值"] = pd.to_numeric(temp_df["消费者满意指数-指数值"], errors="coerce")
3336
- temp_df["消费者预期指数-同比增长"] = pd.to_numeric(temp_df["消费者预期指数-同比增长"], errors="coerce")
3337
- temp_df["消费者预期指数-环比增长"] = pd.to_numeric(temp_df["消费者预期指数-环比增长"], errors="coerce")
2991
+ temp_df["消费者信心指数-指数值"] = pd.to_numeric(
2992
+ temp_df["消费者信心指数-指数值"], errors="coerce"
2993
+ )
2994
+ temp_df["消费者信心指数-同比增长"] = pd.to_numeric(
2995
+ temp_df["消费者信心指数-同比增长"], errors="coerce"
2996
+ )
2997
+ temp_df["消费者信心指数-环比增长"] = pd.to_numeric(
2998
+ temp_df["消费者信心指数-环比增长"], errors="coerce"
2999
+ )
3000
+ temp_df["消费者满意指数-指数值"] = pd.to_numeric(
3001
+ temp_df["消费者满意指数-指数值"], errors="coerce"
3002
+ )
3003
+ temp_df["消费者满意指数-同比增长"] = pd.to_numeric(
3004
+ temp_df["消费者满意指数-同比增长"], errors="coerce"
3005
+ )
3006
+ temp_df["消费者满意指数-环比增长"] = pd.to_numeric(
3007
+ temp_df["消费者满意指数-环比增长"], errors="coerce"
3008
+ )
3009
+ temp_df["消费者预期指数-指数值"] = pd.to_numeric(
3010
+ temp_df["消费者满意指数-指数值"], errors="coerce"
3011
+ )
3012
+ temp_df["消费者预期指数-同比增长"] = pd.to_numeric(
3013
+ temp_df["消费者预期指数-同比增长"], errors="coerce"
3014
+ )
3015
+ temp_df["消费者预期指数-环比增长"] = pd.to_numeric(
3016
+ temp_df["消费者预期指数-环比增长"], errors="coerce"
3017
+ )
3338
3018
  return temp_df
3339
3019
 
3340
3020
 
@@ -3347,38 +3027,40 @@ def macro_china_gyzjz() -> pd.DataFrame:
3347
3027
  """
3348
3028
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
3349
3029
  params = {
3350
- 'columns': 'REPORT_DATE,TIME,BASE_SAME,BASE_ACCUMULATE',
3351
- 'pageNumber': '1',
3352
- 'pageSize': '2000',
3353
- 'sortColumns': 'REPORT_DATE',
3354
- 'sortTypes': '-1',
3355
- 'source': 'WEB',
3356
- 'client': 'WEB',
3357
- 'reportName': 'RPT_ECONOMY_INDUS_GROW',
3358
- 'p': '1',
3359
- 'pageNo': '1',
3360
- 'pageNum': '1',
3361
- '_': '1691676211803',
3030
+ "columns": "REPORT_DATE,TIME,BASE_SAME,BASE_ACCUMULATE",
3031
+ "pageNumber": "1",
3032
+ "pageSize": "2000",
3033
+ "sortColumns": "REPORT_DATE",
3034
+ "sortTypes": "-1",
3035
+ "source": "WEB",
3036
+ "client": "WEB",
3037
+ "reportName": "RPT_ECONOMY_INDUS_GROW",
3038
+ "p": "1",
3039
+ "pageNo": "1",
3040
+ "pageNum": "1",
3041
+ "_": "1691676211803",
3362
3042
  }
3363
3043
  r = requests.get(url, params=params)
3364
3044
  data_json = r.json()
3365
- temp_df = pd.DataFrame(data_json['result']['data'])
3045
+ temp_df = pd.DataFrame(data_json["result"]["data"])
3366
3046
  temp_df.columns = [
3367
3047
  "发布时间",
3368
3048
  "月份",
3369
3049
  "同比增长",
3370
3050
  "累计增长",
3371
3051
  ]
3372
- temp_df = temp_df[[
3373
- "月份",
3374
- "同比增长",
3375
- "累计增长",
3376
- "发布时间",
3377
- ]]
3052
+ temp_df = temp_df[
3053
+ [
3054
+ "月份",
3055
+ "同比增长",
3056
+ "累计增长",
3057
+ "发布时间",
3058
+ ]
3059
+ ]
3378
3060
  temp_df["同比增长"] = pd.to_numeric(temp_df["同比增长"], errors="coerce")
3379
3061
  temp_df["累计增长"] = pd.to_numeric(temp_df["累计增长"], errors="coerce")
3380
- temp_df['发布时间'] = pd.to_datetime(temp_df['发布时间'], errors="coerce").dt.date
3381
- temp_df.sort_values(['发布时间'], ignore_index=True, inplace=True)
3062
+ temp_df["发布时间"] = pd.to_datetime(temp_df["发布时间"], errors="coerce").dt.date
3063
+ temp_df.sort_values(["发布时间"], ignore_index=True, inplace=True)
3382
3064
  return temp_df
3383
3065
 
3384
3066
 
@@ -3391,7 +3073,8 @@ def macro_china_reserve_requirement_ratio() -> pd.DataFrame:
3391
3073
  """
3392
3074
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
3393
3075
  params = {
3394
- "columns": "REPORT_DATE,PUBLISH_DATE,TRADE_DATE,INTEREST_RATE_BB,INTEREST_RATE_BA,CHANGE_RATE_B,INTEREST_RATE_SB,INTEREST_RATE_SA,CHANGE_RATE_S,NEXT_SH_RATE,NEXT_SZ_RATE,REMARK",
3076
+ "columns": "REPORT_DATE,PUBLISH_DATE,TRADE_DATE,INTEREST_RATE_BB,INTEREST_RATE_BA,CHANGE_RATE_B,"
3077
+ "INTEREST_RATE_SB,INTEREST_RATE_SA,CHANGE_RATE_S,NEXT_SH_RATE,NEXT_SZ_RATE,REMARK",
3395
3078
  "pageNumber": "1",
3396
3079
  "pageSize": "2000",
3397
3080
  "sortColumns": "PUBLISH_DATE,TRADE_DATE",
@@ -3436,15 +3119,33 @@ def macro_china_reserve_requirement_ratio() -> pd.DataFrame:
3436
3119
  "备注",
3437
3120
  ]
3438
3121
  ]
3439
- temp_df["大型金融机构-调整前"] = pd.to_numeric(temp_df["大型金融机构-调整前"], errors="coerce")
3440
- temp_df["大型金融机构-调整后"] = pd.to_numeric(temp_df["大型金融机构-调整后"], errors="coerce")
3441
- temp_df["大型金融机构-调整幅度"] = pd.to_numeric(temp_df["大型金融机构-调整幅度"], errors="coerce")
3442
- temp_df["大型金融机构-调整前"] = pd.to_numeric(temp_df["大型金融机构-调整前"], errors="coerce")
3443
- temp_df["大型金融机构-调整后"] = pd.to_numeric(temp_df["大型金融机构-调整后"], errors="coerce")
3444
- temp_df["大型金融机构-调整幅度"] = pd.to_numeric(temp_df["大型金融机构-调整幅度"], errors="coerce")
3445
- temp_df["消息公布次日指数涨跌-上证"] = pd.to_numeric(temp_df["消息公布次日指数涨跌-上证"], errors="coerce")
3446
- temp_df["消息公布次日指数涨跌-深证"] = pd.to_numeric(temp_df["消息公布次日指数涨跌-深证"], errors="coerce")
3447
- temp_df["消息公布次日指数涨跌-深证"] = pd.to_numeric(temp_df["消息公布次日指数涨跌-深证"], errors="coerce")
3122
+ temp_df["大型金融机构-调整前"] = pd.to_numeric(
3123
+ temp_df["大型金融机构-调整前"], errors="coerce"
3124
+ )
3125
+ temp_df["大型金融机构-调整后"] = pd.to_numeric(
3126
+ temp_df["大型金融机构-调整后"], errors="coerce"
3127
+ )
3128
+ temp_df["大型金融机构-调整幅度"] = pd.to_numeric(
3129
+ temp_df["大型金融机构-调整幅度"], errors="coerce"
3130
+ )
3131
+ temp_df["大型金融机构-调整前"] = pd.to_numeric(
3132
+ temp_df["大型金融机构-调整前"], errors="coerce"
3133
+ )
3134
+ temp_df["大型金融机构-调整后"] = pd.to_numeric(
3135
+ temp_df["大型金融机构-调整后"], errors="coerce"
3136
+ )
3137
+ temp_df["大型金融机构-调整幅度"] = pd.to_numeric(
3138
+ temp_df["大型金融机构-调整幅度"], errors="coerce"
3139
+ )
3140
+ temp_df["消息公布次日指数涨跌-上证"] = pd.to_numeric(
3141
+ temp_df["消息公布次日指数涨跌-上证"], errors="coerce"
3142
+ )
3143
+ temp_df["消息公布次日指数涨跌-深证"] = pd.to_numeric(
3144
+ temp_df["消息公布次日指数涨跌-深证"], errors="coerce"
3145
+ )
3146
+ temp_df["消息公布次日指数涨跌-深证"] = pd.to_numeric(
3147
+ temp_df["消息公布次日指数涨跌-深证"], errors="coerce"
3148
+ )
3448
3149
  return temp_df
3449
3150
 
3450
3151
 
@@ -3457,10 +3158,12 @@ def macro_china_consumer_goods_retail() -> pd.DataFrame:
3457
3158
  """
3458
3159
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
3459
3160
  headers = {
3460
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
3161
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
3162
+ "Chrome/81.0.4044.138 Safari/537.36",
3461
3163
  }
3462
3164
  params = {
3463
- "columns": "REPORT_DATE,TIME,RETAIL_TOTAL,RETAIL_TOTAL_SAME,RETAIL_TOTAL_SEQUENTIAL,RETAIL_TOTAL_ACCUMULATE,RETAIL_ACCUMULATE_SAME",
3165
+ "columns": "REPORT_DATE,TIME,RETAIL_TOTAL,RETAIL_TOTAL_SAME,RETAIL_TOTAL_SEQUENTIAL,"
3166
+ "RETAIL_TOTAL_ACCUMULATE,RETAIL_ACCUMULATE_SAME",
3464
3167
  "pageNumber": "1",
3465
3168
  "pageSize": "1000",
3466
3169
  "sortColumns": "REPORT_DATE",
@@ -3506,7 +3209,7 @@ def macro_china_consumer_goods_retail() -> pd.DataFrame:
3506
3209
  def macro_china_society_electricity() -> pd.DataFrame:
3507
3210
  """
3508
3211
  新浪财经-中国宏观经济数据-全社会用电分类情况表
3509
- http://finance.sina.com.cn/mac/#industry-6-0-31-1
3212
+ https://finance.sina.com.cn/mac/#industry-6-0-31-1
3510
3213
  :return: 全社会用电分类情况表
3511
3214
  :rtype: pandas.DataFrame
3512
3215
  """
@@ -3521,14 +3224,14 @@ def macro_china_society_electricity() -> pd.DataFrame:
3521
3224
  }
3522
3225
  r = requests.get(url, params=params)
3523
3226
  data_text = r.text
3524
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3227
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3525
3228
  page_num = math.ceil(int(data_json["count"]) / 31)
3526
3229
  big_df = pd.DataFrame(data_json["data"])
3527
3230
  for i in range(1, page_num):
3528
3231
  params.update({"from": i * 31})
3529
3232
  r = requests.get(url, params=params)
3530
3233
  data_text = r.text
3531
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3234
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3532
3235
  temp_df = pd.DataFrame(data_json["data"])
3533
3236
  big_df = pd.concat([big_df, temp_df], ignore_index=True)
3534
3237
 
@@ -3551,13 +3254,16 @@ def macro_china_society_electricity() -> pd.DataFrame:
3551
3254
  "乡村居民用电量",
3552
3255
  "乡村居民用电量同比",
3553
3256
  ]
3257
+ for item in big_df.columns[1:]:
3258
+ big_df[item] = pd.to_numeric(big_df[item], errors="coerce")
3259
+ big_df.sort_values(["统计时间"], inplace=True, ignore_index=True)
3554
3260
  return big_df
3555
3261
 
3556
3262
 
3557
3263
  def macro_china_society_traffic_volume() -> pd.DataFrame:
3558
3264
  """
3559
3265
  新浪财经-中国宏观经济数据-全社会客货运输量
3560
- http://finance.sina.com.cn/mac/#industry-10-0-31-1
3266
+ https://finance.sina.com.cn/mac/#industry-10-0-31-1
3561
3267
  :return: 全社会客货运输量
3562
3268
  :rtype: pandas.DataFrame
3563
3269
  """
@@ -3572,38 +3278,51 @@ def macro_china_society_traffic_volume() -> pd.DataFrame:
3572
3278
  }
3573
3279
  r = requests.get(url, params=params)
3574
3280
  data_text = r.text
3575
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3281
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3576
3282
  page_num = math.ceil(int(data_json["count"]) / 31)
3577
3283
  big_df = pd.DataFrame(data_json["data"]["非累计"])
3284
+ tqdm = get_tqdm()
3578
3285
  for i in tqdm(range(1, page_num), leave=False):
3579
3286
  params.update({"from": i * 31})
3580
3287
  r = requests.get(url, params=params)
3581
3288
  data_text = r.text
3582
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3289
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3583
3290
  temp_df = pd.DataFrame(data_json["data"]["非累计"])
3584
3291
  big_df = pd.concat([big_df, temp_df], ignore_index=True)
3585
3292
  big_df.columns = [item[1] for item in data_json["config"]["all"]]
3586
- big_df['货运量'] = pd.to_numeric(big_df['货运量'], errors="coerce")
3587
- big_df['货运量同比增长'] = pd.to_numeric(big_df['货运量同比增长'], errors="coerce")
3588
- big_df['货物周转量'] = pd.to_numeric(big_df['货物周转量'], errors="coerce")
3589
- big_df['公里货物周转量同比增长'] = pd.to_numeric(big_df['公里货物周转量同比增长'], errors="coerce")
3590
- big_df['客运量'] = pd.to_numeric(big_df['客运量'], errors="coerce")
3591
- big_df['客运量同比增长'] = pd.to_numeric(big_df['客运量同比增长'], errors="coerce")
3592
- big_df['旅客周转量'] = pd.to_numeric(big_df['旅客周转量'], errors="coerce")
3593
- big_df['公里旅客周转量同比增长'] = pd.to_numeric(big_df['公里旅客周转量同比增长'], errors="coerce")
3594
- big_df['沿海主要港口货物吞吐量'] = pd.to_numeric(big_df['沿海主要港口货物吞吐量'], errors="coerce")
3595
- big_df['沿海主要港口货物吞吐量同比增长'] = pd.to_numeric(big_df['沿海主要港口货物吞吐量同比增长'], errors="coerce")
3596
- big_df['其中:外贸货物吞吐量'] = pd.to_numeric(big_df['其中:外贸货物吞吐量'], errors="coerce")
3597
- big_df['其中:外贸货物吞吐量同比增长'] = pd.to_numeric(big_df['其中:外贸货物吞吐量同比增长'], errors="coerce")
3598
- big_df['民航总周转量'] = pd.to_numeric(big_df['民航总周转量'], errors="coerce")
3599
- big_df['公里民航总周转'] = pd.to_numeric(big_df['公里民航总周转'], errors="coerce")
3293
+ big_df["货运量"] = pd.to_numeric(big_df["货运量"], errors="coerce")
3294
+ big_df["货运量同比增长"] = pd.to_numeric(big_df["货运量同比增长"], errors="coerce")
3295
+ big_df["货物周转量"] = pd.to_numeric(big_df["货物周转量"], errors="coerce")
3296
+ big_df["公里货物周转量同比增长"] = pd.to_numeric(
3297
+ big_df["公里货物周转量同比增长"], errors="coerce"
3298
+ )
3299
+ big_df["客运量"] = pd.to_numeric(big_df["客运量"], errors="coerce")
3300
+ big_df["客运量同比增长"] = pd.to_numeric(big_df["客运量同比增长"], errors="coerce")
3301
+ big_df["旅客周转量"] = pd.to_numeric(big_df["旅客周转量"], errors="coerce")
3302
+ big_df["公里旅客周转量同比增长"] = pd.to_numeric(
3303
+ big_df["公里旅客周转量同比增长"], errors="coerce"
3304
+ )
3305
+ big_df["沿海主要港口货物吞吐量"] = pd.to_numeric(
3306
+ big_df["沿海主要港口货物吞吐量"], errors="coerce"
3307
+ )
3308
+ big_df["沿海主要港口货物吞吐量同比增长"] = pd.to_numeric(
3309
+ big_df["沿海主要港口货物吞吐量同比增长"], errors="coerce"
3310
+ )
3311
+ big_df["其中:外贸货物吞吐量"] = pd.to_numeric(
3312
+ big_df["其中:外贸货物吞吐量"], errors="coerce"
3313
+ )
3314
+ big_df["其中:外贸货物吞吐量同比增长"] = pd.to_numeric(
3315
+ big_df["其中:外贸货物吞吐量同比增长"], errors="coerce"
3316
+ )
3317
+ big_df["民航总周转量"] = pd.to_numeric(big_df["民航总周转量"], errors="coerce")
3318
+ big_df["公里民航总周转"] = pd.to_numeric(big_df["公里民航总周转"], errors="coerce")
3600
3319
  return big_df
3601
3320
 
3602
3321
 
3603
3322
  def macro_china_postal_telecommunicational() -> pd.DataFrame:
3604
3323
  """
3605
3324
  新浪财经-中国宏观经济数据-邮电业务基本情况
3606
- http://finance.sina.com.cn/mac/#industry-11-0-31-1
3325
+ https://finance.sina.com.cn/mac/#industry-11-0-31-1
3607
3326
  :return: 邮电业务基本情况
3608
3327
  :rtype: pandas.DataFrame
3609
3328
  """
@@ -3618,16 +3337,17 @@ def macro_china_postal_telecommunicational() -> pd.DataFrame:
3618
3337
  }
3619
3338
  r = requests.get(url, params=params)
3620
3339
  data_text = r.text
3621
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3340
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3622
3341
  page_num = math.ceil(int(data_json["count"]) / 31)
3623
3342
  big_df = pd.DataFrame(data_json["data"]["非累计"])
3624
- for i in tqdm(range(1, page_num)):
3343
+ tqdm = get_tqdm()
3344
+ for i in tqdm(range(1, page_num), leave=False):
3625
3345
  params.update({"from": i * 31})
3626
3346
  r = requests.get(url, params=params)
3627
3347
  data_text = r.text
3628
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3348
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3629
3349
  temp_df = pd.DataFrame(data_json["data"]["非累计"])
3630
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
3350
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
3631
3351
  big_df.columns = [item[1] for item in data_json["config"]["all"]]
3632
3352
  for item in big_df.columns[1:]:
3633
3353
  big_df[item] = pd.to_numeric(big_df[item], errors="coerce")
@@ -3637,7 +3357,7 @@ def macro_china_postal_telecommunicational() -> pd.DataFrame:
3637
3357
  def macro_china_international_tourism_fx() -> pd.DataFrame:
3638
3358
  """
3639
3359
  新浪财经-中国宏观经济数据-国际旅游外汇收入构成
3640
- http://finance.sina.com.cn/mac/#industry-15-0-31-3
3360
+ https://finance.sina.com.cn/mac/#industry-15-0-31-3
3641
3361
  :return: 国际旅游外汇收入构成
3642
3362
  :rtype: pandas.DataFrame
3643
3363
  """
@@ -3652,26 +3372,27 @@ def macro_china_international_tourism_fx() -> pd.DataFrame:
3652
3372
  }
3653
3373
  r = requests.get(url, params=params)
3654
3374
  data_text = r.text
3655
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3375
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3656
3376
  page_num = math.ceil(int(data_json["count"]) / 31)
3657
3377
  big_df = pd.DataFrame(data_json["data"])
3378
+ tqdm = get_tqdm()
3658
3379
  for i in tqdm(range(1, page_num)):
3659
3380
  params.update({"from": i * 31})
3660
3381
  r = requests.get(url, params=params)
3661
3382
  data_text = r.text
3662
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3383
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3663
3384
  temp_df = pd.DataFrame(data_json["data"])
3664
3385
  big_df = pd.concat([big_df, temp_df], ignore_index=True)
3665
3386
  big_df.columns = [item[1] for item in data_json["config"]["all"]]
3666
- big_df['数量'] = pd.to_numeric(big_df['数量'], errors="coerce")
3667
- big_df['比重'] = pd.to_numeric(big_df['比重'], errors="coerce")
3387
+ big_df["数量"] = pd.to_numeric(big_df["数量"], errors="coerce")
3388
+ big_df["比重"] = pd.to_numeric(big_df["比重"], errors="coerce")
3668
3389
  return big_df
3669
3390
 
3670
3391
 
3671
3392
  def macro_china_passenger_load_factor() -> pd.DataFrame:
3672
3393
  """
3673
3394
  新浪财经-中国宏观经济数据-民航客座率及载运率
3674
- http://finance.sina.com.cn/mac/#industry-20-0-31-1
3395
+ https://finance.sina.com.cn/mac/#industry-20-0-31-1
3675
3396
  :return: 民航客座率及载运率
3676
3397
  :rtype: pandas.DataFrame
3677
3398
  """
@@ -3686,26 +3407,27 @@ def macro_china_passenger_load_factor() -> pd.DataFrame:
3686
3407
  }
3687
3408
  r = requests.get(url, params=params)
3688
3409
  data_text = r.text
3689
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3410
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3690
3411
  page_num = math.ceil(int(data_json["count"]) / 31)
3691
3412
  big_df = pd.DataFrame(data_json["data"])
3413
+ tqdm = get_tqdm()
3692
3414
  for i in tqdm(range(1, page_num)):
3693
3415
  params.update({"from": i * 31})
3694
3416
  r = requests.get(url, params=params)
3695
3417
  data_text = r.text
3696
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3418
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3697
3419
  temp_df = pd.DataFrame(data_json["data"])
3698
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
3420
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
3699
3421
  big_df.columns = [item[1] for item in data_json["config"]["all"]]
3700
- big_df['客座率'] = pd.to_numeric(big_df['客座率'], errors="coerce")
3701
- big_df['载运率'] = pd.to_numeric(big_df['载运率'], errors="coerce")
3422
+ big_df["客座率"] = pd.to_numeric(big_df["客座率"], errors="coerce")
3423
+ big_df["载运率"] = pd.to_numeric(big_df["载运率"], errors="coerce")
3702
3424
  return big_df
3703
3425
 
3704
3426
 
3705
3427
  def _macro_china_freight_index() -> pd.DataFrame:
3706
3428
  """
3707
3429
  新浪财经-中国宏观经济数据-航贸运价指数
3708
- http://finance.sina.com.cn/mac/#industry-22-0-31-2
3430
+ https://finance.sina.com.cn/mac/#industry-22-0-31-2
3709
3431
  :return: 航贸运价指数
3710
3432
  :rtype: pandas.DataFrame
3711
3433
  """
@@ -3720,14 +3442,15 @@ def _macro_china_freight_index() -> pd.DataFrame:
3720
3442
  }
3721
3443
  r = requests.get(url, params=params)
3722
3444
  data_text = r.text
3723
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3445
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3724
3446
  page_num = math.ceil(int(data_json["count"]) / 31)
3725
3447
  big_df = pd.DataFrame(data_json["data"])
3448
+ tqdm = get_tqdm()
3726
3449
  for i in tqdm(range(1, page_num)):
3727
3450
  params.update({"from": i * 31})
3728
3451
  r = requests.get(url, params=params)
3729
3452
  data_text = r.text
3730
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3453
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3731
3454
  temp_df = pd.DataFrame(data_json["data"])
3732
3455
  big_df = big_df.append(temp_df, ignore_index=True)
3733
3456
  big_df.columns = [item[1] for item in data_json["config"]["all"]]
@@ -3737,7 +3460,7 @@ def _macro_china_freight_index() -> pd.DataFrame:
3737
3460
  def macro_china_freight_index() -> pd.DataFrame:
3738
3461
  """
3739
3462
  新浪财经-中国宏观经济数据-航贸运价指数
3740
- http://finance.sina.com.cn/mac/#industry-22-0-31-2
3463
+ https://finance.sina.com.cn/mac/#industry-22-0-31-2
3741
3464
  :return: 航贸运价指数
3742
3465
  :rtype: pandas.DataFrame
3743
3466
  """
@@ -3759,20 +3482,30 @@ def macro_china_freight_index() -> pd.DataFrame:
3759
3482
  .dropna(axis=0)
3760
3483
  .iloc[:, :-1]
3761
3484
  )
3762
- big_df["波罗的海好望角型船运价指数BCI"] = pd.to_numeric(big_df["波罗的海好望角型船运价指数BCI"])
3763
- big_df["灵便型船综合运价指数BHMI"] = pd.to_numeric(big_df["灵便型船综合运价指数BHMI"])
3764
- big_df["波罗的海超级大灵便型船BSI指数"] = pd.to_numeric(big_df["波罗的海超级大灵便型船BSI指数"])
3485
+ big_df["波罗的海好望角型船运价指数BCI"] = pd.to_numeric(
3486
+ big_df["波罗的海好望角型船运价指数BCI"]
3487
+ )
3488
+ big_df["灵便型船综合运价指数BHMI"] = pd.to_numeric(
3489
+ big_df["灵便型船综合运价指数BHMI"]
3490
+ )
3491
+ big_df["波罗的海超级大灵便型船BSI指数"] = pd.to_numeric(
3492
+ big_df["波罗的海超级大灵便型船BSI指数"]
3493
+ )
3765
3494
  big_df["波罗的海综合运价指数BDI"] = pd.to_numeric(big_df["波罗的海综合运价指数BDI"])
3766
3495
  big_df["HRCI国际集装箱租船指数"] = pd.to_numeric(big_df["HRCI国际集装箱租船指数"])
3767
- big_df["油轮运价指数成品油运价指数BCTI"] = pd.to_numeric(big_df["油轮运价指数成品油运价指数BCTI"])
3768
- big_df["油轮运价指数原油运价指数BDTI"] = pd.to_numeric(big_df["油轮运价指数原油运价指数BDTI"])
3496
+ big_df["油轮运价指数成品油运价指数BCTI"] = pd.to_numeric(
3497
+ big_df["油轮运价指数成品油运价指数BCTI"]
3498
+ )
3499
+ big_df["油轮运价指数原油运价指数BDTI"] = pd.to_numeric(
3500
+ big_df["油轮运价指数原油运价指数BDTI"]
3501
+ )
3769
3502
  return big_df
3770
3503
 
3771
3504
 
3772
3505
  def macro_china_central_bank_balance() -> pd.DataFrame:
3773
3506
  """
3774
3507
  新浪财经-中国宏观经济数据-央行货币当局资产负债
3775
- http://finance.sina.com.cn/mac/#fininfo-8-0-31-2
3508
+ https://finance.sina.com.cn/mac/#fininfo-8-0-31-2
3776
3509
  :return: 央行货币当局资产负债
3777
3510
  :rtype: pandas.DataFrame
3778
3511
  """
@@ -3787,14 +3520,15 @@ def macro_china_central_bank_balance() -> pd.DataFrame:
3787
3520
  }
3788
3521
  r = requests.get(url, params=params)
3789
3522
  data_text = r.text
3790
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3523
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3791
3524
  page_num = math.ceil(int(data_json["count"]) / 31)
3792
3525
  big_df = pd.DataFrame(data_json["data"])
3526
+ tqdm = get_tqdm()
3793
3527
  for i in tqdm(range(1, page_num)):
3794
3528
  params.update({"from": i * 31})
3795
3529
  r = requests.get(url, params=params)
3796
3530
  data_text = r.text
3797
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3531
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3798
3532
  temp_df = pd.DataFrame(data_json["data"])
3799
3533
  big_df = pd.concat([big_df, temp_df], ignore_index=True)
3800
3534
  big_df.columns = [item[1] for item in data_json["config"]["all"]]
@@ -3806,7 +3540,7 @@ def macro_china_central_bank_balance() -> pd.DataFrame:
3806
3540
  def macro_china_insurance() -> pd.DataFrame:
3807
3541
  """
3808
3542
  新浪财经-中国宏观经济数据-保险业经营情况
3809
- http://finance.sina.com.cn/mac/#fininfo-19-0-31-3
3543
+ https://finance.sina.com.cn/mac/#fininfo-19-0-31-3
3810
3544
  :return: 保险业经营情况
3811
3545
  :rtype: pandas.DataFrame
3812
3546
  """
@@ -3821,14 +3555,15 @@ def macro_china_insurance() -> pd.DataFrame:
3821
3555
  }
3822
3556
  r = requests.get(url, params=params)
3823
3557
  data_text = r.text
3824
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3558
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3825
3559
  page_num = math.ceil(int(data_json["count"]) / 31)
3826
3560
  big_df = pd.DataFrame(data_json["data"])
3561
+ tqdm = get_tqdm()
3827
3562
  for i in tqdm(range(1, page_num)):
3828
3563
  params.update({"from": i * 31})
3829
3564
  r = requests.get(url, params=params)
3830
3565
  data_text = r.text
3831
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3566
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3832
3567
  temp_df = pd.DataFrame(data_json["data"])
3833
3568
  big_df = pd.concat([big_df, temp_df], ignore_index=True)
3834
3569
  big_df.columns = [item[1] for item in data_json["config"]["all"]]
@@ -3840,7 +3575,7 @@ def macro_china_insurance() -> pd.DataFrame:
3840
3575
  def macro_china_supply_of_money() -> pd.DataFrame:
3841
3576
  """
3842
3577
  新浪财经-中国宏观经济数据-货币供应量
3843
- http://finance.sina.com.cn/mac/#fininfo-1-0-31-1
3578
+ https://finance.sina.com.cn/mac/#fininfo-1-0-31-1
3844
3579
  :return: 货币供应量
3845
3580
  :rtype: pandas.DataFrame
3846
3581
  """
@@ -3855,16 +3590,17 @@ def macro_china_supply_of_money() -> pd.DataFrame:
3855
3590
  }
3856
3591
  r = requests.get(url, params=params)
3857
3592
  data_text = r.text
3858
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3593
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3859
3594
  page_num = math.ceil(int(data_json["count"]) / 31)
3860
3595
  big_df = pd.DataFrame(data_json["data"])
3596
+ tqdm = get_tqdm()
3861
3597
  for i in tqdm(range(1, page_num)):
3862
3598
  params.update({"from": i * 31})
3863
3599
  r = requests.get(url, params=params)
3864
3600
  data_text = r.text
3865
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3601
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3866
3602
  temp_df = pd.DataFrame(data_json["data"])
3867
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
3603
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
3868
3604
  big_df.columns = [item[1] for item in data_json["config"]["all"]]
3869
3605
  for item in big_df.columns[1:]:
3870
3606
  big_df[item] = pd.to_numeric(big_df[item], errors="coerce")
@@ -3874,7 +3610,7 @@ def macro_china_supply_of_money() -> pd.DataFrame:
3874
3610
  def macro_china_foreign_exchange_gold() -> pd.DataFrame:
3875
3611
  """
3876
3612
  央行黄金和外汇储备
3877
- http://finance.sina.com.cn/mac/#fininfo-5-0-31-2
3613
+ https://finance.sina.com.cn/mac/#fininfo-5-0-31-2
3878
3614
  :return: 央行黄金和外汇储备
3879
3615
  :rtype: pandas.DataFrame
3880
3616
  """
@@ -3889,24 +3625,28 @@ def macro_china_foreign_exchange_gold() -> pd.DataFrame:
3889
3625
  }
3890
3626
  r = requests.get(url, params=params)
3891
3627
  data_text = r.text
3892
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3628
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3893
3629
  page_num = math.ceil(int(data_json["count"]) / 31)
3894
3630
  big_df = pd.DataFrame(data_json["data"])
3895
- for i in tqdm(range(1, page_num)):
3631
+ tqdm = get_tqdm()
3632
+ for i in tqdm(range(1, page_num), leave=False):
3896
3633
  params.update({"from": i * 31})
3897
3634
  r = requests.get(url, params=params)
3898
3635
  data_text = r.text
3899
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3636
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3900
3637
  temp_df = pd.DataFrame(data_json["data"])
3901
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
3638
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
3902
3639
  big_df.columns = [item[1] for item in data_json["config"]["all"]]
3640
+ big_df.sort_values(by=["统计时间"], ignore_index=True, inplace=True)
3641
+ big_df["黄金储备"] = pd.to_numeric(big_df["黄金储备"], errors="coerce")
3642
+ big_df["国家外汇储备"] = pd.to_numeric(big_df["国家外汇储备"], errors="coerce")
3903
3643
  return big_df
3904
3644
 
3905
3645
 
3906
3646
  def macro_china_retail_price_index() -> pd.DataFrame:
3907
3647
  """
3908
3648
  商品零售价格指数
3909
- http://finance.sina.com.cn/mac/#price-12-0-31-1
3649
+ https://finance.sina.com.cn/mac/#price-12-0-31-1
3910
3650
  :return: 商品零售价格指数
3911
3651
  :rtype: pandas.DataFrame
3912
3652
  """
@@ -3921,30 +3661,36 @@ def macro_china_retail_price_index() -> pd.DataFrame:
3921
3661
  }
3922
3662
  r = requests.get(url, params=params)
3923
3663
  data_text = r.text
3924
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3664
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3925
3665
  page_num = math.ceil(int(data_json["count"]) / 31)
3926
3666
  big_df = pd.DataFrame(data_json["data"])
3927
- for i in tqdm(range(1, page_num)):
3667
+ tqdm = get_tqdm()
3668
+ for i in tqdm(range(1, page_num), leave=False):
3928
3669
  params.update({"from": i * 31})
3929
3670
  r = requests.get(url, params=params)
3930
3671
  data_text = r.text
3931
- data_json = demjson.decode(data_text[data_text.find("{"): -3])
3672
+ data_json = demjson.decode(data_text[data_text.find("{") : -3])
3932
3673
  temp_df = pd.DataFrame(data_json["data"])
3933
- big_df = pd.concat([big_df, temp_df], ignore_index=True)
3674
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
3934
3675
  big_df.columns = [item[1] for item in data_json["config"]["all"]]
3676
+ big_df.sort_values(by=["统计月份"], ignore_index=True, inplace=True)
3677
+ big_df["零售商品价格指数"] = pd.to_numeric(
3678
+ big_df["零售商品价格指数"], errors="coerce"
3679
+ )
3935
3680
  return big_df
3936
3681
 
3937
3682
 
3938
3683
  def macro_china_real_estate() -> pd.DataFrame:
3939
3684
  """
3940
3685
  国房景气指数
3941
- http://data.eastmoney.com/cjsj/hyzs_list_EMM00121987.html
3686
+ https://data.eastmoney.com/cjsj/hyzs_list_EMM00121987.html
3942
3687
  :return: 国房景气指数
3943
3688
  :rtype: pandas.DataFrame
3944
3689
  """
3945
3690
  url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
3946
3691
  headers = {
3947
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
3692
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
3693
+ "Chrome/81.0.4044.138 Safari/537.36",
3948
3694
  }
3949
3695
  params = {
3950
3696
  "sortColumns": "REPORT_DATE",
@@ -3952,7 +3698,8 @@ def macro_china_real_estate() -> pd.DataFrame:
3952
3698
  "pageSize": "1000",
3953
3699
  "pageNumber": "1",
3954
3700
  "reportName": "RPT_INDUSTRY_INDEX",
3955
- "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,CHANGERATE_2Y,CHANGERATE_3Y",
3701
+ "columns": "REPORT_DATE,INDICATOR_VALUE,CHANGE_RATE,CHANGERATE_3M,CHANGERATE_6M,CHANGERATE_1Y,"
3702
+ "CHANGERATE_2Y,CHANGERATE_3Y",
3956
3703
  "filter": '(INDICATOR_ID="EMM00121987")',
3957
3704
  "source": "WEB",
3958
3705
  "client": "WEB",
@@ -3961,6 +3708,7 @@ def macro_china_real_estate() -> pd.DataFrame:
3961
3708
  data_json = r.json()
3962
3709
  total_page = data_json["result"]["pages"]
3963
3710
  big_df = pd.DataFrame()
3711
+ tqdm = get_tqdm()
3964
3712
  for page in tqdm(range(1, total_page + 1), leave=False):
3965
3713
  params.update({"pageNumber": page})
3966
3714
  r = requests.get(url, params=params, headers=headers)
@@ -3977,15 +3725,15 @@ def macro_china_real_estate() -> pd.DataFrame:
3977
3725
  "近2年涨跌幅",
3978
3726
  "近3年涨跌幅",
3979
3727
  ]
3980
- big_df["日期"] = pd.to_datetime(big_df["日期"]).dt.date
3981
- big_df["最新值"] = pd.to_numeric(big_df["最新值"])
3982
- big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"])
3983
- big_df["近3月涨跌幅"] = pd.to_numeric(big_df["近3月涨跌幅"])
3984
- big_df["近6月涨跌幅"] = pd.to_numeric(big_df["近6月涨跌幅"])
3985
- big_df["近1年涨跌幅"] = pd.to_numeric(big_df["近1年涨跌幅"])
3986
- big_df["近2年涨跌幅"] = pd.to_numeric(big_df["近2年涨跌幅"])
3987
- big_df["近3年涨跌幅"] = pd.to_numeric(big_df["近3年涨跌幅"])
3988
- big_df.sort_values(["日期"], inplace=True)
3728
+ big_df["日期"] = pd.to_datetime(big_df["日期"], errors="coerce").dt.date
3729
+ big_df["最新值"] = pd.to_numeric(big_df["最新值"], errors="coerce")
3730
+ big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"], errors="coerce")
3731
+ big_df["近3月涨跌幅"] = pd.to_numeric(big_df["近3月涨跌幅"], errors="coerce")
3732
+ big_df["近6月涨跌幅"] = pd.to_numeric(big_df["近6月涨跌幅"], errors="coerce")
3733
+ big_df["近1年涨跌幅"] = pd.to_numeric(big_df["近1年涨跌幅"], errors="coerce")
3734
+ big_df["近2年涨跌幅"] = pd.to_numeric(big_df["近2年涨跌幅"], errors="coerce")
3735
+ big_df["近3年涨跌幅"] = pd.to_numeric(big_df["近3年涨跌幅"], errors="coerce")
3736
+ big_df.sort_values(by=["日期"], inplace=True)
3989
3737
  big_df.drop_duplicates(inplace=True)
3990
3738
  big_df.reset_index(inplace=True, drop=True)
3991
3739
  return big_df