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,27 +1,78 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2023/7/19 18:00
4
+ Date: 2024/4/4 18:00
5
5
  Desc: 金十数据中心-经济指标-美国
6
6
  https://datacenter.jin10.com/economic
7
7
  """
8
- import json
8
+
9
+ import datetime
9
10
  import time
10
11
 
11
12
  import pandas as pd
12
13
  import requests
13
14
 
14
- from akshare.economic.cons import (
15
- JS_USA_NON_FARM_URL,
16
- JS_USA_UNEMPLOYMENT_RATE_URL,
17
- JS_USA_EIA_CRUDE_URL,
18
- JS_USA_INITIAL_JOBLESS_URL,
19
- JS_USA_CORE_PCE_PRICE_URL,
20
- JS_USA_CPI_MONTHLY_URL,
21
- JS_USA_LMCI_URL,
22
- JS_USA_ADP_NONFARM_URL,
23
- JS_USA_GDP_MONTHLY_URL,
24
- )
15
+
16
+ def __macro_usa_base_func(symbol: str, params: dict) -> pd.DataFrame:
17
+ """
18
+ 金十数据中心-经济指标-美国-基础函数
19
+ https://datacenter.jin10.com/economic
20
+ :return: 美国经济指标数据
21
+ :rtype: pandas.DataFrame
22
+ """
23
+ import warnings
24
+
25
+ warnings.filterwarnings(action="ignore", category=FutureWarning)
26
+ headers = {
27
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
28
+ "Chrome/107.0.0.0 Safari/537.36",
29
+ "x-app-id": "rU6QIu7JHe2gOUeR",
30
+ "x-csrf-token": "x-csrf-token",
31
+ "x-version": "1.0.0",
32
+ }
33
+ url = "https://datacenter-api.jin10.com/reports/list_v2"
34
+ params = params
35
+ big_df = pd.DataFrame()
36
+ while True:
37
+ r = requests.get(url, params=params, headers=headers)
38
+ data_json = r.json()
39
+ if not data_json["data"]["values"]:
40
+ break
41
+ temp_df = pd.DataFrame(data_json["data"]["values"])
42
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
43
+ last_date_str = temp_df.iat[-1, 0]
44
+ last_date_str = (
45
+ (
46
+ datetime.datetime.strptime(last_date_str, "%Y-%m-%d")
47
+ - datetime.timedelta(days=1)
48
+ )
49
+ .date()
50
+ .isoformat()
51
+ )
52
+ params.update({"max_date": f"{last_date_str}"})
53
+ big_df.columns = [
54
+ "日期",
55
+ "今值",
56
+ "预测值",
57
+ "前值",
58
+ ]
59
+ big_df["商品"] = symbol
60
+ big_df = big_df[
61
+ [
62
+ "商品",
63
+ "日期",
64
+ "今值",
65
+ "预测值",
66
+ "前值",
67
+ ]
68
+ ]
69
+ big_df["日期"] = pd.to_datetime(big_df["日期"], errors="coerce").dt.date
70
+ big_df["今值"] = pd.to_numeric(big_df["今值"], errors="coerce")
71
+ big_df["预测值"] = pd.to_numeric(big_df["预测值"], errors="coerce")
72
+ big_df["前值"] = pd.to_numeric(big_df["前值"], errors="coerce")
73
+ big_df.sort_values(["日期"], inplace=True)
74
+ big_df.reset_index(inplace=True, drop=True)
75
+ return big_df
25
76
 
26
77
 
27
78
  # 东方财富-美国-未决房屋销售月率
@@ -71,7 +122,46 @@ def macro_usa_phs() -> pd.DataFrame:
71
122
  ]
72
123
  temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
73
124
  temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
74
- temp_df["发布日期"] = pd.to_datetime(temp_df["发布日期"]).dt.date
125
+ temp_df["发布日期"] = pd.to_datetime(temp_df["发布日期"], errors="coerce").dt.date
126
+ return temp_df
127
+
128
+
129
+ # 东方财富-经济指标-美国-物价水平-美国核心CPI月率报告
130
+ def macro_usa_cpi_yoy() -> pd.DataFrame:
131
+ """
132
+ 东方财富-经济数据一览-美国-CPI年率, 数据区间从 2008-至今
133
+ https://data.eastmoney.com/cjsj/foreign_0_12.html
134
+ :return: 美国 CPI 年率报告
135
+ :rtype: pandas.DataFrame
136
+ """
137
+ url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
138
+ params = {
139
+ "reportName": "RPT_ECONOMICVALUE_USA",
140
+ "columns": "ALL",
141
+ "filter": '(INDICATOR_ID="EMG00000733")',
142
+ "sortColumns": "REPORT_DATE",
143
+ "sortTypes": "-1",
144
+ "source": "WEB",
145
+ "client": "WEB",
146
+ "_": "1689320600161",
147
+ }
148
+ r = requests.get(url, params=params)
149
+ data_json = r.json()
150
+ data_list = data_json["result"]["data"]
151
+ temp_df = pd.DataFrame(
152
+ data_list, columns=["REPORT_DATE", "PUBLISH_DATE", "VALUE", "PRE_VALUE"]
153
+ )
154
+ temp_df.columns = [
155
+ "时间",
156
+ "发布日期",
157
+ "现值",
158
+ "前值",
159
+ ]
160
+ temp_df["时间"] = pd.to_datetime(temp_df["时间"], errors="coerce").dt.date
161
+ temp_df["发布日期"] = pd.to_datetime(temp_df["发布日期"], errors="coerce").dt.date
162
+ temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
163
+ temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
164
+ temp_df.sort_values(by=["时间"], inplace=True, ignore_index=True)
75
165
  return temp_df
76
166
 
77
167
 
@@ -80,159 +170,36 @@ def macro_usa_gdp_monthly() -> pd.DataFrame:
80
170
  """
81
171
  金十数据-美国国内生产总值(GDP)报告, 数据区间从 20080228-至今
82
172
  https://datacenter.jin10.com/reportType/dc_usa_gdp
83
- :return: pandas.Series
173
+ :return: 美国国内生产总值(GDP)
174
+ :rtype: pandas.DataFrame
84
175
  """
85
176
  t = time.time()
86
- r = requests.get(
87
- JS_USA_GDP_MONTHLY_URL.format(
88
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
89
- )
90
- )
91
- json_data = json.loads(r.text[r.text.find("{") : r.text.rfind("}") + 1])
92
- date_list = [item["date"] for item in json_data["list"]]
93
- value_list = [item["datas"]["美国国内生产总值(GDP)"] for item in json_data["list"]]
94
- value_df = pd.DataFrame(value_list)
95
- value_df.columns = json_data["kinds"]
96
- value_df.index = pd.to_datetime(date_list)
97
-
98
- url = "https://datacenter-api.jin10.com/reports/list_v2"
99
177
  params = {
100
178
  "max_date": "",
101
179
  "category": "ec",
102
180
  "attr_id": "53",
103
181
  "_": str(int(round(t * 1000))),
104
182
  }
105
- headers = {
106
- "accept": "*/*",
107
- "accept-encoding": "gzip, deflate, br",
108
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
109
- "cache-control": "no-cache",
110
- "origin": "https://datacenter.jin10.com",
111
- "pragma": "no-cache",
112
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
113
- "sec-fetch-dest": "empty",
114
- "sec-fetch-mode": "cors",
115
- "sec-fetch-site": "same-site",
116
- "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",
117
- "x-app-id": "rU6QIu7JHe2gOUeR",
118
- "x-csrf-token": "",
119
- "x-version": "1.0.0",
120
- }
121
- r = requests.get(url, params=params, headers=headers)
122
- temp_df = pd.DataFrame(r.json()["data"]["values"])
123
- temp_df.index = pd.to_datetime(temp_df.iloc[:, 0])
124
- temp_df.columns = ['date'] + json_data["kinds"]
125
- del temp_df['date']
126
- temp_df = pd.concat([value_df, temp_df])
127
-
128
- temp_df.dropna(subset=["预测值(%)"], inplace=True)
129
- temp_df.sort_index(inplace=True)
130
- temp_df = temp_df.reset_index()
131
- temp_df.drop_duplicates(subset="index", inplace=True)
132
- temp_df.columns = ['日期', '今值', '预测值', '前值']
133
- temp_df['日期'] = pd.to_datetime(temp_df['日期']).dt.date
134
- temp_df['今值'] = pd.to_numeric(temp_df['今值'], errors="coerce")
135
- temp_df['预测值'] = pd.to_numeric(temp_df['预测值'], errors="coerce")
136
- temp_df['前值'] = pd.to_numeric(temp_df['前值'], errors="coerce")
183
+ temp_df = __macro_usa_base_func(symbol="美国国内生产总值(GDP)", params=params)
137
184
  return temp_df
138
185
 
139
186
 
140
187
  # 金十数据中心-经济指标-美国-物价水平-美国CPI月率报告
141
188
  def macro_usa_cpi_monthly() -> pd.DataFrame:
142
189
  """
143
- 美国CPI月率报告, 数据区间从19700101-至今
190
+ 美国 CPI 月率报告, 数据区间从 19700101-至今
144
191
  https://datacenter.jin10.com/reportType/dc_usa_cpi
145
- https://cdn.jin10.com/dc/reports/dc_usa_cpi_all.js?v=1578741110
146
- :return: 美国CPI月率报告-今值(%)
147
- :rtype: pandas.Series
192
+ :return: 美国 CPI 月率报告
193
+ :rtype: pandas.DataFrame
148
194
  """
149
195
  t = time.time()
150
- res = requests.get(
151
- JS_USA_CPI_MONTHLY_URL.format(
152
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
153
- )
154
- )
155
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
156
- date_list = [item["date"] for item in json_data["list"]]
157
- value_list = [item["datas"]["美国居民消费价格指数(CPI)(月环比)"] for item in json_data["list"]]
158
- value_df = pd.DataFrame(value_list)
159
- value_df.columns = json_data["kinds"]
160
- value_df.index = pd.to_datetime(date_list)
161
- temp_df = value_df["今值(%)"]
162
- url = "https://datacenter-api.jin10.com/reports/list_v2"
163
196
  params = {
164
197
  "max_date": "",
165
198
  "category": "ec",
166
199
  "attr_id": "9",
167
200
  "_": str(int(round(t * 1000))),
168
201
  }
169
- headers = {
170
- "accept": "*/*",
171
- "accept-encoding": "gzip, deflate, br",
172
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
173
- "cache-control": "no-cache",
174
- "origin": "https://datacenter.jin10.com",
175
- "pragma": "no-cache",
176
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
177
- "sec-fetch-dest": "empty",
178
- "sec-fetch-mode": "cors",
179
- "sec-fetch-site": "same-site",
180
- "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",
181
- "x-app-id": "rU6QIu7JHe2gOUeR",
182
- "x-csrf-token": "",
183
- "x-version": "1.0.0",
184
- }
185
- r = requests.get(url, params=params, headers=headers)
186
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
187
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
188
- temp_se = temp_se.iloc[:, 1]
189
- temp_df = pd.concat([temp_df, temp_se])
190
- temp_df.dropna(inplace=True)
191
- temp_df.sort_index(inplace=True)
192
- temp_df = temp_df.reset_index()
193
- temp_df.drop_duplicates(subset="index", inplace=True)
194
- temp_df.set_index("index", inplace=True)
195
- temp_df = temp_df.squeeze()
196
- temp_df.index.name = None
197
- temp_df.name = "cpi_monthly"
198
- temp_df = temp_df.astype("float")
199
- return temp_df
200
-
201
-
202
- # 东方财富-经济指标-美国-物价水平-美国核心CPI月率报告
203
- def macro_usa_cpi_yoy() -> pd.DataFrame:
204
- """
205
- 东方财富-经济数据一览-美国-CPI年率, 数据区间从 2008-至今
206
- https://data.eastmoney.com/cjsj/foreign_0_12.html
207
- :return: 美国 CPI 年率报告
208
- :rtype: pandas.DataFrame
209
- """
210
- url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
211
- params = {
212
- "reportName": "RPT_ECONOMICVALUE_USA",
213
- "columns": "ALL",
214
- "filter": '(INDICATOR_ID="EMG00000733")',
215
- "sortColumns": "REPORT_DATE",
216
- "sortTypes": "-1",
217
- "source": "WEB",
218
- "client": "WEB",
219
- "_": "1689320600161",
220
- }
221
- r = requests.get(url, params=params)
222
- data_json = r.json()
223
- data_list = data_json["result"]["data"]
224
- temp_df = pd.DataFrame(data_list, columns=['REPORT_DATE', 'PUBLISH_DATE', 'VALUE', 'PRE_VALUE'])
225
- temp_df.columns = [
226
- "时间",
227
- "发布日期",
228
- "现值",
229
- "前值",
230
- ]
231
- temp_df["时间"] = pd.to_datetime(temp_df["时间"], errors="coerce").dt.date
232
- temp_df["发布日期"] = pd.to_datetime(temp_df["发布日期"], errors="coerce").dt.date
233
- temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
234
- temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
235
- temp_df.sort_values(['时间'], inplace=True, ignore_index=True)
202
+ temp_df = __macro_usa_base_func(symbol="美国CPI月率", params=params)
236
203
  return temp_df
237
204
 
238
205
 
@@ -241,63 +208,17 @@ def macro_usa_core_cpi_monthly() -> pd.DataFrame:
241
208
  """
242
209
  美国核心 CPI 月率报告, 数据区间从 19700101-至今
243
210
  https://datacenter.jin10.com/reportType/dc_usa_core_cpi
244
- https://cdn.jin10.com/dc/reports/dc_usa_core_cpi_all.js?v=1578740570
245
- :return: 美国核心CPI月率报告-今值(%)
246
- :rtype: pandas.Series
211
+ :return: 美国核心CPI月率报告
212
+ :rtype: pandas.DataFrame
247
213
  """
248
214
  t = time.time()
249
- res = requests.get(
250
- f"https://cdn.jin10.com/dc/reports/dc_usa_core_cpi_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
251
- )
252
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
253
- date_list = [item["date"] for item in json_data["list"]]
254
- value_list = [item["datas"]["美国核心CPI月率报告"] for item in json_data["list"]]
255
- value_df = pd.DataFrame(value_list)
256
- value_df.columns = json_data["kinds"]
257
- value_df.index = pd.to_datetime(date_list)
258
- temp_df = value_df["今值(%)"]
259
- url = "https://datacenter-api.jin10.com/reports/list_v2"
260
215
  params = {
261
216
  "max_date": "",
262
217
  "category": "ec",
263
218
  "attr_id": "6",
264
219
  "_": str(int(round(t * 1000))),
265
220
  }
266
- headers = {
267
- "accept": "*/*",
268
- "accept-encoding": "gzip, deflate, br",
269
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
270
- "cache-control": "no-cache",
271
- "origin": "https://datacenter.jin10.com",
272
- "pragma": "no-cache",
273
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
274
- "sec-fetch-dest": "empty",
275
- "sec-fetch-mode": "cors",
276
- "sec-fetch-site": "same-site",
277
- "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",
278
- "x-app-id": "rU6QIu7JHe2gOUeR",
279
- "x-csrf-token": "",
280
- "x-version": "1.0.0",
281
- }
282
- r = requests.get(url, params=params, headers=headers)
283
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
284
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
285
- temp_se = temp_se.iloc[:, 1]
286
- temp_df = pd.concat([temp_df, temp_se])
287
- temp_df.dropna(inplace=True)
288
- temp_df.sort_index(inplace=True)
289
- temp_df = temp_df.reset_index()
290
- temp_df.drop_duplicates(subset="index", inplace=True)
291
- temp_df.set_index("index", inplace=True)
292
- temp_df = temp_df.squeeze()
293
- temp_df.index.name = None
294
- temp_df.name = "usa_core_cpi"
295
- temp_df = temp_df.astype("float")
296
- temp_df = pd.DataFrame(temp_df)
297
- temp_df.reset_index(inplace=True, drop=False)
298
- temp_df.columns = ['date', 'value']
299
- temp_df['date'] = pd.to_datetime(temp_df['date'], errors="coerce").dt.date
300
- temp_df['value'] = pd.to_numeric(temp_df['value'], errors="coerce")
221
+ temp_df = __macro_usa_base_func(symbol="美国核心CPI月率", params=params)
301
222
  return temp_df
302
223
 
303
224
 
@@ -306,118 +227,36 @@ def macro_usa_personal_spending() -> pd.DataFrame:
306
227
  """
307
228
  美国个人支出月率报告, 数据区间从19700101-至今
308
229
  https://datacenter.jin10.com/reportType/dc_usa_personal_spending
309
- https://cdn.jin10.com/dc/reports/dc_usa_personal_spending_all.js?v=1578741327
310
- :return: 美国个人支出月率报告-今值(%)
311
- :rtype: pandas.Series
230
+ :return: 美国个人支出月率报告
231
+ :rtype: pandas.DataFrame
312
232
  """
313
233
  t = time.time()
314
- res = requests.get(
315
- f"https://cdn.jin10.com/dc/reports/dc_usa_personal_spending_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
316
- )
317
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
318
- date_list = [item["date"] for item in json_data["list"]]
319
- value_list = [item["datas"]["美国个人支出月率报告"] for item in json_data["list"]]
320
- value_df = pd.DataFrame(value_list)
321
- value_df.columns = json_data["kinds"]
322
- value_df.index = pd.to_datetime(date_list)
323
- temp_df = value_df["今值(%)"]
324
- url = "https://datacenter-api.jin10.com/reports/list_v2"
325
234
  params = {
326
235
  "max_date": "",
327
236
  "category": "ec",
328
237
  "attr_id": "35",
329
238
  "_": str(int(round(t * 1000))),
330
239
  }
331
- headers = {
332
- "accept": "*/*",
333
- "accept-encoding": "gzip, deflate, br",
334
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
335
- "cache-control": "no-cache",
336
- "origin": "https://datacenter.jin10.com",
337
- "pragma": "no-cache",
338
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
339
- "sec-fetch-dest": "empty",
340
- "sec-fetch-mode": "cors",
341
- "sec-fetch-site": "same-site",
342
- "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",
343
- "x-app-id": "rU6QIu7JHe2gOUeR",
344
- "x-csrf-token": "",
345
- "x-version": "1.0.0",
346
- }
347
- r = requests.get(url, params=params, headers=headers)
348
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
349
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
350
- temp_se = temp_se.iloc[:, 1]
351
- temp_df = pd.concat([temp_df, temp_se])
352
- temp_df.dropna(inplace=True)
353
- temp_df.sort_index(inplace=True)
354
- temp_df = temp_df.reset_index()
355
- temp_df.drop_duplicates(subset="index", inplace=True)
356
- temp_df.set_index("index", inplace=True)
357
- temp_df = temp_df.squeeze()
358
- temp_df.index.name = None
359
- temp_df.name = "usa_personal_spending"
360
- temp_df = temp_df.astype("float")
240
+ temp_df = __macro_usa_base_func(symbol="美国个人支出月率", params=params)
361
241
  return temp_df
362
242
 
363
243
 
364
244
  # 金十数据中心-经济指标-美国-物价水平-美国零售销售月率报告
365
245
  def macro_usa_retail_sales() -> pd.DataFrame:
366
246
  """
367
- 美国零售销售月率报告, 数据区间从19920301-至今
247
+ 美国零售销售月率报告, 数据区间从 19920301-至今
368
248
  https://datacenter.jin10.com/reportType/dc_usa_retail_sales
369
- https://cdn.jin10.com/dc/reports/dc_usa_retail_sales_all.js?v=1578741528
370
249
  :return: 美国零售销售月率报告-今值(%)
371
- :rtype: pandas.Series
250
+ :rtype: pandas.DataFrame
372
251
  """
373
252
  t = time.time()
374
- res = requests.get(
375
- f"https://cdn.jin10.com/dc/reports/dc_usa_retail_sales_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
376
- )
377
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
378
- date_list = [item["date"] for item in json_data["list"]]
379
- value_list = [item["datas"]["美国零售销售月率报告"] for item in json_data["list"]]
380
- value_df = pd.DataFrame(value_list)
381
- value_df.columns = json_data["kinds"]
382
- value_df.index = pd.to_datetime(date_list)
383
- temp_df = value_df["今值(%)"]
384
- url = "https://datacenter-api.jin10.com/reports/list_v2"
385
253
  params = {
386
254
  "max_date": "",
387
255
  "category": "ec",
388
256
  "attr_id": "39",
389
257
  "_": str(int(round(t * 1000))),
390
258
  }
391
- headers = {
392
- "accept": "*/*",
393
- "accept-encoding": "gzip, deflate, br",
394
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
395
- "cache-control": "no-cache",
396
- "origin": "https://datacenter.jin10.com",
397
- "pragma": "no-cache",
398
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
399
- "sec-fetch-dest": "empty",
400
- "sec-fetch-mode": "cors",
401
- "sec-fetch-site": "same-site",
402
- "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",
403
- "x-app-id": "rU6QIu7JHe2gOUeR",
404
- "x-csrf-token": "",
405
- "x-version": "1.0.0",
406
- }
407
- r = requests.get(url, params=params, headers=headers)
408
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
409
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
410
- temp_se = temp_se.iloc[:, 1]
411
- temp_df = pd.concat([temp_df, temp_se])
412
- temp_df.dropna(inplace=True)
413
- temp_df.sort_index(inplace=True)
414
- temp_df = temp_df.reset_index()
415
- temp_df.drop_duplicates(subset="index", inplace=True)
416
- temp_df.set_index("index", inplace=True)
417
- temp_df = temp_df.squeeze()
418
- temp_df.index.name = None
419
- temp_df.name = "usa_retail_sales"
420
- temp_df = temp_df.astype("float")
259
+ temp_df = __macro_usa_base_func(symbol="美国零售销售月率", params=params)
421
260
  return temp_df
422
261
 
423
262
 
@@ -426,58 +265,17 @@ def macro_usa_import_price() -> pd.DataFrame:
426
265
  """
427
266
  美国进口物价指数报告, 数据区间从19890201-至今
428
267
  https://datacenter.jin10.com/reportType/dc_usa_import_price
429
- https://cdn.jin10.com/dc/reports/dc_usa_import_price_all.js?v=1578741716
430
268
  :return: 美国进口物价指数报告-今值(%)
431
269
  :rtype: pandas.Series
432
270
  """
433
271
  t = time.time()
434
- res = requests.get(
435
- f"https://cdn.jin10.com/dc/reports/dc_usa_import_price_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
436
- )
437
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
438
- date_list = [item["date"] for item in json_data["list"]]
439
- value_list = [item["datas"]["美国进口物价指数"] for item in json_data["list"]]
440
- value_df = pd.DataFrame(value_list)
441
- value_df.columns = json_data["kinds"]
442
- value_df.index = pd.to_datetime(date_list)
443
- temp_df = value_df["今值(%)"]
444
- url = "https://datacenter-api.jin10.com/reports/list_v2"
445
272
  params = {
446
273
  "max_date": "",
447
274
  "category": "ec",
448
275
  "attr_id": "18",
449
276
  "_": str(int(round(t * 1000))),
450
277
  }
451
- headers = {
452
- "accept": "*/*",
453
- "accept-encoding": "gzip, deflate, br",
454
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
455
- "cache-control": "no-cache",
456
- "origin": "https://datacenter.jin10.com",
457
- "pragma": "no-cache",
458
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
459
- "sec-fetch-dest": "empty",
460
- "sec-fetch-mode": "cors",
461
- "sec-fetch-site": "same-site",
462
- "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",
463
- "x-app-id": "rU6QIu7JHe2gOUeR",
464
- "x-csrf-token": "",
465
- "x-version": "1.0.0",
466
- }
467
- r = requests.get(url, params=params, headers=headers)
468
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
469
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
470
- temp_se = temp_se.iloc[:, 1]
471
- temp_df = pd.concat([temp_df, temp_se])
472
- temp_df.dropna(inplace=True)
473
- temp_df.sort_index(inplace=True)
474
- temp_df = temp_df.reset_index()
475
- temp_df.drop_duplicates(subset="index", inplace=True)
476
- temp_df.set_index("index", inplace=True)
477
- temp_df = temp_df.squeeze()
478
- temp_df.index.name = None
479
- temp_df.name = "usa_import_price"
480
- temp_df = temp_df.astype("float")
278
+ temp_df = __macro_usa_base_func(symbol="美国进口物价指数", params=params)
481
279
  return temp_df
482
280
 
483
281
 
@@ -491,235 +289,68 @@ def macro_usa_export_price() -> pd.DataFrame:
491
289
  :rtype: pandas.Series
492
290
  """
493
291
  t = time.time()
494
- res = requests.get(
495
- f"https://cdn.jin10.com/dc/reports/dc_usa_export_price_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
496
- )
497
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
498
- date_list = [item["date"] for item in json_data["list"]]
499
- value_list = [item["datas"]["美国出口价格指数"] for item in json_data["list"]]
500
- value_df = pd.DataFrame(value_list)
501
- value_df.columns = json_data["kinds"]
502
- value_df.index = pd.to_datetime(date_list)
503
- temp_df = value_df["今值(%)"]
504
- url = "https://datacenter-api.jin10.com/reports/list_v2"
505
292
  params = {
506
293
  "max_date": "",
507
294
  "category": "ec",
508
295
  "attr_id": "79",
509
296
  "_": str(int(round(t * 1000))),
510
297
  }
511
- headers = {
512
- "accept": "*/*",
513
- "accept-encoding": "gzip, deflate, br",
514
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
515
- "cache-control": "no-cache",
516
- "origin": "https://datacenter.jin10.com",
517
- "pragma": "no-cache",
518
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
519
- "sec-fetch-dest": "empty",
520
- "sec-fetch-mode": "cors",
521
- "sec-fetch-site": "same-site",
522
- "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",
523
- "x-app-id": "rU6QIu7JHe2gOUeR",
524
- "x-csrf-token": "",
525
- "x-version": "1.0.0",
526
- }
527
- r = requests.get(url, params=params, headers=headers)
528
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
529
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
530
- temp_se = temp_se.iloc[:, 1]
531
- temp_df = pd.concat([temp_df, temp_se])
532
- temp_df.dropna(inplace=True)
533
- temp_df.sort_index(inplace=True)
534
- temp_df = temp_df.reset_index()
535
- temp_df.drop_duplicates(subset="index", inplace=True)
536
- temp_df.set_index("index", inplace=True)
537
- temp_df = temp_df.squeeze()
538
- temp_df.index.name = None
539
- temp_df.name = "usa_export_price"
540
- temp_df = temp_df.astype("float")
298
+ temp_df = __macro_usa_base_func(symbol="美国出口价格指数", params=params)
541
299
  return temp_df
542
300
 
543
301
 
544
302
  # 金十数据中心-经济指标-美国-劳动力市场-LMCI
545
303
  def macro_usa_lmci() -> pd.DataFrame:
546
304
  """
547
- 美联储劳动力市场状况指数报告, 数据区间从20141006-至今
305
+ 美联储劳动力市场状况指数报告, 数据区间从 20141006-至今
548
306
  https://datacenter.jin10.com/reportType/dc_usa_lmci
549
- https://cdn.jin10.com/dc/reports/dc_usa_lmci_all.js?v=1578742043
550
307
  :return: 美联储劳动力市场状况指数报告-今值(%)
551
308
  :rtype: pandas.Series
552
309
  """
553
310
  t = time.time()
554
- res = requests.get(
555
- JS_USA_LMCI_URL.format(
556
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
557
- )
558
- )
559
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
560
- date_list = [item["date"] for item in json_data["list"]]
561
- value_list = [item["datas"]["美联储劳动力市场状况指数"] for item in json_data["list"]]
562
- value_df = pd.DataFrame(value_list)
563
- value_df.columns = json_data["kinds"]
564
- value_df.index = pd.to_datetime(date_list)
565
- temp_df = value_df["今值(%)"]
566
- url = "https://datacenter-api.jin10.com/reports/list_v2"
567
311
  params = {
568
312
  "max_date": "",
569
313
  "category": "ec",
570
314
  "attr_id": "93",
571
315
  "_": str(int(round(t * 1000))),
572
316
  }
573
- headers = {
574
- "accept": "*/*",
575
- "accept-encoding": "gzip, deflate, br",
576
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
577
- "cache-control": "no-cache",
578
- "origin": "https://datacenter.jin10.com",
579
- "pragma": "no-cache",
580
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
581
- "sec-fetch-dest": "empty",
582
- "sec-fetch-mode": "cors",
583
- "sec-fetch-site": "same-site",
584
- "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",
585
- "x-app-id": "rU6QIu7JHe2gOUeR",
586
- "x-csrf-token": "",
587
- "x-version": "1.0.0",
588
- }
589
- r = requests.get(url, params=params, headers=headers)
590
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
591
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
592
- temp_se = temp_se.iloc[:, 1]
593
- temp_df = pd.concat([temp_df, temp_se])
594
- temp_df.dropna(inplace=True)
595
- temp_df.sort_index(inplace=True)
596
- temp_df = temp_df.reset_index()
597
- temp_df.drop_duplicates(subset="index", inplace=True)
598
- temp_df.set_index("index", inplace=True)
599
- temp_df = temp_df.squeeze()
600
- temp_df.index.name = None
601
- temp_df.name = "lmci"
602
- temp_df = temp_df.astype("float")
317
+ temp_df = __macro_usa_base_func(symbol="美联储劳动力市场状况指数", params=params)
603
318
  return temp_df
604
319
 
605
320
 
606
321
  # 金十数据中心-经济指标-美国-劳动力市场-失业率-美国失业率报告
607
322
  def macro_usa_unemployment_rate() -> pd.DataFrame:
608
323
  """
609
- 美国失业率报告, 数据区间从19700101-至今
324
+ 美国失业率报告, 数据区间从 19700101-至今
610
325
  https://datacenter.jin10.com/reportType/dc_usa_unemployment_rate
611
- https://cdn.jin10.com/dc/reports/dc_usa_unemployment_rate_all.js?v=1578821511
612
- :return: 获取美国失业率报告-今值(%)
326
+ :return: 获取美国失业率报告
613
327
  :rtype: pandas.Series
614
328
  """
615
329
  t = time.time()
616
- res = requests.get(
617
- JS_USA_UNEMPLOYMENT_RATE_URL.format(
618
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
619
- )
620
- )
621
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
622
- date_list = [item["date"] for item in json_data["list"]]
623
- value_list = [item["datas"]["美国失业率"] for item in json_data["list"]]
624
- value_df = pd.DataFrame(value_list)
625
- value_df.columns = json_data["kinds"]
626
- value_df.index = pd.to_datetime(date_list)
627
- temp_df = value_df["今值(%)"]
628
- url = "https://datacenter-api.jin10.com/reports/list_v2"
629
330
  params = {
630
331
  "category": "ec",
631
332
  "attr_id": "47",
632
333
  "_": str(int(round(t * 1000))),
633
334
  }
634
- headers = {
635
- "accept": "*/*",
636
- "accept-encoding": "gzip, deflate, br",
637
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
638
- "cache-control": "no-cache",
639
- "origin": "https://datacenter.jin10.com",
640
- "pragma": "no-cache",
641
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
642
- "sec-fetch-dest": "empty",
643
- "sec-fetch-mode": "cors",
644
- "sec-fetch-site": "same-site",
645
- "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",
646
- "x-app-id": "rU6QIu7JHe2gOUeR",
647
- "x-csrf-token": "",
648
- "x-version": "1.0.0",
649
- }
650
- r = requests.get(url, params=params, headers=headers)
651
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
652
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
653
- temp_se = temp_se.iloc[:, 1]
654
- temp_df = pd.concat([temp_df, temp_se])
655
- temp_df.dropna(inplace=True)
656
- temp_df.sort_index(inplace=True)
657
- temp_df = temp_df.reset_index()
658
- temp_df.drop_duplicates(subset="index", inplace=True)
659
- temp_df.set_index("index", inplace=True)
660
- temp_df = temp_df.squeeze()
661
- temp_df.index.name = None
662
- temp_df = temp_df.astype("float")
663
- temp_df.name = "unemployment_rate"
335
+ temp_df = __macro_usa_base_func(symbol="美国失业率", params=params)
664
336
  return temp_df
665
337
 
666
338
 
667
339
  # 金十数据中心-经济指标-美国-劳动力市场-失业率-美国挑战者企业裁员人数报告
668
340
  def macro_usa_job_cuts() -> pd.DataFrame:
669
341
  """
670
- 美国挑战者企业裁员人数报告, 数据区间从19940201-至今
342
+ 美国挑战者企业裁员人数报告, 数据区间从 19940201-至今
671
343
  https://datacenter.jin10.com/reportType/dc_usa_job_cuts
672
- https://cdn.jin10.com/dc/reports/dc_usa_job_cuts_all.js?v=1578742262
673
- :return: 美国挑战者企业裁员人数报告-今值(万人)
674
- :rtype: pandas.Series
344
+ :return: 美国挑战者企业裁员人数报告
345
+ :rtype: pandas.DataFrame
675
346
  """
676
347
  t = time.time()
677
- res = requests.get(
678
- f"https://cdn.jin10.com/dc/reports/dc_usa_job_cuts_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
679
- )
680
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
681
- date_list = [item["date"] for item in json_data["list"]]
682
- value_list = [item["datas"]["美国挑战者企业裁员人数报告"] for item in json_data["list"]]
683
- value_df = pd.DataFrame(value_list)
684
- value_df.columns = json_data["kinds"]
685
- value_df.index = pd.to_datetime(date_list)
686
- temp_df = value_df["今值(万人)"]
687
- url = "https://datacenter-api.jin10.com/reports/list_v2"
688
348
  params = {
689
349
  "category": "ec",
690
350
  "attr_id": "78",
691
351
  "_": str(int(round(t * 1000))),
692
352
  }
693
- headers = {
694
- "accept": "*/*",
695
- "accept-encoding": "gzip, deflate, br",
696
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
697
- "cache-control": "no-cache",
698
- "origin": "https://datacenter.jin10.com",
699
- "pragma": "no-cache",
700
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
701
- "sec-fetch-dest": "empty",
702
- "sec-fetch-mode": "cors",
703
- "sec-fetch-site": "same-site",
704
- "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",
705
- "x-app-id": "rU6QIu7JHe2gOUeR",
706
- "x-csrf-token": "",
707
- "x-version": "1.0.0",
708
- }
709
- r = requests.get(url, params=params, headers=headers)
710
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
711
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
712
- temp_se = temp_se.iloc[:, 1]
713
- temp_df = pd.concat([temp_df, temp_se])
714
- temp_df.dropna(inplace=True)
715
- temp_df.sort_index(inplace=True)
716
- temp_df = temp_df.reset_index()
717
- temp_df.drop_duplicates(subset="index", inplace=True)
718
- temp_df.set_index("index", inplace=True)
719
- temp_df = temp_df.squeeze()
720
- temp_df.index.name = None
721
- temp_df = temp_df.astype("float")
722
- temp_df.name = "usa_job_cuts"
353
+ temp_df = __macro_usa_base_func(symbol="美国挑战者企业裁员人数", params=params)
723
354
  return temp_df
724
355
 
725
356
 
@@ -728,374 +359,123 @@ def macro_usa_non_farm() -> pd.DataFrame:
728
359
  """
729
360
  美国非农就业人数报告, 数据区间从19700102-至今
730
361
  https://datacenter.jin10.com/reportType/dc_nonfarm_payrolls
731
- https://cdn.jin10.com/dc/reports/dc_nonfarm_payrolls_all.js?v=1578742490
732
- :return: 美国非农就业人数报告-今值(万人)
362
+ :return: 美国非农就业人数报告
733
363
  :rtype: pandas.Series
734
364
  """
735
365
  t = time.time()
736
- res = requests.get(
737
- JS_USA_NON_FARM_URL.format(
738
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
739
- )
740
- )
741
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
742
- date_list = [item["date"] for item in json_data["list"]]
743
- value_list = [item["datas"]["美国非农就业人数"] for item in json_data["list"]]
744
- value_df = pd.DataFrame(value_list)
745
- value_df.columns = json_data["kinds"]
746
- value_df.index = pd.to_datetime(date_list)
747
- temp_df = value_df["今值(万人)"]
748
- url = "https://datacenter-api.jin10.com/reports/list_v2"
749
366
  params = {
750
367
  "category": "ec",
751
368
  "attr_id": "33",
752
369
  "_": str(int(round(t * 1000))),
753
370
  }
754
- headers = {
755
- "accept": "*/*",
756
- "accept-encoding": "gzip, deflate, br",
757
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
758
- "cache-control": "no-cache",
759
- "origin": "https://datacenter.jin10.com",
760
- "pragma": "no-cache",
761
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
762
- "sec-fetch-dest": "empty",
763
- "sec-fetch-mode": "cors",
764
- "sec-fetch-site": "same-site",
765
- "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",
766
- "x-app-id": "rU6QIu7JHe2gOUeR",
767
- "x-csrf-token": "",
768
- "x-version": "1.0.0",
769
- }
770
- r = requests.get(url, params=params, headers=headers)
771
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
772
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
773
- temp_se = temp_se.iloc[:, 1]
774
- temp_df = pd.concat([temp_df, temp_se])
775
- temp_df.dropna(inplace=True)
776
- temp_df.sort_index(inplace=True)
777
- temp_df = temp_df.reset_index()
778
- temp_df.drop_duplicates(subset="index", inplace=True)
779
- temp_df.set_index("index", inplace=True)
780
- temp_df = temp_df.squeeze()
781
- temp_df.index.name = None
782
- temp_df = temp_df.astype("float")
783
- temp_df.name = "non_farm"
371
+ temp_df = __macro_usa_base_func(symbol="美国非农就业人数", params=params)
784
372
  return temp_df
785
373
 
786
374
 
787
375
  # 金十数据中心-经济指标-美国-劳动力市场-就业人口-美国ADP就业人数报告
788
376
  def macro_usa_adp_employment() -> pd.DataFrame:
789
377
  """
790
- 美国ADP就业人数报告, 数据区间从20010601-至今
378
+ 美国ADP就业人数报告, 数据区间从 20010601-至今
791
379
  https://datacenter.jin10.com/reportType/dc_adp_nonfarm_employment
792
- https://cdn.jin10.com/dc/reports/dc_adp_nonfarm_employment_all.js?v=1578742564
793
- :return: 美国ADP就业人数报告-今值(万人)
380
+ :return: 美国ADP就业人数报告
794
381
  :rtype: pandas.Series
795
382
  """
796
383
  t = time.time()
797
- res = requests.get(
798
- JS_USA_ADP_NONFARM_URL.format(
799
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
800
- )
801
- )
802
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
803
- date_list = [item["date"] for item in json_data["list"]]
804
- value_list = [item["datas"]["美国ADP就业人数(万人)"] for item in json_data["list"]]
805
- value_df = pd.DataFrame(value_list)
806
- value_df.columns = json_data["kinds"]
807
- value_df.index = pd.to_datetime(date_list)
808
- temp_df = value_df["今值(万人)"]
809
- url = "https://datacenter-api.jin10.com/reports/list_v2"
810
384
  params = {
811
385
  "category": "ec",
812
386
  "attr_id": "1",
813
387
  "_": str(int(round(t * 1000))),
814
388
  }
815
- headers = {
816
- "accept": "*/*",
817
- "accept-encoding": "gzip, deflate, br",
818
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
819
- "cache-control": "no-cache",
820
- "origin": "https://datacenter.jin10.com",
821
- "pragma": "no-cache",
822
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
823
- "sec-fetch-dest": "empty",
824
- "sec-fetch-mode": "cors",
825
- "sec-fetch-site": "same-site",
826
- "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",
827
- "x-app-id": "rU6QIu7JHe2gOUeR",
828
- "x-csrf-token": "",
829
- "x-version": "1.0.0",
830
- }
831
- r = requests.get(url, params=params, headers=headers)
832
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
833
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
834
- temp_se = temp_se.iloc[:, 1]
835
- temp_df = pd.concat([temp_df, temp_se])
836
- temp_df.dropna(inplace=True)
837
- temp_df.sort_index(inplace=True)
838
- temp_df = temp_df.reset_index()
839
- temp_df.drop_duplicates(subset="index", inplace=True)
840
- temp_df.set_index("index", inplace=True)
841
- temp_df = temp_df.squeeze()
842
- temp_df.index.name = None
843
- temp_df = temp_df.astype("float")
844
- temp_df.name = "adp"
389
+ temp_df = __macro_usa_base_func(symbol="美国ADP就业人数", params=params)
845
390
  return temp_df
846
391
 
847
392
 
848
393
  # 金十数据中心-经济指标-美国-劳动力市场-消费者收入与支出-美国核心PCE物价指数年率报告
849
394
  def macro_usa_core_pce_price() -> pd.DataFrame:
850
395
  """
851
- 美国核心PCE物价指数年率报告, 数据区间从19700101-至今
396
+ 美国核心PCE物价指数年率报告, 数据区间从 19700101-至今
852
397
  https://datacenter.jin10.com/reportType/dc_usa_core_pce_price
853
- https://cdn.jin10.com/dc/reports/dc_usa_core_pce_price_all.js?v=1578742641
854
- :return: 美国核心PCE物价指数年率报告-今值(%)
855
- :rtype: pandas.Series
398
+ :return: 美国核心PCE物价指数年率报告
399
+ :rtype: pandas.DataFrame
856
400
  """
857
401
  t = time.time()
858
- res = requests.get(
859
- JS_USA_CORE_PCE_PRICE_URL.format(
860
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
861
- )
862
- )
863
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
864
- date_list = [item["date"] for item in json_data["list"]]
865
- value_list = [item["datas"]["美国核心PCE物价指数年率"] for item in json_data["list"]]
866
- value_df = pd.DataFrame(value_list)
867
- value_df.columns = json_data["kinds"]
868
- value_df.index = pd.to_datetime(date_list)
869
- temp_df = value_df["今值(%)"]
870
- url = "https://datacenter-api.jin10.com/reports/list_v2"
871
402
  params = {
872
403
  "category": "ec",
873
404
  "attr_id": "80",
874
405
  "_": str(int(round(t * 1000))),
875
406
  }
876
- headers = {
877
- "accept": "*/*",
878
- "accept-encoding": "gzip, deflate, br",
879
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
880
- "cache-control": "no-cache",
881
- "origin": "https://datacenter.jin10.com",
882
- "pragma": "no-cache",
883
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
884
- "sec-fetch-dest": "empty",
885
- "sec-fetch-mode": "cors",
886
- "sec-fetch-site": "same-site",
887
- "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",
888
- "x-app-id": "rU6QIu7JHe2gOUeR",
889
- "x-csrf-token": "",
890
- "x-version": "1.0.0",
891
- }
892
- r = requests.get(url, params=params, headers=headers)
893
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
894
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
895
- temp_se = temp_se.iloc[:, 1]
896
- temp_df = pd.concat([temp_df, temp_se])
897
- temp_df.dropna(inplace=True)
898
- temp_df.sort_index(inplace=True)
899
- temp_df = temp_df.reset_index()
900
- temp_df.drop_duplicates(subset="index", inplace=True)
901
- temp_df.set_index("index", inplace=True)
902
- temp_df = temp_df.squeeze()
903
- temp_df.index.name = None
904
- temp_df = temp_df.astype("float")
905
- temp_df.name = "core_pce_price"
407
+ temp_df = __macro_usa_base_func(symbol="美国核心PCE物价指数年率", params=params)
906
408
  return temp_df
907
409
 
908
410
 
909
411
  # 金十数据中心-经济指标-美国-劳动力市场-消费者收入与支出-美国实际个人消费支出季率初值报告
910
412
  def macro_usa_real_consumer_spending() -> pd.DataFrame:
911
413
  """
912
- 美国实际个人消费支出季率初值报告, 数据区间从20131107-至今
414
+ 美国实际个人消费支出季率初值报告, 数据区间从 20131107-至今
913
415
  https://datacenter.jin10.com/reportType/dc_usa_real_consumer_spending
914
- https://cdn.jin10.com/dc/reports/dc_usa_real_consumer_spending_all.js?v=1578742802
915
- :return: 美国实际个人消费支出季率初值报告-今值(%)
916
- :rtype: pandas.Series
416
+ :return: 美国实际个人消费支出季率初值报告
417
+ :rtype: pandas.DataFrame
917
418
  """
918
419
  t = time.time()
919
- res = requests.get(
920
- f"https://cdn.jin10.com/dc/reports/dc_usa_real_consumer_spending_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
921
- )
922
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
923
- date_list = [item["date"] for item in json_data["list"]]
924
- value_list = [item["datas"]["美国实际个人消费支出季率初值报告"] for item in json_data["list"]]
925
- value_df = pd.DataFrame(value_list)
926
- value_df.columns = json_data["kinds"]
927
- value_df.index = pd.to_datetime(date_list)
928
- temp_df = value_df["今值(%)"]
929
- url = "https://datacenter-api.jin10.com/reports/list_v2"
930
420
  params = {
931
421
  "category": "ec",
932
422
  "attr_id": "81",
933
423
  "_": str(int(round(t * 1000))),
934
424
  }
935
- headers = {
936
- "accept": "*/*",
937
- "accept-encoding": "gzip, deflate, br",
938
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
939
- "cache-control": "no-cache",
940
- "origin": "https://datacenter.jin10.com",
941
- "pragma": "no-cache",
942
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
943
- "sec-fetch-dest": "empty",
944
- "sec-fetch-mode": "cors",
945
- "sec-fetch-site": "same-site",
946
- "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",
947
- "x-app-id": "rU6QIu7JHe2gOUeR",
948
- "x-csrf-token": "",
949
- "x-version": "1.0.0",
950
- }
951
- r = requests.get(url, params=params, headers=headers)
952
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
953
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
954
- temp_se = temp_se.iloc[:, 1]
955
- temp_df = pd.concat([temp_df, temp_se])
956
- temp_df.dropna(inplace=True)
957
- temp_df.sort_index(inplace=True)
958
- temp_df = temp_df.reset_index()
959
- temp_df.drop_duplicates(subset="index", inplace=True)
960
- temp_df.set_index("index", inplace=True)
961
- temp_df = temp_df.squeeze()
962
- temp_df.index.name = None
963
- temp_df = temp_df.astype("float")
964
- temp_df.name = "usa_real_consumer_spending"
425
+ temp_df = __macro_usa_base_func(
426
+ symbol="美国实际个人消费支出季率初值", params=params
427
+ )
965
428
  return temp_df
966
429
 
967
430
 
968
431
  # 金十数据中心-经济指标-美国-贸易状况-美国贸易帐报告
969
432
  def macro_usa_trade_balance() -> pd.DataFrame:
970
433
  """
971
- 美国贸易帐报告, 数据区间从19700101-至今
434
+ 美国贸易帐报告, 数据区间从 19700101-至今
972
435
  https://datacenter.jin10.com/reportType/dc_usa_trade_balance
973
- https://cdn.jin10.com/dc/reports/dc_usa_trade_balance_all.js?v=1578742911
974
- :return: 美国贸易帐报告-今值(亿美元)
975
- :rtype: pandas.Series
436
+ :return: 美国贸易帐报告
437
+ :rtype: pandas.DataFrame
976
438
  """
977
439
  t = time.time()
978
- res = requests.get(
979
- f"https://cdn.jin10.com/dc/reports/dc_usa_trade_balance_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
980
- )
981
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
982
- date_list = [item["date"] for item in json_data["list"]]
983
- value_list = [item["datas"]["美国贸易帐报告"] for item in json_data["list"]]
984
- value_df = pd.DataFrame(value_list)
985
- value_df.columns = json_data["kinds"]
986
- value_df.index = pd.to_datetime(date_list)
987
- temp_df = value_df["今值(亿美元)"]
988
- url = "https://datacenter-api.jin10.com/reports/list_v2"
989
440
  params = {
990
441
  "category": "ec",
991
442
  "attr_id": "42",
992
443
  "_": str(int(round(t * 1000))),
993
444
  }
994
- headers = {
995
- "accept": "*/*",
996
- "accept-encoding": "gzip, deflate, br",
997
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
998
- "cache-control": "no-cache",
999
- "origin": "https://datacenter.jin10.com",
1000
- "pragma": "no-cache",
1001
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1002
- "sec-fetch-dest": "empty",
1003
- "sec-fetch-mode": "cors",
1004
- "sec-fetch-site": "same-site",
1005
- "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",
1006
- "x-app-id": "rU6QIu7JHe2gOUeR",
1007
- "x-csrf-token": "",
1008
- "x-version": "1.0.0",
1009
- }
1010
- r = requests.get(url, params=params, headers=headers)
1011
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1012
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1013
- temp_se = temp_se.iloc[:, 1]
1014
- temp_df = pd.concat([temp_df, temp_se])
1015
- temp_df.dropna(inplace=True)
1016
- temp_df.sort_index(inplace=True)
1017
- temp_df = temp_df.reset_index()
1018
- temp_df.drop_duplicates(subset="index", inplace=True)
1019
- temp_df.set_index("index", inplace=True)
1020
- temp_df = temp_df.squeeze()
1021
- temp_df.index.name = None
1022
- temp_df = temp_df.astype("float")
1023
- temp_df.name = "usa_trade_balance"
445
+ temp_df = __macro_usa_base_func(symbol="美国贸易帐报告", params=params)
1024
446
  return temp_df
1025
447
 
1026
448
 
1027
449
  # 金十数据中心-经济指标-美国-贸易状况-美国经常帐报告
1028
450
  def macro_usa_current_account() -> pd.DataFrame:
1029
451
  """
1030
- 美国经常帐报告, 数据区间从20080317-至今
452
+ 美国经常帐报告, 数据区间从 20080317-至今
1031
453
  https://datacenter.jin10.com/reportType/dc_usa_current_account
1032
- https://cdn.jin10.com/dc/reports/dc_usa_current_account_all.js?v=1578743012
1033
- :return: 美国经常帐报告-今值(亿美元)
1034
- :rtype: pandas.Series
454
+ :return: 美国经常帐报告
455
+ :rtype: pandas.DataFrame
1035
456
  """
1036
457
  t = time.time()
1037
- res = requests.get(
1038
- f"https://cdn.jin10.com/dc/reports/dc_usa_current_account_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1039
- )
1040
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1041
- date_list = [item["date"] for item in json_data["list"]]
1042
- value_list = [item["datas"]["美国经常账报告"] for item in json_data["list"]]
1043
- value_df = pd.DataFrame(value_list)
1044
- value_df.columns = json_data["kinds"]
1045
- value_df.index = pd.to_datetime(date_list)
1046
- temp_df = value_df["今值(亿美元)"]
1047
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1048
458
  params = {
1049
459
  "category": "ec",
1050
460
  "attr_id": "12",
1051
461
  "_": str(int(round(t * 1000))),
1052
462
  }
1053
- headers = {
1054
- "accept": "*/*",
1055
- "accept-encoding": "gzip, deflate, br",
1056
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1057
- "cache-control": "no-cache",
1058
- "origin": "https://datacenter.jin10.com",
1059
- "pragma": "no-cache",
1060
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1061
- "sec-fetch-dest": "empty",
1062
- "sec-fetch-mode": "cors",
1063
- "sec-fetch-site": "same-site",
1064
- "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",
1065
- "x-app-id": "rU6QIu7JHe2gOUeR",
1066
- "x-csrf-token": "",
1067
- "x-version": "1.0.0",
1068
- }
1069
- r = requests.get(url, params=params, headers=headers)
1070
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1071
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1072
- temp_se = temp_se.iloc[:, 1]
1073
- temp_df = pd.concat([temp_df, temp_se])
1074
- temp_df.dropna(inplace=True)
1075
- temp_df.sort_index(inplace=True)
1076
- temp_df = temp_df.reset_index()
1077
- temp_df.drop_duplicates(subset="index", inplace=True)
1078
- temp_df.set_index("index", inplace=True)
1079
- temp_df = temp_df.squeeze()
1080
- temp_df.index.name = None
1081
- temp_df = temp_df.astype("float")
1082
- temp_df.name = "usa_current_account"
463
+ temp_df = __macro_usa_base_func(symbol="美国经常账报告", params=params)
1083
464
  return temp_df
1084
465
 
1085
466
 
1086
467
  # 金十数据中心-经济指标-美国-产业指标-制造业-贝克休斯钻井报告
1087
468
  def macro_usa_rig_count() -> pd.DataFrame:
1088
469
  """
1089
- 贝克休斯钻井报告, 数据区间从20080317-至今
470
+ 贝克休斯钻井报告, 数据区间从 20080317-至今
1090
471
  https://datacenter.jin10.com/reportType/dc_rig_count_summary
1091
- https://cdn.jin10.com/dc/reports/dc_rig_count_summary_all.js?v=1578743203
1092
472
  :return: 贝克休斯钻井报告-当周
1093
- :rtype: pandas.Series
473
+ :rtype: pandas.DataFrame
1094
474
  """
1095
475
  t = time.time()
1096
476
  params = {"_": t}
1097
477
  res = requests.get(
1098
- "https://cdn.jin10.com/data_center/reports/baker.json", params=params
478
+ url="https://cdn.jin10.com/data_center/reports/baker.json", params=params
1099
479
  )
1100
480
  temp_df = pd.DataFrame(res.json().get("values")).T
1101
481
  big_df = pd.DataFrame()
@@ -1108,69 +488,28 @@ def macro_usa_rig_count() -> pd.DataFrame:
1108
488
  big_df["美国天然气钻井_钻井数"] = temp_df["美国天然气钻井"].apply(lambda x: x[0])
1109
489
  big_df["美国天然气钻井_变化"] = temp_df["美国天然气钻井"].apply(lambda x: x[1])
1110
490
  big_df = big_df.astype("float")
491
+ big_df.reset_index(inplace=True)
492
+ big_df.rename(columns={"index": "日期"}, inplace=True)
493
+ big_df.sort_values(by=["日期"], inplace=True, ignore_index=True)
1111
494
  return big_df
1112
495
 
1113
496
 
1114
- # 金十数据中心-经济指标-美国-产业指标-制造业-美国个人支出月率报告
1115
-
1116
-
1117
497
  # 金十数据中心-经济指标-美国-产业指标-制造业-美国生产者物价指数(PPI)报告
1118
498
  def macro_usa_ppi() -> pd.DataFrame:
1119
499
  """
1120
- 美国生产者物价指数(PPI)报告, 数据区间从20080226-至今
500
+ 美国生产者物价指数(PPI)报告, 数据区间从 20080226-至今
1121
501
  https://datacenter.jin10.com/reportType/dc_usa_ppi
1122
- https://cdn.jin10.com/dc/reports/dc_usa_ppi_all.js?v=1578743628
1123
- :return: 美国生产者物价指数(PPI)报告-今值(%)
1124
- :rtype: pandas.Series
502
+ :return: 美国生产者物价指数(PPI)报告
503
+ :rtype: pandas.DataFrame
1125
504
  """
1126
505
  t = time.time()
1127
- res = requests.get(
1128
- f"https://cdn.jin10.com/dc/reports/dc_usa_ppi_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1129
- )
1130
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1131
- date_list = [item["date"] for item in json_data["list"]]
1132
- value_list = [item["datas"]["美国生产者物价指数(PPI)报告"] for item in json_data["list"]]
1133
- value_df = pd.DataFrame(value_list)
1134
- value_df.columns = json_data["kinds"]
1135
- value_df.index = pd.to_datetime(date_list)
1136
- temp_df = value_df["今值(%)"]
1137
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1138
506
  params = {
1139
507
  "max_date": "",
1140
508
  "category": "ec",
1141
509
  "attr_id": "37",
1142
510
  "_": str(int(round(t * 1000))),
1143
511
  }
1144
- headers = {
1145
- "accept": "*/*",
1146
- "accept-encoding": "gzip, deflate, br",
1147
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1148
- "cache-control": "no-cache",
1149
- "origin": "https://datacenter.jin10.com",
1150
- "pragma": "no-cache",
1151
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1152
- "sec-fetch-dest": "empty",
1153
- "sec-fetch-mode": "cors",
1154
- "sec-fetch-site": "same-site",
1155
- "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",
1156
- "x-app-id": "rU6QIu7JHe2gOUeR",
1157
- "x-csrf-token": "",
1158
- "x-version": "1.0.0",
1159
- }
1160
- r = requests.get(url, params=params, headers=headers)
1161
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1162
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1163
- temp_se = temp_se.iloc[:, 1]
1164
- temp_df = pd.concat([temp_df, temp_se])
1165
- temp_df.dropna(inplace=True)
1166
- temp_df.sort_index(inplace=True)
1167
- temp_df = temp_df.reset_index()
1168
- temp_df.drop_duplicates(subset="index", inplace=True)
1169
- temp_df.set_index("index", inplace=True)
1170
- temp_df = temp_df.squeeze()
1171
- temp_df.index.name = None
1172
- temp_df.name = "usa_ppi"
1173
- temp_df = temp_df.astype("float")
512
+ temp_df = __macro_usa_base_func(symbol="美国生产者物价指数", params=params)
1174
513
  return temp_df
1175
514
 
1176
515
 
@@ -1179,1078 +518,345 @@ def macro_usa_core_ppi() -> pd.DataFrame:
1179
518
  """
1180
519
  美国核心生产者物价指数(PPI)报告, 数据区间从20080318-至今
1181
520
  https://datacenter.jin10.com/reportType/dc_usa_core_ppi
1182
- https://cdn.jin10.com/dc/reports/dc_usa_core_ppi_all.js?v=1578743709
1183
521
  :return: 美国核心生产者物价指数(PPI)报告-今值(%)
1184
- :rtype: pandas.Series
522
+ :rtype: pandas.DataFrame
1185
523
  """
1186
524
  t = time.time()
1187
- res = requests.get(
1188
- f"https://cdn.jin10.com/dc/reports/dc_usa_core_ppi_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1189
- )
1190
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1191
- date_list = [item["date"] for item in json_data["list"]]
1192
- value_list = [item["datas"]["美国核心生产者物价指数(PPI)报告"] for item in json_data["list"]]
1193
- value_df = pd.DataFrame(value_list)
1194
- value_df.columns = json_data["kinds"]
1195
- value_df.index = pd.to_datetime(date_list)
1196
- temp_df = value_df["今值(%)"]
1197
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1198
525
  params = {
1199
526
  "max_date": "",
1200
527
  "category": "ec",
1201
528
  "attr_id": "7",
1202
529
  "_": str(int(round(t * 1000))),
1203
530
  }
1204
- headers = {
1205
- "accept": "*/*",
1206
- "accept-encoding": "gzip, deflate, br",
1207
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1208
- "cache-control": "no-cache",
1209
- "origin": "https://datacenter.jin10.com",
1210
- "pragma": "no-cache",
1211
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1212
- "sec-fetch-dest": "empty",
1213
- "sec-fetch-mode": "cors",
1214
- "sec-fetch-site": "same-site",
1215
- "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",
1216
- "x-app-id": "rU6QIu7JHe2gOUeR",
1217
- "x-csrf-token": "",
1218
- "x-version": "1.0.0",
1219
- }
1220
- r = requests.get(url, params=params, headers=headers)
1221
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1222
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1223
- temp_se = temp_se.iloc[:, 1]
1224
- temp_df = pd.concat([temp_df, temp_se])
1225
- temp_df.dropna(inplace=True)
1226
- temp_df.sort_index(inplace=True)
1227
- temp_df = temp_df.reset_index()
1228
- temp_df.drop_duplicates(subset="index", inplace=True)
1229
- temp_df.set_index("index", inplace=True)
1230
- temp_df = temp_df.squeeze()
1231
- temp_df.index.name = None
1232
- temp_df.name = "usa_core_ppi"
1233
- temp_df = temp_df.astype("float")
531
+ temp_df = __macro_usa_base_func(symbol="美国核心生产者物价指数", params=params)
1234
532
  return temp_df
1235
533
 
1236
534
 
1237
535
  # 金十数据中心-经济指标-美国-产业指标-制造业-美国API原油库存报告
1238
536
  def macro_usa_api_crude_stock() -> pd.DataFrame:
1239
537
  """
1240
- 美国API原油库存报告, 数据区间从20120328-至今
538
+ 美国 API 原油库存报告, 数据区间从 20120328-至今
1241
539
  https://datacenter.jin10.com/reportType/dc_usa_api_crude_stock
1242
540
  https://cdn.jin10.com/dc/reports/dc_usa_api_crude_stock_all.js?v=1578743859
1243
541
  :return: 美国API原油库存报告-今值(万桶)
1244
542
  :rtype: pandas.Series
1245
543
  """
1246
544
  t = time.time()
1247
- res = requests.get(
1248
- f"https://cdn.jin10.com/dc/reports/dc_usa_api_crude_stock_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1249
- )
1250
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1251
- date_list = [item["date"] for item in json_data["list"]]
1252
- value_list = [item["datas"]["美国API原油库存报告"] for item in json_data["list"]]
1253
- value_df = pd.DataFrame(value_list)
1254
- value_df.columns = json_data["kinds"]
1255
- value_df.index = pd.to_datetime(date_list)
1256
- temp_df = value_df["今值(万桶)"]
1257
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1258
545
  params = {
1259
546
  "max_date": "",
1260
547
  "category": "ec",
1261
548
  "attr_id": "69",
1262
549
  "_": str(int(round(t * 1000))),
1263
550
  }
1264
- headers = {
1265
- "accept": "*/*",
1266
- "accept-encoding": "gzip, deflate, br",
1267
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1268
- "cache-control": "no-cache",
1269
- "origin": "https://datacenter.jin10.com",
1270
- "pragma": "no-cache",
1271
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1272
- "sec-fetch-dest": "empty",
1273
- "sec-fetch-mode": "cors",
1274
- "sec-fetch-site": "same-site",
1275
- "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",
1276
- "x-app-id": "rU6QIu7JHe2gOUeR",
1277
- "x-csrf-token": "",
1278
- "x-version": "1.0.0",
1279
- }
1280
- r = requests.get(url, params=params, headers=headers)
1281
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1282
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1283
- temp_se = temp_se.iloc[:, 1]
1284
- temp_df = pd.concat([temp_df, temp_se])
1285
- temp_df.dropna(inplace=True)
1286
- temp_df.sort_index(inplace=True)
1287
- temp_df = temp_df.reset_index()
1288
- temp_df.drop_duplicates(subset="index", inplace=True)
1289
- temp_df.set_index("index", inplace=True)
1290
- temp_df = temp_df.squeeze()
1291
- temp_df.index.name = None
1292
- temp_df.name = "usa_api_crude_stock"
1293
- temp_df = temp_df.astype("float")
551
+ temp_df = __macro_usa_base_func(symbol="美国API原油库存", params=params)
1294
552
  return temp_df
1295
553
 
1296
554
 
1297
555
  # 金十数据中心-经济指标-美国-产业指标-制造业-美国Markit制造业PMI初值报告
1298
- def macro_usa_pmi() -> pd.Series:
556
+ def macro_usa_pmi() -> pd.DataFrame:
1299
557
  """
1300
- 美国Markit制造业PMI初值报告, 数据区间从20120601-至今
558
+ 美国 Markit 制造业 PMI 初值报告, 数据区间从 20120601-至今
1301
559
  https://datacenter.jin10.com/reportType/dc_usa_pmi
1302
- https://cdn.jin10.com/dc/reports/dc_usa_pmi_all.js?v=1578743969
1303
- :return: 美国Markit制造业PMI初值报告-今值
1304
- :rtype: pandas.Series
560
+ :return: 美国 Markit 制造业 PMI 初值报告
561
+ :rtype: pandas.DataFrame
1305
562
  """
1306
563
  t = time.time()
1307
- res = requests.get(
1308
- f"https://cdn.jin10.com/dc/reports/dc_usa_pmi_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1309
- )
1310
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1311
- date_list = [item["date"] for item in json_data["list"]]
1312
- value_list = [item["datas"]["美国Markit制造业PMI报告"] for item in json_data["list"]]
1313
- value_df = pd.DataFrame(value_list)
1314
- value_df.columns = json_data["kinds"]
1315
- value_df.index = pd.to_datetime(date_list)
1316
- temp_df = value_df["今值"]
1317
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1318
564
  params = {
1319
565
  "max_date": "",
1320
566
  "category": "ec",
1321
567
  "attr_id": "74",
1322
568
  "_": str(int(round(t * 1000))),
1323
569
  }
1324
- headers = {
1325
- "accept": "*/*",
1326
- "accept-encoding": "gzip, deflate, br",
1327
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1328
- "cache-control": "no-cache",
1329
- "origin": "https://datacenter.jin10.com",
1330
- "pragma": "no-cache",
1331
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1332
- "sec-fetch-dest": "empty",
1333
- "sec-fetch-mode": "cors",
1334
- "sec-fetch-site": "same-site",
1335
- "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",
1336
- "x-app-id": "rU6QIu7JHe2gOUeR",
1337
- "x-csrf-token": "",
1338
- "x-version": "1.0.0",
1339
- }
1340
- r = requests.get(url, params=params, headers=headers)
1341
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1342
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1343
- temp_se = temp_se.iloc[:, 1]
1344
- temp_df = pd.concat([temp_df, temp_se])
1345
- temp_df.dropna(inplace=True)
1346
- temp_df.sort_index(inplace=True)
1347
- temp_df = temp_df.reset_index()
1348
- temp_df.drop_duplicates(subset="index", inplace=True)
1349
- temp_df.set_index("index", inplace=True)
1350
- temp_df = temp_df.squeeze()
1351
- temp_df.index.name = None
1352
- temp_df.name = "usa_pmi"
1353
- temp_df = temp_df.astype("float")
570
+ temp_df = __macro_usa_base_func(symbol="美国Markit制造业PMI报告", params=params)
1354
571
  return temp_df
1355
572
 
1356
573
 
1357
574
  # 金十数据中心-经济指标-美国-产业指标-制造业-美国ISM制造业PMI报告
1358
575
  def macro_usa_ism_pmi() -> pd.DataFrame:
1359
576
  """
1360
- 美国ISM制造业PMI报告, 数据区间从19700101-至今
577
+ 美国 ISM 制造业 PMI 报告, 数据区间从 19700101-至今
1361
578
  https://datacenter.jin10.com/reportType/dc_usa_ism_pmi
1362
- https://cdn.jin10.com/dc/reports/dc_usa_ism_pmi_all.js?v=1578744071
1363
- :return: 美国ISM制造业PMI报告-今值
1364
- :rtype: pandas.Series
579
+ :return: 美国 ISM 制造业 PMI 报告-今值
580
+ :rtype: pandas.DataFrame
1365
581
  """
1366
582
  t = time.time()
1367
- res = requests.get(
1368
- f"https://cdn.jin10.com/dc/reports/dc_usa_ism_pmi_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1369
- )
1370
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1371
- date_list = [item["date"] for item in json_data["list"]]
1372
- value_list = [item["datas"]["美国ISM制造业PMI报告"] for item in json_data["list"]]
1373
- value_df = pd.DataFrame(value_list)
1374
- value_df.columns = json_data["kinds"]
1375
- value_df.index = pd.to_datetime(date_list)
1376
- temp_df = value_df["今值"]
1377
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1378
583
  params = {
1379
584
  "max_date": "",
1380
585
  "category": "ec",
1381
586
  "attr_id": "28",
1382
587
  "_": str(int(round(t * 1000))),
1383
588
  }
1384
- headers = {
1385
- "accept": "*/*",
1386
- "accept-encoding": "gzip, deflate, br",
1387
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1388
- "cache-control": "no-cache",
1389
- "origin": "https://datacenter.jin10.com",
1390
- "pragma": "no-cache",
1391
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1392
- "sec-fetch-dest": "empty",
1393
- "sec-fetch-mode": "cors",
1394
- "sec-fetch-site": "same-site",
1395
- "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",
1396
- "x-app-id": "rU6QIu7JHe2gOUeR",
1397
- "x-csrf-token": "",
1398
- "x-version": "1.0.0",
1399
- }
1400
- r = requests.get(url, params=params, headers=headers)
1401
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1402
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1403
- temp_se = temp_se.iloc[:, 1]
1404
- temp_df = pd.concat([temp_df, temp_se])
1405
- temp_df.dropna(inplace=True)
1406
- temp_df.sort_index(inplace=True)
1407
- temp_df = temp_df.reset_index()
1408
- temp_df.drop_duplicates(subset="index", inplace=True)
1409
- temp_df.set_index("index", inplace=True)
1410
- temp_df = temp_df.squeeze()
1411
- temp_df.index.name = None
1412
- temp_df.name = "usa_ism_pmi"
1413
- temp_df = temp_df.astype("float")
589
+ temp_df = __macro_usa_base_func(symbol="美国ISM制造业PMI报告", params=params)
1414
590
  return temp_df
1415
591
 
1416
592
 
1417
593
  # 金十数据中心-经济指标-美国-产业指标-工业-美国工业产出月率报告
1418
594
  def macro_usa_industrial_production() -> pd.DataFrame:
1419
595
  """
1420
- 美国工业产出月率报告, 数据区间从19700101-至今
596
+ 美国工业产出月率报告, 数据区间从 19700101-至今
1421
597
  https://datacenter.jin10.com/reportType/dc_usa_industrial_production
1422
- https://cdn.jin10.com/dc/reports/dc_usa_industrial_production_all.js?v=1578744188
1423
598
  :return: 美国工业产出月率报告-今值(%)
1424
- :rtype: pandas.Series
599
+ :rtype: pandas.DataFrame
1425
600
  """
1426
601
  t = time.time()
1427
- res = requests.get(
1428
- f"https://cdn.jin10.com/dc/reports/dc_usa_industrial_production_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1429
- )
1430
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1431
- date_list = [item["date"] for item in json_data["list"]]
1432
- value_list = [item["datas"]["美国工业产出月率报告"] for item in json_data["list"]]
1433
- value_df = pd.DataFrame(value_list)
1434
- value_df.columns = json_data["kinds"]
1435
- value_df.index = pd.to_datetime(date_list)
1436
- temp_df = value_df["今值(%)"]
1437
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1438
602
  params = {
1439
603
  "max_date": "",
1440
604
  "category": "ec",
1441
605
  "attr_id": "20",
1442
606
  "_": str(int(round(t * 1000))),
1443
607
  }
1444
- headers = {
1445
- "accept": "*/*",
1446
- "accept-encoding": "gzip, deflate, br",
1447
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1448
- "cache-control": "no-cache",
1449
- "origin": "https://datacenter.jin10.com",
1450
- "pragma": "no-cache",
1451
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1452
- "sec-fetch-dest": "empty",
1453
- "sec-fetch-mode": "cors",
1454
- "sec-fetch-site": "same-site",
1455
- "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",
1456
- "x-app-id": "rU6QIu7JHe2gOUeR",
1457
- "x-csrf-token": "",
1458
- "x-version": "1.0.0",
1459
- }
1460
- r = requests.get(url, params=params, headers=headers)
1461
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1462
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1463
- temp_se = temp_se.iloc[:, 1]
1464
- temp_df = pd.concat([temp_df, temp_se])
1465
- temp_df.dropna(inplace=True)
1466
- temp_df.sort_index(inplace=True)
1467
- temp_df = temp_df.reset_index()
1468
- temp_df.drop_duplicates(subset="index", inplace=True)
1469
- temp_df.set_index("index", inplace=True)
1470
- temp_df = temp_df.squeeze()
1471
- temp_df.index.name = None
1472
- temp_df.name = "usa_industrial_production"
1473
- temp_df = temp_df.astype("float")
608
+ temp_df = __macro_usa_base_func(symbol="美国工业产出月率报告", params=params)
1474
609
  return temp_df
1475
610
 
1476
611
 
1477
612
  # 金十数据中心-经济指标-美国-产业指标-工业-美国耐用品订单月率报告
1478
613
  def macro_usa_durable_goods_orders() -> pd.DataFrame:
1479
614
  """
1480
- 美国耐用品订单月率报告, 数据区间从20080227-至今
615
+ 美国耐用品订单月率报告, 数据区间从 20080227-至今
1481
616
  https://datacenter.jin10.com/reportType/dc_usa_durable_goods_orders
1482
- https://cdn.jin10.com/dc/reports/dc_usa_durable_goods_orders_all.js?v=1578744295
1483
- :return: 美国耐用品订单月率报告-今值(%)
1484
- :rtype: pandas.Series
617
+ :return: 美国耐用品订单月率报告
618
+ :rtype: pandas.DataFrame
1485
619
  """
1486
620
  t = time.time()
1487
- res = requests.get(
1488
- f"https://cdn.jin10.com/dc/reports/dc_usa_durable_goods_orders_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1489
- )
1490
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1491
- date_list = [item["date"] for item in json_data["list"]]
1492
- value_list = [item["datas"]["美国耐用品订单月率报告"] for item in json_data["list"]]
1493
- value_df = pd.DataFrame(value_list)
1494
- value_df.columns = json_data["kinds"]
1495
- value_df.index = pd.to_datetime(date_list)
1496
- temp_df = value_df["今值(%)"]
1497
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1498
621
  params = {
1499
622
  "max_date": "",
1500
623
  "category": "ec",
1501
624
  "attr_id": "13",
1502
625
  "_": str(int(round(t * 1000))),
1503
626
  }
1504
- headers = {
1505
- "accept": "*/*",
1506
- "accept-encoding": "gzip, deflate, br",
1507
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1508
- "cache-control": "no-cache",
1509
- "origin": "https://datacenter.jin10.com",
1510
- "pragma": "no-cache",
1511
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1512
- "sec-fetch-dest": "empty",
1513
- "sec-fetch-mode": "cors",
1514
- "sec-fetch-site": "same-site",
1515
- "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",
1516
- "x-app-id": "rU6QIu7JHe2gOUeR",
1517
- "x-csrf-token": "",
1518
- "x-version": "1.0.0",
1519
- }
1520
- r = requests.get(url, params=params, headers=headers)
1521
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1522
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1523
- temp_se = temp_se.iloc[:, 1]
1524
- temp_df = pd.concat([temp_df, temp_se])
1525
- temp_df.dropna(inplace=True)
1526
- temp_df.sort_index(inplace=True)
1527
- temp_df = temp_df.reset_index()
1528
- temp_df.drop_duplicates(subset="index", inplace=True)
1529
- temp_df.set_index("index", inplace=True)
1530
- temp_df = temp_df.squeeze()
1531
- temp_df.index.name = None
1532
- temp_df.name = "usa_durable_goods_orders"
1533
- temp_df = temp_df.astype("float")
627
+ temp_df = __macro_usa_base_func(symbol="美国耐用品订单月率报告", params=params)
1534
628
  return temp_df
1535
629
 
1536
630
 
1537
631
  # 金十数据中心-经济指标-美国-产业指标-工业-美国工厂订单月率报告
1538
632
  def macro_usa_factory_orders() -> pd.DataFrame:
1539
633
  """
1540
- 美国工厂订单月率报告, 数据区间从19920401-至今
634
+ 美国工厂订单月率报告, 数据区间从 19920401-至今
1541
635
  https://datacenter.jin10.com/reportType/dc_usa_factory_orders
1542
- https://cdn.jin10.com/dc/reports/dc_usa_factory_orders_all.js?v=1578744385
1543
- :return: 美国工厂订单月率报告-今值(%)
1544
- :rtype: pandas.Series
636
+ :return: 美国工厂订单月率报告
637
+ :rtype: pandas.DataFrame
1545
638
  """
1546
639
  t = time.time()
1547
- res = requests.get(
1548
- f"https://cdn.jin10.com/dc/reports/dc_usa_factory_orders_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1549
- )
1550
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1551
- date_list = [item["date"] for item in json_data["list"]]
1552
- value_list = [item["datas"]["美国工厂订单月率报告"] for item in json_data["list"]]
1553
- value_df = pd.DataFrame(value_list)
1554
- value_df.columns = json_data["kinds"]
1555
- value_df.index = pd.to_datetime(date_list)
1556
- temp_df = value_df["今值(%)"]
1557
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1558
640
  params = {
1559
641
  "max_date": "",
1560
642
  "category": "ec",
1561
643
  "attr_id": "16",
1562
644
  "_": str(int(round(t * 1000))),
1563
645
  }
1564
- headers = {
1565
- "accept": "*/*",
1566
- "accept-encoding": "gzip, deflate, br",
1567
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1568
- "cache-control": "no-cache",
1569
- "origin": "https://datacenter.jin10.com",
1570
- "pragma": "no-cache",
1571
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1572
- "sec-fetch-dest": "empty",
1573
- "sec-fetch-mode": "cors",
1574
- "sec-fetch-site": "same-site",
1575
- "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",
1576
- "x-app-id": "rU6QIu7JHe2gOUeR",
1577
- "x-csrf-token": "",
1578
- "x-version": "1.0.0",
1579
- }
1580
- r = requests.get(url, params=params, headers=headers)
1581
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1582
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1583
- temp_se = temp_se.iloc[:, 1]
1584
- temp_df = pd.concat([temp_df, temp_se])
1585
- temp_df.dropna(inplace=True)
1586
- temp_df.sort_index(inplace=True)
1587
- temp_df = temp_df.reset_index()
1588
- temp_df.drop_duplicates(subset="index", inplace=True)
1589
- temp_df.set_index("index", inplace=True)
1590
- temp_df = temp_df.squeeze()
1591
- temp_df.index.name = None
1592
- temp_df.name = "usa_factory_orders"
1593
- temp_df = temp_df.astype("float")
646
+ temp_df = __macro_usa_base_func(symbol="美国工厂订单月率报告", params=params)
1594
647
  return temp_df
1595
648
 
1596
649
 
1597
650
  # 金十数据中心-经济指标-美国-产业指标-服务业-美国Markit服务业PMI初值报告
1598
651
  def macro_usa_services_pmi() -> pd.DataFrame:
1599
652
  """
1600
- 美国Markit服务业PMI初值报告, 数据区间从20120701-至今
653
+ 美国Markit服务业PMI初值报告, 数据区间从 20120701-至今
1601
654
  https://datacenter.jin10.com/reportType/dc_usa_services_pmi
1602
- https://cdn.jin10.com/dc/reports/dc_usa_services_pmi_all.js?v=1578744503
1603
- :return: 美国Markit服务业PMI初值报告-今值
1604
- :rtype: pandas.Series
655
+ :return: 美国Markit服务业PMI初值报告
656
+ :rtype: pandas.DataFrame
1605
657
  """
1606
658
  t = time.time()
1607
- res = requests.get(
1608
- f"https://cdn.jin10.com/dc/reports/dc_usa_services_pmi_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1609
- )
1610
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1611
- date_list = [item["date"] for item in json_data["list"]]
1612
- value_list = [item["datas"]["美国Markit服务业PMI初值报告"] for item in json_data["list"]]
1613
- value_df = pd.DataFrame(value_list)
1614
- value_df.columns = json_data["kinds"]
1615
- value_df.index = pd.to_datetime(date_list)
1616
- temp_df = value_df["今值"]
1617
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1618
659
  params = {
1619
660
  "max_date": "",
1620
661
  "category": "ec",
1621
662
  "attr_id": "89",
1622
663
  "_": str(int(round(t * 1000))),
1623
664
  }
1624
- headers = {
1625
- "accept": "*/*",
1626
- "accept-encoding": "gzip, deflate, br",
1627
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1628
- "cache-control": "no-cache",
1629
- "origin": "https://datacenter.jin10.com",
1630
- "pragma": "no-cache",
1631
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1632
- "sec-fetch-dest": "empty",
1633
- "sec-fetch-mode": "cors",
1634
- "sec-fetch-site": "same-site",
1635
- "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",
1636
- "x-app-id": "rU6QIu7JHe2gOUeR",
1637
- "x-csrf-token": "",
1638
- "x-version": "1.0.0",
1639
- }
1640
- r = requests.get(url, params=params, headers=headers)
1641
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1642
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1643
- temp_se = temp_se.iloc[:, 1]
1644
- temp_df = pd.concat([temp_df, temp_se])
1645
- temp_df.dropna(inplace=True)
1646
- temp_df.sort_index(inplace=True)
1647
- temp_df = temp_df.reset_index()
1648
- temp_df.drop_duplicates(subset="index", inplace=True)
1649
- temp_df.set_index("index", inplace=True)
1650
- temp_df = temp_df.squeeze()
1651
- temp_df.index.name = None
1652
- temp_df.name = "usa_services_pmi"
1653
- temp_df = temp_df.astype("float")
665
+ temp_df = __macro_usa_base_func(symbol="美国Markit服务业PMI初值报告", params=params)
1654
666
  return temp_df
1655
667
 
1656
668
 
1657
669
  # 金十数据中心-经济指标-美国-产业指标-服务业-美国商业库存月率报告
1658
670
  def macro_usa_business_inventories() -> pd.DataFrame:
1659
671
  """
1660
- 美国商业库存月率报告, 数据区间从19920301-至今
672
+ 美国商业库存月率报告, 数据区间从 19920301-至今
1661
673
  https://datacenter.jin10.com/reportType/dc_usa_business_inventories
1662
- https://cdn.jin10.com/dc/reports/dc_usa_business_inventories_all.js?v=1578744618
1663
- :return: 美国商业库存月率报告-今值(%)
1664
- :rtype: pandas.Series
674
+ :return: 美国商业库存月率报告
675
+ :rtype: pandas.DataFrame
1665
676
  """
1666
677
  t = time.time()
1667
- res = requests.get(
1668
- f"https://cdn.jin10.com/dc/reports/dc_usa_business_inventories_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1669
- )
1670
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1671
- date_list = [item["date"] for item in json_data["list"]]
1672
- value_list = [item["datas"]["美国商业库存月率报告"] for item in json_data["list"]]
1673
- value_df = pd.DataFrame(value_list)
1674
- value_df.columns = json_data["kinds"]
1675
- value_df.index = pd.to_datetime(date_list)
1676
- temp_df = value_df["今值(%)"]
1677
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1678
678
  params = {
1679
679
  "max_date": "",
1680
680
  "category": "ec",
1681
681
  "attr_id": "4",
1682
682
  "_": str(int(round(t * 1000))),
1683
683
  }
1684
- headers = {
1685
- "accept": "*/*",
1686
- "accept-encoding": "gzip, deflate, br",
1687
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1688
- "cache-control": "no-cache",
1689
- "origin": "https://datacenter.jin10.com",
1690
- "pragma": "no-cache",
1691
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1692
- "sec-fetch-dest": "empty",
1693
- "sec-fetch-mode": "cors",
1694
- "sec-fetch-site": "same-site",
1695
- "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",
1696
- "x-app-id": "rU6QIu7JHe2gOUeR",
1697
- "x-csrf-token": "",
1698
- "x-version": "1.0.0",
1699
- }
1700
- r = requests.get(url, params=params, headers=headers)
1701
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1702
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1703
- temp_se = temp_se.iloc[:, 1]
1704
- temp_df = pd.concat([temp_df, temp_se])
1705
- temp_df.dropna(inplace=True)
1706
- temp_df.sort_index(inplace=True)
1707
- temp_df = temp_df.reset_index()
1708
- temp_df.drop_duplicates(subset="index", inplace=True)
1709
- temp_df.set_index("index", inplace=True)
1710
- temp_df = temp_df.squeeze()
1711
- temp_df.index.name = None
1712
- temp_df.name = "usa_business_inventories"
1713
- temp_df = temp_df.astype("float")
684
+ temp_df = __macro_usa_base_func(symbol="美国商业库存月率报告", params=params)
1714
685
  return temp_df
1715
686
 
1716
687
 
1717
688
  # 金十数据中心-经济指标-美国-产业指标-服务业-美国ISM非制造业PMI报告
1718
689
  def macro_usa_ism_non_pmi() -> pd.DataFrame:
1719
690
  """
1720
- 美国ISM非制造业PMI报告, 数据区间从19970801-至今
691
+ 美国ISM非制造业PMI报告, 数据区间从 19970801-至今
1721
692
  https://datacenter.jin10.com/reportType/dc_usa_ism_non_pmi
1722
- https://cdn.jin10.com/dc/reports/dc_usa_ism_non_pmi_all.js?v=1578744693
1723
- :return: 美国ISM非制造业PMI报告-今值
1724
- :rtype: pandas.Series
693
+ :return: 美国ISM非制造业PMI报告
694
+ :rtype: pandas.DataFrame
1725
695
  """
1726
696
  t = time.time()
1727
- res = requests.get(
1728
- f"https://cdn.jin10.com/dc/reports/dc_usa_ism_non_pmi_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1729
- )
1730
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1731
- date_list = [item["date"] for item in json_data["list"]]
1732
- value_list = [item["datas"]["美国ISM非制造业PMI报告"] for item in json_data["list"]]
1733
- value_df = pd.DataFrame(value_list)
1734
- value_df.columns = json_data["kinds"]
1735
- value_df.index = pd.to_datetime(date_list)
1736
- temp_df = value_df["今值"]
1737
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1738
697
  params = {
1739
698
  "max_date": "",
1740
699
  "category": "ec",
1741
700
  "attr_id": "29",
1742
701
  "_": str(int(round(t * 1000))),
1743
702
  }
1744
- headers = {
1745
- "accept": "*/*",
1746
- "accept-encoding": "gzip, deflate, br",
1747
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1748
- "cache-control": "no-cache",
1749
- "origin": "https://datacenter.jin10.com",
1750
- "pragma": "no-cache",
1751
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1752
- "sec-fetch-dest": "empty",
1753
- "sec-fetch-mode": "cors",
1754
- "sec-fetch-site": "same-site",
1755
- "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",
1756
- "x-app-id": "rU6QIu7JHe2gOUeR",
1757
- "x-csrf-token": "",
1758
- "x-version": "1.0.0",
1759
- }
1760
- r = requests.get(url, params=params, headers=headers)
1761
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1762
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1763
- temp_se = temp_se.iloc[:, 1]
1764
- temp_df = pd.concat([temp_df, temp_se])
1765
- temp_df.dropna(inplace=True)
1766
- temp_df.sort_index(inplace=True)
1767
- temp_df = temp_df.reset_index()
1768
- temp_df.drop_duplicates(subset="index", inplace=True)
1769
- temp_df.set_index("index", inplace=True)
1770
- temp_df = temp_df.squeeze()
1771
- temp_df.index.name = None
1772
- temp_df.name = "usa_ism_non_pmi"
1773
- temp_df = temp_df.astype("float")
703
+ temp_df = __macro_usa_base_func(symbol="美国ISM非制造业PMI报告", params=params)
1774
704
  return temp_df
1775
705
 
1776
706
 
1777
707
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国NAHB房产市场指数报告
1778
708
  def macro_usa_nahb_house_market_index() -> pd.DataFrame:
1779
709
  """
1780
- 美国NAHB房产市场指数报告, 数据区间从19850201-至今
710
+ 美国NAHB房产市场指数报告, 数据区间从 19850201-至今
1781
711
  https://datacenter.jin10.com/reportType/dc_usa_nahb_house_market_index
1782
- https://cdn.jin10.com/dc/reports/dc_usa_nahb_house_market_index_all.js?v=1578744817
1783
- :return: 美国NAHB房产市场指数报告-今值
1784
- :rtype: pandas.Series
712
+ :return: 美国NAHB房产市场指数报告
713
+ :rtype: pandas.DataFrame
1785
714
  """
1786
715
  t = time.time()
1787
- res = requests.get(
1788
- f"https://cdn.jin10.com/dc/reports/dc_usa_nahb_house_market_index_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1789
- )
1790
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1791
- date_list = [item["date"] for item in json_data["list"]]
1792
- value_list = [item["datas"]["美国NAHB房产市场指数报告"] for item in json_data["list"]]
1793
- value_df = pd.DataFrame(value_list)
1794
- value_df.columns = json_data["kinds"]
1795
- value_df.index = pd.to_datetime(date_list)
1796
- temp_df = value_df["今值"]
1797
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1798
716
  params = {
1799
717
  "max_date": "",
1800
718
  "category": "ec",
1801
719
  "attr_id": "31",
1802
720
  "_": str(int(round(t * 1000))),
1803
721
  }
1804
- headers = {
1805
- "accept": "*/*",
1806
- "accept-encoding": "gzip, deflate, br",
1807
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1808
- "cache-control": "no-cache",
1809
- "origin": "https://datacenter.jin10.com",
1810
- "pragma": "no-cache",
1811
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1812
- "sec-fetch-dest": "empty",
1813
- "sec-fetch-mode": "cors",
1814
- "sec-fetch-site": "same-site",
1815
- "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",
1816
- "x-app-id": "rU6QIu7JHe2gOUeR",
1817
- "x-csrf-token": "",
1818
- "x-version": "1.0.0",
1819
- }
1820
- r = requests.get(url, params=params, headers=headers)
1821
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1822
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1823
- temp_se = temp_se.iloc[:, 1]
1824
- temp_df = pd.concat([temp_df, temp_se])
1825
- temp_df.dropna(inplace=True)
1826
- temp_df.sort_index(inplace=True)
1827
- temp_df = temp_df.reset_index()
1828
- temp_df.drop_duplicates(subset="index", inplace=True)
1829
- temp_df.set_index("index", inplace=True)
1830
- temp_df = temp_df.squeeze()
1831
- temp_df.index.name = None
1832
- temp_df.name = "usa_nahb_house_market_index"
1833
- temp_df = temp_df.astype("float")
722
+ temp_df = __macro_usa_base_func(symbol="美国NAHB房产市场指数报告", params=params)
1834
723
  return temp_df
1835
724
 
1836
725
 
1837
726
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国新屋开工总数年化报告
1838
727
  def macro_usa_house_starts() -> pd.DataFrame:
1839
728
  """
1840
- 美国新屋开工总数年化报告, 数据区间从19700101-至今
729
+ 美国新屋开工总数年化报告, 数据区间从 19700101-至今
1841
730
  https://datacenter.jin10.com/reportType/dc_usa_house_starts
1842
- https://cdn.jin10.com/dc/reports/dc_usa_house_starts_all.js?v=1578747388
1843
- :return: 美国新屋开工总数年化报告-今值(万户)
1844
- :rtype: pandas.Series
731
+ :return: 美国新屋开工总数年化报告
732
+ :rtype: pandas.DataFrame
1845
733
  """
1846
734
  t = time.time()
1847
- res = requests.get(
1848
- f"https://cdn.jin10.com/dc/reports/dc_usa_house_starts_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1849
- )
1850
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1851
- date_list = [item["date"] for item in json_data["list"]]
1852
- value_list = [item["datas"]["美国新屋开工总数年化报告"] for item in json_data["list"]]
1853
- value_df = pd.DataFrame(value_list)
1854
- value_df.columns = json_data["kinds"]
1855
- value_df.index = pd.to_datetime(date_list)
1856
- temp_df = value_df["今值(万户)"]
1857
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1858
735
  params = {
1859
736
  "max_date": "",
1860
737
  "category": "ec",
1861
738
  "attr_id": "17",
1862
739
  "_": str(int(round(t * 1000))),
1863
740
  }
1864
- headers = {
1865
- "accept": "*/*",
1866
- "accept-encoding": "gzip, deflate, br",
1867
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1868
- "cache-control": "no-cache",
1869
- "origin": "https://datacenter.jin10.com",
1870
- "pragma": "no-cache",
1871
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1872
- "sec-fetch-dest": "empty",
1873
- "sec-fetch-mode": "cors",
1874
- "sec-fetch-site": "same-site",
1875
- "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",
1876
- "x-app-id": "rU6QIu7JHe2gOUeR",
1877
- "x-csrf-token": "",
1878
- "x-version": "1.0.0",
1879
- }
1880
- r = requests.get(url, params=params, headers=headers)
1881
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1882
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1883
- temp_se = temp_se.iloc[:, 1]
1884
- temp_df = pd.concat([temp_df, temp_se])
1885
- temp_df.dropna(inplace=True)
1886
- temp_df.sort_index(inplace=True)
1887
- temp_df = temp_df.reset_index()
1888
- temp_df.drop_duplicates(subset="index", inplace=True)
1889
- temp_df.set_index("index", inplace=True)
1890
- temp_df = temp_df.squeeze()
1891
- temp_df.index.name = None
1892
- temp_df.name = "usa_house_starts"
1893
- temp_df = temp_df.astype("float")
741
+ temp_df = __macro_usa_base_func(symbol="美国新屋开工总数年化报告", params=params)
1894
742
  return temp_df
1895
743
 
1896
744
 
1897
745
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国新屋销售总数年化报告
1898
746
  def macro_usa_new_home_sales() -> pd.DataFrame:
1899
747
  """
1900
- 美国新屋销售总数年化报告, 数据区间从19700101-至今
748
+ 美国新屋销售总数年化报告, 数据区间从 19700101-至今
1901
749
  https://datacenter.jin10.com/reportType/dc_usa_new_home_sales
1902
- https://cdn.jin10.com/dc/reports/dc_usa_new_home_sales_all.js?v=1578747501
1903
- :return: 美国新屋销售总数年化报告-今值(万户)
1904
- :rtype: pandas.Series
750
+ :return: 美国新屋销售总数年化报告
751
+ :rtype: pandas.DataFrame
1905
752
  """
1906
753
  t = time.time()
1907
- res = requests.get(
1908
- f"https://cdn.jin10.com/dc/reports/dc_usa_new_home_sales_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1909
- )
1910
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1911
- date_list = [item["date"] for item in json_data["list"]]
1912
- value_list = [item["datas"]["美国新屋销售总数年化报告"] for item in json_data["list"]]
1913
- value_df = pd.DataFrame(value_list)
1914
- value_df.columns = json_data["kinds"]
1915
- value_df.index = pd.to_datetime(date_list)
1916
- temp_df = value_df["今值(万户)"]
1917
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1918
754
  params = {
1919
755
  "max_date": "",
1920
756
  "category": "ec",
1921
757
  "attr_id": "32",
1922
758
  "_": str(int(round(t * 1000))),
1923
759
  }
1924
- headers = {
1925
- "accept": "*/*",
1926
- "accept-encoding": "gzip, deflate, br",
1927
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1928
- "cache-control": "no-cache",
1929
- "origin": "https://datacenter.jin10.com",
1930
- "pragma": "no-cache",
1931
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1932
- "sec-fetch-dest": "empty",
1933
- "sec-fetch-mode": "cors",
1934
- "sec-fetch-site": "same-site",
1935
- "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",
1936
- "x-app-id": "rU6QIu7JHe2gOUeR",
1937
- "x-csrf-token": "",
1938
- "x-version": "1.0.0",
1939
- }
1940
- r = requests.get(url, params=params, headers=headers)
1941
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
1942
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
1943
- temp_se = temp_se.iloc[:, 1]
1944
- temp_df = pd.concat([temp_df, temp_se])
1945
- temp_df.dropna(inplace=True)
1946
- temp_df.sort_index(inplace=True)
1947
- temp_df = temp_df.reset_index()
1948
- temp_df.drop_duplicates(subset="index", inplace=True)
1949
- temp_df.set_index("index", inplace=True)
1950
- temp_df = temp_df.squeeze()
1951
- temp_df.index.name = None
1952
- temp_df.name = "usa_new_home_sales"
1953
- temp_df = temp_df.astype("float")
760
+ temp_df = __macro_usa_base_func(symbol="美国新屋销售总数年化报告", params=params)
1954
761
  return temp_df
1955
762
 
1956
763
 
1957
764
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国营建许可总数报告
1958
765
  def macro_usa_building_permits() -> pd.DataFrame:
1959
766
  """
1960
- 美国营建许可总数报告, 数据区间从20080220-至今
767
+ 美国营建许可总数报告, 数据区间从 20080220-至今
1961
768
  https://datacenter.jin10.com/reportType/dc_usa_building_permits
1962
- https://cdn.jin10.com/dc/reports/dc_usa_building_permits_all.js?v=1578747599
1963
- :return: 美国营建许可总数报告-今值(万户)
1964
- :rtype: pandas.Series
769
+ :return: 美国营建许可总数报告
770
+ :rtype: pandas.DataFrame
1965
771
  """
1966
772
  t = time.time()
1967
- res = requests.get(
1968
- f"https://cdn.jin10.com/dc/reports/dc_usa_building_permits_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
1969
- )
1970
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
1971
- date_list = [item["date"] for item in json_data["list"]]
1972
- value_list = [item["datas"]["美国营建许可总数报告"] for item in json_data["list"]]
1973
- value_df = pd.DataFrame(value_list)
1974
- value_df.columns = json_data["kinds"]
1975
- value_df.index = pd.to_datetime(date_list)
1976
- temp_df = value_df["今值(万户)"]
1977
- url = "https://datacenter-api.jin10.com/reports/list_v2"
1978
773
  params = {
1979
774
  "max_date": "",
1980
775
  "category": "ec",
1981
776
  "attr_id": "3",
1982
777
  "_": str(int(round(t * 1000))),
1983
778
  }
1984
- headers = {
1985
- "accept": "*/*",
1986
- "accept-encoding": "gzip, deflate, br",
1987
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
1988
- "cache-control": "no-cache",
1989
- "origin": "https://datacenter.jin10.com",
1990
- "pragma": "no-cache",
1991
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
1992
- "sec-fetch-dest": "empty",
1993
- "sec-fetch-mode": "cors",
1994
- "sec-fetch-site": "same-site",
1995
- "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",
1996
- "x-app-id": "rU6QIu7JHe2gOUeR",
1997
- "x-csrf-token": "",
1998
- "x-version": "1.0.0",
1999
- }
2000
- r = requests.get(url, params=params, headers=headers)
2001
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
2002
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
2003
- temp_se = temp_se.iloc[:, 1]
2004
- temp_df = pd.concat([temp_df, temp_se])
2005
- temp_df.dropna(inplace=True)
2006
- temp_df.sort_index(inplace=True)
2007
- temp_df = temp_df.reset_index()
2008
- temp_df.drop_duplicates(subset="index", inplace=True)
2009
- temp_df.set_index("index", inplace=True)
2010
- temp_df = temp_df.squeeze()
2011
- temp_df.index.name = None
2012
- temp_df.name = "usa_building_permits"
2013
- temp_df = temp_df.astype("float")
779
+ temp_df = __macro_usa_base_func(symbol="美国营建许可总数报告", params=params)
2014
780
  return temp_df
2015
781
 
2016
782
 
2017
783
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国成屋销售总数年化报告
2018
784
  def macro_usa_exist_home_sales() -> pd.DataFrame:
2019
785
  """
2020
- 美国成屋销售总数年化报告, 数据区间从19700101-至今
786
+ 美国成屋销售总数年化报告, 数据区间从 19700101-至今
2021
787
  https://datacenter.jin10.com/reportType/dc_usa_exist_home_sales
2022
- https://cdn.jin10.com/dc/reports/dc_usa_exist_home_sales_all.js?v=1578747703
2023
- :return: 美国成屋销售总数年化报告-今值(万户)
2024
- :rtype: pandas.Series
788
+ :return: 美国成屋销售总数年化报告
789
+ :rtype: pandas.DataFrame
2025
790
  """
2026
791
  t = time.time()
2027
- res = requests.get(
2028
- f"https://cdn.jin10.com/dc/reports/dc_usa_exist_home_sales_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
2029
- )
2030
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
2031
- date_list = [item["date"] for item in json_data["list"]]
2032
- value_list = [item["datas"]["美国成屋销售总数年化报告"] for item in json_data["list"]]
2033
- value_df = pd.DataFrame(value_list)
2034
- value_df.columns = json_data["kinds"]
2035
- value_df.index = pd.to_datetime(date_list)
2036
- temp_df = value_df["今值(万户)"]
2037
- url = "https://datacenter-api.jin10.com/reports/list_v2"
2038
792
  params = {
2039
793
  "max_date": "",
2040
794
  "category": "ec",
2041
795
  "attr_id": "15",
2042
796
  "_": str(int(round(t * 1000))),
2043
797
  }
2044
- headers = {
2045
- "accept": "*/*",
2046
- "accept-encoding": "gzip, deflate, br",
2047
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
2048
- "cache-control": "no-cache",
2049
- "origin": "https://datacenter.jin10.com",
2050
- "pragma": "no-cache",
2051
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
2052
- "sec-fetch-dest": "empty",
2053
- "sec-fetch-mode": "cors",
2054
- "sec-fetch-site": "same-site",
2055
- "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",
2056
- "x-app-id": "rU6QIu7JHe2gOUeR",
2057
- "x-csrf-token": "",
2058
- "x-version": "1.0.0",
2059
- }
2060
- r = requests.get(url, params=params, headers=headers)
2061
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
2062
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
2063
- temp_se = temp_se.iloc[:, 1]
2064
- temp_df = pd.concat([temp_df, temp_se])
2065
- temp_df.dropna(inplace=True)
2066
- temp_df.sort_index(inplace=True)
2067
- temp_df = temp_df.reset_index()
2068
- temp_df.drop_duplicates(subset="index", inplace=True)
2069
- temp_df.set_index("index", inplace=True)
2070
- temp_df = temp_df.squeeze()
2071
- temp_df.index.name = None
2072
- temp_df.name = "usa_exist_home_sales"
2073
- temp_df = temp_df.astype("float")
798
+ temp_df = __macro_usa_base_func(symbol="美国成屋销售总数年化报告", params=params)
2074
799
  return temp_df
2075
800
 
2076
801
 
2077
802
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国FHFA房价指数月率报告
2078
803
  def macro_usa_house_price_index() -> pd.DataFrame:
2079
804
  """
2080
- 美国FHFA房价指数月率报告, 数据区间从19910301-至今
805
+ 美国FHFA房价指数月率报告, 数据区间从 19910301-至今
2081
806
  https://datacenter.jin10.com/reportType/dc_usa_house_price_index
2082
- https://cdn.jin10.com/dc/reports/dc_usa_house_price_index_all.js?v=1578747781
2083
- :return: 美国FHFA房价指数月率报告-今值(%)
2084
- :rtype: pandas.Series
807
+ :return: 美国FHFA房价指数月率报告
808
+ :rtype: pandas.DataFrame
2085
809
  """
2086
810
  t = time.time()
2087
- res = requests.get(
2088
- f"https://cdn.jin10.com/dc/reports/dc_usa_house_price_index_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
2089
- )
2090
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
2091
- date_list = [item["date"] for item in json_data["list"]]
2092
- value_list = [item["datas"]["美国FHFA房价指数月率报告"] for item in json_data["list"]]
2093
- value_df = pd.DataFrame(value_list)
2094
- value_df.columns = json_data["kinds"]
2095
- value_df.index = pd.to_datetime(date_list)
2096
- temp_df = value_df["今值(%)"]
2097
- url = "https://datacenter-api.jin10.com/reports/list_v2"
2098
811
  params = {
2099
812
  "max_date": "",
2100
813
  "category": "ec",
2101
814
  "attr_id": "51",
2102
815
  "_": str(int(round(t * 1000))),
2103
816
  }
2104
- headers = {
2105
- "accept": "*/*",
2106
- "accept-encoding": "gzip, deflate, br",
2107
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
2108
- "cache-control": "no-cache",
2109
- "origin": "https://datacenter.jin10.com",
2110
- "pragma": "no-cache",
2111
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
2112
- "sec-fetch-dest": "empty",
2113
- "sec-fetch-mode": "cors",
2114
- "sec-fetch-site": "same-site",
2115
- "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",
2116
- "x-app-id": "rU6QIu7JHe2gOUeR",
2117
- "x-csrf-token": "",
2118
- "x-version": "1.0.0",
2119
- }
2120
- r = requests.get(url, params=params, headers=headers)
2121
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
2122
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
2123
- temp_se = temp_se.iloc[:, 1]
2124
- temp_df = pd.concat([temp_df, temp_se])
2125
- temp_df.dropna(inplace=True)
2126
- temp_df.sort_index(inplace=True)
2127
- temp_df = temp_df.reset_index()
2128
- temp_df.drop_duplicates(subset="index", inplace=True)
2129
- temp_df.set_index("index", inplace=True)
2130
- temp_df = temp_df.squeeze()
2131
- temp_df.index.name = None
2132
- temp_df.name = "usa_house_price_index"
2133
- temp_df = temp_df.astype("float")
817
+ temp_df = __macro_usa_base_func(symbol="美国FHFA房价指数月率报告", params=params)
2134
818
  return temp_df
2135
819
 
2136
820
 
2137
821
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国S&P/CS20座大城市房价指数年率报告
2138
822
  def macro_usa_spcs20() -> pd.DataFrame:
2139
823
  """
2140
- 美国S&P/CS20座大城市房价指数年率报告, 数据区间从20010201-至今
824
+ 美国S&P/CS20座大城市房价指数年率报告, 数据区间从 20010201-至今
2141
825
  https://datacenter.jin10.com/reportType/dc_usa_spcs20
2142
- https://cdn.jin10.com/dc/reports/dc_usa_spcs20_all.js?v=1578747873
2143
- :return: 美国S&P/CS20座大城市房价指数年率报告-今值(%)
2144
- :rtype: pandas.Series
826
+ :return: 美国S&P/CS20座大城市房价指数年率报告
827
+ :rtype: pandas.DataFrame
2145
828
  """
2146
829
  t = time.time()
2147
- res = requests.get(
2148
- f"https://cdn.jin10.com/dc/reports/dc_usa_spcs20_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
2149
- )
2150
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
2151
- date_list = [item["date"] for item in json_data["list"]]
2152
- value_list = [item["datas"]["美国S&P/CS20座大城市房价指数年率报告"] for item in json_data["list"]]
2153
- value_df = pd.DataFrame(value_list)
2154
- value_df.columns = json_data["kinds"]
2155
- value_df.index = pd.to_datetime(date_list)
2156
- temp_df = value_df["今值(%)"]
2157
- url = "https://datacenter-api.jin10.com/reports/list_v2"
2158
830
  params = {
2159
831
  "max_date": "",
2160
832
  "category": "ec",
2161
833
  "attr_id": "52",
2162
834
  "_": str(int(round(t * 1000))),
2163
835
  }
2164
- headers = {
2165
- "accept": "*/*",
2166
- "accept-encoding": "gzip, deflate, br",
2167
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
2168
- "cache-control": "no-cache",
2169
- "origin": "https://datacenter.jin10.com",
2170
- "pragma": "no-cache",
2171
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
2172
- "sec-fetch-dest": "empty",
2173
- "sec-fetch-mode": "cors",
2174
- "sec-fetch-site": "same-site",
2175
- "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",
2176
- "x-app-id": "rU6QIu7JHe2gOUeR",
2177
- "x-csrf-token": "",
2178
- "x-version": "1.0.0",
2179
- }
2180
- r = requests.get(url, params=params, headers=headers)
2181
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
2182
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
2183
- temp_se = temp_se.iloc[:, 1]
2184
- temp_df = pd.concat([temp_df, temp_se])
2185
- temp_df.dropna(inplace=True)
2186
- temp_df.sort_index(inplace=True)
2187
- temp_df = temp_df.reset_index()
2188
- temp_df.drop_duplicates(subset="index", keep="last", inplace=True)
2189
- temp_df.set_index("index", inplace=True)
2190
- temp_df = temp_df.squeeze()
2191
- temp_df.index.name = None
2192
- temp_df.name = "usa_spcs20"
2193
- temp_df = temp_df.astype(float)
836
+ temp_df = __macro_usa_base_func(
837
+ symbol="美国S&P/CS20座大城市房价指数年率", params=params
838
+ )
2194
839
  return temp_df
2195
840
 
2196
841
 
2197
842
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国成屋签约销售指数月率报告
2198
843
  def macro_usa_pending_home_sales() -> pd.DataFrame:
2199
844
  """
2200
- 美国成屋签约销售指数月率报告, 数据区间从20010301-至今
845
+ 美国成屋签约销售指数月率报告, 数据区间从 20010301-至今
2201
846
  https://datacenter.jin10.com/reportType/dc_usa_pending_home_sales
2202
- https://cdn.jin10.com/dc/reports/dc_usa_pending_home_sales_all.js?v=1578747959
2203
847
  :return: 美国成屋签约销售指数月率报告
2204
- :rtype: pandas.Series
848
+ :rtype: pandas.DataFrame
2205
849
  """
2206
850
  t = time.time()
2207
- res = requests.get(
2208
- f"https://cdn.jin10.com/dc/reports/dc_usa_pending_home_sales_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
2209
- )
2210
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
2211
- date_list = [item["date"] for item in json_data["list"]]
2212
- value_list = [item["datas"]["美国成屋签约销售指数月率报告"] for item in json_data["list"]]
2213
- value_df = pd.DataFrame(value_list)
2214
- value_df.columns = json_data["kinds"]
2215
- value_df.index = pd.to_datetime(date_list)
2216
- temp_df = value_df["今值(%)"]
2217
- url = "https://datacenter-api.jin10.com/reports/list_v2"
2218
851
  params = {
2219
852
  "max_date": "",
2220
853
  "category": "ec",
2221
854
  "attr_id": "34",
2222
855
  "_": str(int(round(t * 1000))),
2223
856
  }
2224
- headers = {
2225
- "accept": "*/*",
2226
- "accept-encoding": "gzip, deflate, br",
2227
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
2228
- "cache-control": "no-cache",
2229
- "origin": "https://datacenter.jin10.com",
2230
- "pragma": "no-cache",
2231
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
2232
- "sec-fetch-dest": "empty",
2233
- "sec-fetch-mode": "cors",
2234
- "sec-fetch-site": "same-site",
2235
- "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",
2236
- "x-app-id": "rU6QIu7JHe2gOUeR",
2237
- "x-csrf-token": "",
2238
- "x-version": "1.0.0",
2239
- }
2240
- r = requests.get(url, params=params, headers=headers)
2241
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
2242
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
2243
- temp_se = temp_se.iloc[:, 1]
2244
- temp_df = pd.concat([temp_df, temp_se])
2245
- temp_df.dropna(inplace=True)
2246
- temp_df.sort_index(inplace=True)
2247
- temp_df = temp_df.reset_index()
2248
- temp_df.drop_duplicates(subset="index", keep="last", inplace=True)
2249
- temp_df.set_index("index", inplace=True)
2250
- temp_df = temp_df.squeeze()
2251
- temp_df.index.name = None
2252
- temp_df.name = "usa_pending_home_sales"
2253
- temp_df = temp_df.astype(float)
857
+ temp_df = __macro_usa_base_func(
858
+ symbol="美国成屋签约销售指数月率报告", params=params
859
+ )
2254
860
  return temp_df
2255
861
 
2256
862
 
@@ -2258,353 +864,134 @@ def macro_usa_pending_home_sales() -> pd.DataFrame:
2258
864
  def macro_usa_cb_consumer_confidence() -> pd.DataFrame:
2259
865
  """
2260
866
  金十数据中心-经济指标-美国-领先指标-美国谘商会消费者信心指数报告, 数据区间从 19700101-至今
2261
- https://cdn.jin10.com/dc/reports/dc_usa_cb_consumer_confidence_all.js?v=1578576859
2262
- :return: 美国谘商会消费者信心指数报告-今值
2263
- :rtype: pandas.Series
867
+ https://datacenter.jin10.com/reportType/dc_usa_cb_consumer_confidence
868
+ :return: 美国谘商会消费者信心指数报告
869
+ :rtype: pandas.DataFrame
2264
870
  """
2265
871
  t = time.time()
2266
- res = requests.get(
2267
- f"https://cdn.jin10.com/dc/reports/dc_usa_cb_consumer_confidence_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
2268
- )
2269
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
2270
- date_list = [item["date"] for item in json_data["list"]]
2271
- value_list = [item["datas"]["美国谘商会消费者信心指数报告"] for item in json_data["list"]]
2272
- value_df = pd.DataFrame(value_list)
2273
- value_df.columns = json_data["kinds"]
2274
- value_df.index = pd.to_datetime(date_list)
2275
- temp_df = value_df["今值"]
2276
-
2277
- url = "https://datacenter-api.jin10.com/reports/list_v2"
2278
872
  params = {
2279
873
  "max_date": "",
2280
874
  "category": "ec",
2281
875
  "attr_id": "5",
2282
876
  "_": str(int(round(t * 1000))),
2283
877
  }
2284
- headers = {
2285
- "accept": "*/*",
2286
- "accept-encoding": "gzip, deflate, br",
2287
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
2288
- "cache-control": "no-cache",
2289
- "origin": "https://datacenter.jin10.com",
2290
- "pragma": "no-cache",
2291
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
2292
- "sec-fetch-dest": "empty",
2293
- "sec-fetch-mode": "cors",
2294
- "sec-fetch-site": "same-site",
2295
- "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",
2296
- "x-app-id": "rU6QIu7JHe2gOUeR",
2297
- "x-csrf-token": "",
2298
- "x-version": "1.0.0",
2299
- }
2300
- r = requests.get(url, params=params, headers=headers)
2301
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
2302
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
2303
- temp_se = temp_se.iloc[:, 1]
2304
- temp_df = pd.concat([temp_df, temp_se])
2305
- temp_df.dropna(inplace=True)
2306
- temp_df.sort_index(inplace=True)
2307
- temp_df = temp_df.reset_index()
2308
- temp_df.drop_duplicates(subset="index", keep="last", inplace=True)
2309
- temp_df.set_index("index", inplace=True)
2310
- temp_df = temp_df.squeeze()
2311
- temp_df.index.name = None
2312
- temp_df.name = "cb_consumer_confidence"
2313
- temp_df = temp_df.astype(float)
878
+ temp_df = __macro_usa_base_func(symbol="美国谘商会消费者信心指数", params=params)
2314
879
  return temp_df
2315
880
 
2316
881
 
2317
882
  # 金十数据中心-经济指标-美国-领先指标-美国NFIB小型企业信心指数报告
2318
883
  def macro_usa_nfib_small_business() -> pd.DataFrame:
2319
884
  """
2320
- 美国NFIB小型企业信心指数报告, 数据区间从19750201-至今
2321
- https://cdn.jin10.com/dc/reports/dc_usa_nfib_small_business_all.js?v=1578576631
2322
- :return: 美国NFIB小型企业信心指数报告-今值
2323
- :rtype: pandas.Series
885
+ 美国NFIB小型企业信心指数报告, 数据区间从 19750201-至今
886
+ https://datacenter.jin10.com/reportType/dc_usa_nfib_small_business
887
+ :return: 美国NFIB小型企业信心指数报告
888
+ :rtype: pandas.DataFrame
2324
889
  """
2325
890
  t = time.time()
2326
- res = requests.get(
2327
- f"https://cdn.jin10.com/dc/reports/dc_usa_nfib_small_business_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
2328
- )
2329
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
2330
- date_list = [item["date"] for item in json_data["list"]]
2331
- value_list = [item["datas"]["美国NFIB小型企业信心指数报告"] for item in json_data["list"]]
2332
- value_df = pd.DataFrame(value_list)
2333
- value_df.columns = json_data["kinds"]
2334
- value_df.index = pd.to_datetime(date_list)
2335
- temp_df = value_df["今值"]
2336
- url = "https://datacenter-api.jin10.com/reports/list_v2"
2337
891
  params = {
2338
892
  "max_date": "",
2339
893
  "category": "ec",
2340
894
  "attr_id": "63",
2341
895
  "_": str(int(round(t * 1000))),
2342
896
  }
2343
- headers = {
2344
- "accept": "*/*",
2345
- "accept-encoding": "gzip, deflate, br",
2346
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
2347
- "cache-control": "no-cache",
2348
- "origin": "https://datacenter.jin10.com",
2349
- "pragma": "no-cache",
2350
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
2351
- "sec-fetch-dest": "empty",
2352
- "sec-fetch-mode": "cors",
2353
- "sec-fetch-site": "same-site",
2354
- "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",
2355
- "x-app-id": "rU6QIu7JHe2gOUeR",
2356
- "x-csrf-token": "",
2357
- "x-version": "1.0.0",
2358
- }
2359
- r = requests.get(url, params=params, headers=headers)
2360
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
2361
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
2362
- temp_se = temp_se.iloc[:, 1]
2363
- temp_df = pd.concat([temp_df, temp_se])
2364
- temp_df.dropna(inplace=True)
2365
- temp_df.sort_index(inplace=True)
2366
- temp_df = temp_df.reset_index()
2367
- temp_df.drop_duplicates(subset="index", keep="last", inplace=True)
2368
- temp_df.set_index("index", inplace=True)
2369
- temp_df = temp_df.squeeze()
2370
- temp_df.index.name = None
2371
- temp_df.name = "nfib_small_business"
2372
- temp_df = temp_df.astype(float)
897
+ temp_df = __macro_usa_base_func(
898
+ symbol="美国NFIB小型企业信心指数报告", params=params
899
+ )
2373
900
  return temp_df
2374
901
 
2375
902
 
2376
903
  # 金十数据中心-经济指标-美国-领先指标-美国密歇根大学消费者信心指数初值报告
2377
904
  def macro_usa_michigan_consumer_sentiment() -> pd.DataFrame:
2378
905
  """
2379
- 美国密歇根大学消费者信心指数初值报告, 数据区间从19700301-至今
906
+ 美国密歇根大学消费者信心指数初值报告, 数据区间从 19700301-至今
2380
907
  https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment
2381
- :return: 美国密歇根大学消费者信心指数初值报告-今值
2382
- :rtype: pandas.Series
908
+ :return: 美国密歇根大学消费者信心指数初值报告
909
+ :rtype: pandas.DataFrame
2383
910
  """
2384
911
  t = time.time()
2385
- res = requests.get(
2386
- f"https://cdn.jin10.com/dc/reports/dc_usa_michigan_consumer_sentiment_all.js?v={str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)}"
2387
- )
2388
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
2389
- date_list = [item["date"] for item in json_data["list"]]
2390
- value_list = [item["datas"]["美国密歇根大学消费者信心指数初值报告"] for item in json_data["list"]]
2391
- value_df = pd.DataFrame(value_list)
2392
- value_df.columns = json_data["kinds"]
2393
- value_df.index = pd.to_datetime(date_list)
2394
- temp_df = value_df["今值"]
2395
- url = "https://datacenter-api.jin10.com/reports/list_v2"
2396
912
  params = {
2397
913
  "max_date": "",
2398
914
  "category": "ec",
2399
915
  "attr_id": "50",
2400
916
  "_": str(int(round(t * 1000))),
2401
917
  }
2402
- headers = {
2403
- "accept": "*/*",
2404
- "accept-encoding": "gzip, deflate, br",
2405
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
2406
- "cache-control": "no-cache",
2407
- "origin": "https://datacenter.jin10.com",
2408
- "pragma": "no-cache",
2409
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
2410
- "sec-fetch-dest": "empty",
2411
- "sec-fetch-mode": "cors",
2412
- "sec-fetch-site": "same-site",
2413
- "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",
2414
- "x-app-id": "rU6QIu7JHe2gOUeR",
2415
- "x-csrf-token": "",
2416
- "x-version": "1.0.0",
2417
- }
2418
- r = requests.get(url, params=params, headers=headers)
2419
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
2420
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
2421
- temp_se = temp_se.iloc[:, 1]
2422
- temp_df = pd.concat([temp_df, temp_se])
2423
- temp_df.dropna(inplace=True)
2424
- temp_df.sort_index(inplace=True)
2425
- temp_df = temp_df.reset_index()
2426
- temp_df.drop_duplicates(subset="index", keep="last", inplace=True)
2427
- temp_df.set_index("index", inplace=True)
2428
- temp_df = temp_df.squeeze()
2429
- temp_df.index.name = None
2430
- temp_df.name = "michigan_consumer_sentiment"
2431
- temp_df = temp_df.astype(float)
918
+ temp_df = __macro_usa_base_func(
919
+ symbol="美国密歇根大学消费者信心指数初值报告", params=params
920
+ )
2432
921
  return temp_df
2433
922
 
2434
923
 
2435
924
  # 金十数据中心-经济指标-美国-其他-美国EIA原油库存报告
2436
925
  def macro_usa_eia_crude_rate() -> pd.DataFrame:
2437
926
  """
2438
- 美国EIA原油库存报告, 数据区间从19950801-至今
927
+ 美国 EIA 原油库存报告, 数据区间从 19950801-至今
2439
928
  https://datacenter.jin10.com/reportType/dc_eia_crude_oil
2440
- :return: pandas.Series
2441
- 1982-09-01 -262.6
2442
- 1982-10-01 -8
2443
- 1982-11-01 -41.3
2444
- 1982-12-01 -87.6
2445
- 1983-01-01 51.3
2446
- ...
2447
- 2019-10-02 310
2448
- 2019-10-09 292.7
2449
- 2019-10-16 0
2450
- 2019-10-17 928.1
2451
- 2019-10-23 0
929
+ :return: 美国 EIA 原油库存报告
930
+ :return: pandas.DataFrame
2452
931
  """
2453
932
  t = time.time()
2454
- res = requests.get(
2455
- JS_USA_EIA_CRUDE_URL.format(
2456
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
2457
- )
2458
- )
2459
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
2460
- date_list = [item["date"] for item in json_data["list"]]
2461
- value_list = [item["datas"]["美国EIA原油库存(万桶)"] for item in json_data["list"]]
2462
- value_df = pd.DataFrame(value_list)
2463
- value_df.columns = json_data["kinds"]
2464
- value_df.index = pd.to_datetime(date_list)
2465
- temp_df = value_df["今值(万桶)"]
2466
- url = "https://datacenter-api.jin10.com/reports/list_v2"
2467
933
  params = {
2468
934
  "max_date": "",
2469
935
  "category": "ec",
2470
936
  "attr_id": "10",
2471
937
  "_": str(int(round(t * 1000))),
2472
938
  }
2473
- headers = {
2474
- "accept": "*/*",
2475
- "accept-encoding": "gzip, deflate, br",
2476
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
2477
- "cache-control": "no-cache",
2478
- "origin": "https://datacenter.jin10.com",
2479
- "pragma": "no-cache",
2480
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
2481
- "sec-fetch-dest": "empty",
2482
- "sec-fetch-mode": "cors",
2483
- "sec-fetch-site": "same-site",
2484
- "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",
2485
- "x-app-id": "rU6QIu7JHe2gOUeR",
2486
- "x-csrf-token": "",
2487
- "x-version": "1.0.0",
2488
- }
2489
- r = requests.get(url, params=params, headers=headers)
2490
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
2491
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
2492
- temp_se = temp_se.iloc[:, 1]
2493
- temp_df = pd.concat([temp_df, temp_se])
2494
- temp_df.dropna(inplace=True)
2495
- temp_df.sort_index(inplace=True)
2496
- temp_df = temp_df.reset_index()
2497
- temp_df.drop_duplicates(subset="index", inplace=True)
2498
- temp_df.set_index("index", inplace=True)
2499
- temp_df = temp_df.squeeze()
2500
- temp_df.index.name = None
2501
- temp_df.name = "eia_crude_rate"
2502
- temp_df = temp_df.astype("float")
939
+ temp_df = __macro_usa_base_func(symbol="美国EIA原油库存", params=params)
2503
940
  return temp_df
2504
941
 
2505
942
 
2506
943
  # 金十数据中心-经济指标-美国-其他-美国初请失业金人数报告
2507
944
  def macro_usa_initial_jobless() -> pd.DataFrame:
2508
945
  """
2509
- 美国初请失业金人数报告, 数据区间从19700101-至今
2510
- :return: pandas.Series
2511
- 1970-01-01 22.1087
2512
- 1970-02-01 24.9318
2513
- 1970-03-01 25.85
2514
- 1970-04-01 26.8682
2515
- 1970-05-01 33.1591
2516
- ...
2517
- 2019-09-26 21.5
2518
- 2019-10-03 22
2519
- 2019-10-10 21
2520
- 2019-10-17 21.4
2521
- 2019-10-24 0
946
+ 美国初请失业金人数报告, 数据区间从 19700101-至今
947
+ https://datacenter.jin10.com/reportType/dc_initial_jobless
948
+ :return: 美国 EIA 原油库存报告
949
+ :return: pandas.DataFrame
2522
950
  """
2523
951
  t = time.time()
2524
- res = requests.get(
2525
- JS_USA_INITIAL_JOBLESS_URL.format(
2526
- str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
2527
- )
2528
- )
2529
- json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
2530
- date_list = [item["date"] for item in json_data["list"]]
2531
- value_list = [item["datas"]["美国初请失业金人数(万人)"] for item in json_data["list"]]
2532
- value_df = pd.DataFrame(value_list)
2533
- value_df.columns = json_data["kinds"]
2534
- value_df.index = pd.to_datetime(date_list)
2535
- temp_df = value_df["今值(万人)"]
2536
- url = "https://datacenter-api.jin10.com/reports/list_v2"
2537
952
  params = {
2538
953
  "max_date": "",
2539
954
  "category": "ec",
2540
955
  "attr_id": "44",
2541
956
  "_": str(int(round(t * 1000))),
2542
957
  }
2543
- headers = {
2544
- "accept": "*/*",
2545
- "accept-encoding": "gzip, deflate, br",
2546
- "accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
2547
- "cache-control": "no-cache",
2548
- "origin": "https://datacenter.jin10.com",
2549
- "pragma": "no-cache",
2550
- "referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
2551
- "sec-fetch-dest": "empty",
2552
- "sec-fetch-mode": "cors",
2553
- "sec-fetch-site": "same-site",
2554
- "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",
2555
- "x-app-id": "rU6QIu7JHe2gOUeR",
2556
- "x-csrf-token": "",
2557
- "x-version": "1.0.0",
2558
- }
2559
- r = requests.get(url, params=params, headers=headers)
2560
- temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
2561
- temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
2562
- temp_se = temp_se.iloc[:, 1]
2563
- temp_df = pd.concat([temp_df, temp_se])
2564
- temp_df.dropna(inplace=True)
2565
- temp_df.sort_index(inplace=True)
2566
- temp_df = temp_df.reset_index()
2567
- temp_df.drop_duplicates(subset="index", inplace=True)
2568
- temp_df.set_index("index", inplace=True)
2569
- temp_df = temp_df.squeeze()
2570
- temp_df.index.name = None
2571
- temp_df.name = "initial_jobless"
2572
- temp_df = temp_df.astype("float")
958
+ temp_df = __macro_usa_base_func(symbol="美国初请失业金人数", params=params)
2573
959
  return temp_df
2574
960
 
2575
961
 
2576
962
  # 金十数据中心-经济指标-美国-其他-美国原油产量报告
2577
963
  def macro_usa_crude_inner() -> pd.DataFrame:
2578
964
  """
2579
- 美国原油产量报告, 数据区间从19830107-至今
965
+ 美国原油产量报告, 数据区间从 19830107-至今
2580
966
  https://datacenter.jin10.com/reportType/dc_eia_crude_oil_produce
2581
- :return: pandas.Series
2582
- 1983-01-07 863.40
2583
- 1983-01-14 863.40
2584
- 1983-01-21 863.40
2585
- 1983-01-28 863.40
2586
- 1983-02-04 866.00
2587
- ...
2588
- 2019-09-20 1250.00
2589
- 2019-09-27 1240.00
2590
- 2019-10-04 1260.00
2591
- 2019-10-11 1260.00
2592
- 2019-10-18 1260.00
967
+ :return: 美国原油产量报告
968
+ :return: pandas.DataFrame
2593
969
  """
2594
970
  t = time.time()
2595
971
  params = {"_": t}
2596
972
  res = requests.get(
2597
- "https://cdn.jin10.com/data_center/reports/usa_oil.json", params=params
973
+ url="https://cdn.jin10.com/data_center/reports/usa_oil.json", params=params
2598
974
  )
2599
975
  temp_df = pd.DataFrame(res.json().get("values")).T
2600
976
  big_df = pd.DataFrame()
2601
- big_df["美国国内原油总量_产量"] = temp_df["美国国内原油总量"].apply(lambda x: x[0])
2602
- big_df["美国国内原油总量_变化"] = temp_df["美国国内原油总量"].apply(lambda x: x[1])
2603
- big_df["美国本土48州原油产量_产量"] = temp_df["美国本土48州原油产量"].apply(lambda x: x[0])
2604
- big_df["美国本土48州原油产量_变化"] = temp_df["美国本土48州原油产量"].apply(lambda x: x[1])
2605
- big_df["美国阿拉斯加州原油产量_产量"] = temp_df["美国阿拉斯加州原油产量"].apply(lambda x: x[0])
2606
- big_df["美国阿拉斯加州原油产量_变化"] = temp_df["美国阿拉斯加州原油产量"].apply(lambda x: x[1])
977
+ big_df["美国国内原油总量-产量"] = temp_df["美国国内原油总量"].apply(lambda x: x[0])
978
+ big_df["美国国内原油总量-变化"] = temp_df["美国国内原油总量"].apply(lambda x: x[1])
979
+ big_df["美国本土48州原油产量-产量"] = temp_df["美国本土48州原油产量"].apply(
980
+ lambda x: x[0]
981
+ )
982
+ big_df["美国本土48州原油产量-变化"] = temp_df["美国本土48州原油产量"].apply(
983
+ lambda x: x[1]
984
+ )
985
+ big_df["美国阿拉斯加州原油产量-产量"] = temp_df["美国阿拉斯加州原油产量"].apply(
986
+ lambda x: x[0]
987
+ )
988
+ big_df["美国阿拉斯加州原油产量-变化"] = temp_df["美国阿拉斯加州原油产量"].apply(
989
+ lambda x: x[1]
990
+ )
2607
991
  big_df = big_df.astype("float")
992
+ big_df.reset_index(inplace=True)
993
+ big_df.rename(columns={"index": "日期"}, inplace=True)
994
+ big_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
2608
995
  return big_df
2609
996
 
2610
997
 
@@ -2613,24 +1000,27 @@ def macro_usa_cftc_nc_holding() -> pd.DataFrame:
2613
1000
  """
2614
1001
  美国商品期货交易委员会CFTC外汇类非商业持仓报告, 数据区间从 19830107-至今
2615
1002
  https://datacenter.jin10.com/reportType/dc_cftc_nc_report
2616
- https://cdn.jin10.com/data_center/reports/cftc_4.json?_=1591535493741
1003
+ :return: 美国商品期货交易委员会CFTC外汇类非商业持仓报告
2617
1004
  :return: pandas.DataFrame
2618
1005
  """
2619
1006
  t = time.time()
2620
1007
  params = {"_": str(int(round(t * 1000)))}
2621
1008
  r = requests.get(
2622
- "https://cdn.jin10.com/data_center/reports/cftc_4.json", params=params
1009
+ url="https://cdn.jin10.com/data_center/reports/cftc_4.json", params=params
2623
1010
  )
2624
1011
  json_data = r.json()
2625
1012
  temp_df = pd.DataFrame(json_data["values"]).T
2626
- temp_df.fillna("[0, 0, 0]", inplace=True)
1013
+ temp_df.fillna(value="[0, 0, 0]", inplace=True)
2627
1014
  big_df = pd.DataFrame()
2628
1015
  for item in temp_df.columns:
2629
1016
  for i in range(3):
2630
1017
  inner_temp_df = temp_df.loc[:, item].apply(lambda x: eval(str(x))[i])
2631
1018
  inner_temp_df.name = inner_temp_df.name + "-" + json_data["keys"][i]["name"]
2632
- big_df = pd.concat([big_df, inner_temp_df], axis=1)
2633
- big_df.sort_index(inplace=True)
1019
+ big_df = pd.concat(objs=[big_df, inner_temp_df], axis=1)
1020
+ big_df = big_df.astype("float")
1021
+ big_df.reset_index(inplace=True)
1022
+ big_df.rename(columns={"index": "日期"}, inplace=True)
1023
+ big_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
2634
1024
  return big_df
2635
1025
 
2636
1026
 
@@ -2639,24 +1029,27 @@ def macro_usa_cftc_c_holding() -> pd.DataFrame:
2639
1029
  """
2640
1030
  美国商品期货交易委员会CFTC商品类非商业持仓报告, 数据区间从 19830107-至今
2641
1031
  https://datacenter.jin10.com/reportType/dc_cftc_c_report
2642
- https://cdn.jin10.com/data_center/reports/cftc_2.json?_=1591536282271
1032
+ :return: 美国商品期货交易委员会CFTC外汇类非商业持仓报告
2643
1033
  :return: pandas.DataFrame
2644
1034
  """
2645
1035
  t = time.time()
2646
1036
  params = {"_": str(int(round(t * 1000)))}
2647
1037
  r = requests.get(
2648
- "https://cdn.jin10.com/data_center/reports/cftc_2.json", params=params
1038
+ url="https://cdn.jin10.com/data_center/reports/cftc_2.json", params=params
2649
1039
  )
2650
1040
  json_data = r.json()
2651
1041
  temp_df = pd.DataFrame(json_data["values"]).T
2652
- temp_df.fillna("[0, 0, 0]", inplace=True)
1042
+ temp_df.fillna(value="[0, 0, 0]", inplace=True)
2653
1043
  big_df = pd.DataFrame()
2654
1044
  for item in temp_df.columns:
2655
1045
  for i in range(3):
2656
1046
  inner_temp_df = temp_df.loc[:, item].apply(lambda x: eval(str(x))[i])
2657
1047
  inner_temp_df.name = inner_temp_df.name + "-" + json_data["keys"][i]["name"]
2658
- big_df = pd.concat([big_df, inner_temp_df], axis=1)
2659
- big_df.sort_index(inplace=True)
1048
+ big_df = pd.concat(objs=[big_df, inner_temp_df], axis=1)
1049
+ big_df = big_df.astype("float")
1050
+ big_df.reset_index(inplace=True)
1051
+ big_df.rename(columns={"index": "日期"}, inplace=True)
1052
+ big_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
2660
1053
  return big_df
2661
1054
 
2662
1055
 
@@ -2665,24 +1058,27 @@ def macro_usa_cftc_merchant_currency_holding() -> pd.DataFrame:
2665
1058
  """
2666
1059
  美国商品期货交易委员会CFTC外汇类商业持仓报告, 数据区间从 19860115-至今
2667
1060
  https://datacenter.jin10.com/reportType/dc_cftc_merchant_currency
2668
- https://cdn.jin10.com/data_center/reports/cftc_3.json?_=1591536389283
1061
+ :return: 美国商品期货交易委员会CFTC外汇类商业持仓报告
2669
1062
  :return: pandas.DataFrame
2670
1063
  """
2671
1064
  t = time.time()
2672
1065
  params = {"_": str(int(round(t * 1000)))}
2673
1066
  r = requests.get(
2674
- "https://cdn.jin10.com/data_center/reports/cftc_3.json", params=params
1067
+ url="https://cdn.jin10.com/data_center/reports/cftc_3.json", params=params
2675
1068
  )
2676
1069
  json_data = r.json()
2677
1070
  temp_df = pd.DataFrame(json_data["values"]).T
2678
- temp_df.fillna("[0, 0, 0]", inplace=True)
1071
+ temp_df.fillna(value="[0, 0, 0]", inplace=True)
2679
1072
  big_df = pd.DataFrame()
2680
1073
  for item in temp_df.columns:
2681
1074
  for i in range(3):
2682
1075
  inner_temp_df = temp_df.loc[:, item].apply(lambda x: eval(str(x))[i])
2683
1076
  inner_temp_df.name = inner_temp_df.name + "-" + json_data["keys"][i]["name"]
2684
- big_df = pd.concat([big_df, inner_temp_df], axis=1)
2685
- big_df.sort_index(inplace=True)
1077
+ big_df = pd.concat(objs=[big_df, inner_temp_df], axis=1)
1078
+ big_df = big_df.astype("float")
1079
+ big_df.reset_index(inplace=True)
1080
+ big_df.rename(columns={"index": "日期"}, inplace=True)
1081
+ big_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
2686
1082
  return big_df
2687
1083
 
2688
1084
 
@@ -2691,53 +1087,55 @@ def macro_usa_cftc_merchant_goods_holding() -> pd.DataFrame:
2691
1087
  """
2692
1088
  美国商品期货交易委员会CFTC商品类商业持仓报告, 数据区间从 19860115-至今
2693
1089
  https://datacenter.jin10.com/reportType/dc_cftc_merchant_goods
2694
- https://cdn.jin10.com/data_center/reports/cftc_1.json?_=1591536502095
2695
1090
  :return: 美国商品期货交易委员会CFTC商品类商业持仓报告
2696
1091
  :rtype: pandas.DataFrame
2697
1092
  """
2698
1093
  t = time.time()
2699
1094
  params = {"_": str(int(round(t * 1000)))}
2700
1095
  r = requests.get(
2701
- "https://cdn.jin10.com/data_center/reports/cftc_1.json", params=params
1096
+ url="https://cdn.jin10.com/data_center/reports/cftc_1.json", params=params
2702
1097
  )
2703
1098
  json_data = r.json()
2704
1099
  temp_df = pd.DataFrame(json_data["values"]).T
2705
- temp_df.fillna("[0, 0, 0]", inplace=True)
1100
+ temp_df.fillna(value="[0, 0, 0]", inplace=True)
2706
1101
  big_df = pd.DataFrame()
2707
1102
  for item in temp_df.columns:
2708
1103
  for i in range(3):
2709
1104
  inner_temp_df = temp_df.loc[:, item].apply(lambda x: eval(str(x))[i])
2710
1105
  inner_temp_df.name = inner_temp_df.name + "-" + json_data["keys"][i]["name"]
2711
- big_df = pd.concat([big_df, inner_temp_df], axis=1)
2712
- big_df.sort_index(inplace=True)
1106
+ big_df = pd.concat(objs=[big_df, inner_temp_df], axis=1)
1107
+ big_df = big_df.astype("float")
1108
+ big_df.reset_index(inplace=True)
1109
+ big_df.rename(columns={"index": "日期"}, inplace=True)
1110
+ big_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
2713
1111
  return big_df
2714
1112
 
2715
1113
 
2716
1114
  # 金十数据中心-CME-贵金属
2717
- # def macro_usa_cme_merchant_goods_holding():
2718
- # """
2719
- # CME-贵金属, 数据区间从 19860115-至今
2720
- # https://datacenter.jin10.com/org
2721
- # https://cdn.jin10.com/data_center/reports/cme_3.json?_=1591536643385
2722
- # :return: pandas.DataFrame
2723
- # """
2724
- # t = time.time()
2725
- # params = {
2726
- # "_": str(int(round(t * 1000)))
2727
- # }
2728
- # r = requests.get("https://cdn.jin10.com/data_center/reports/cme_3.json", params=params)
2729
- # json_data = r.json()
2730
- # json_data["values"].keys()
2731
- # temp_df = pd.DataFrame(json_data["values"]).T
2732
- # temp_df.fillna("[0, 0, 0]", inplace=True)
2733
- # big_df = pd.DataFrame()
2734
- # for item in temp_df.columns:
2735
- # for i in range(3):
2736
- # inner_temp_df = temp_df.loc[:, item].apply(lambda x: eval(str(x))[i])
2737
- # inner_temp_df.name = inner_temp_df.name + "-" + json_data["keys"][i]["name"]
2738
- # big_df = pd.concat([big_df, inner_temp_df], axis=1)
2739
- # big_df.sort_index(inplace=True)
2740
- # return big_df
1115
+ def macro_usa_cme_merchant_goods_holding():
1116
+ """
1117
+ CME-贵金属, 数据区间从 20180405-至今
1118
+ https://datacenter.jin10.com/org
1119
+ :return: CME-贵金属
1120
+ :return: pandas.DataFrame
1121
+ """
1122
+ t = time.time()
1123
+ params = {"_": str(int(round(t * 1000)))}
1124
+ r = requests.get(
1125
+ url="https://cdn.jin10.com/data_center/reports/cme_3.json", params=params
1126
+ )
1127
+ json_data = r.json()
1128
+ big_df = pd.DataFrame()
1129
+ for item in json_data["values"].keys():
1130
+ temp_df = pd.DataFrame(json_data["values"][item])
1131
+ temp_df["日期"] = item
1132
+ big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
1133
+
1134
+ big_df.columns = ["pz", "tc", "-", "-", "-", "成交量", "-", "-", "日期"]
1135
+ big_df["品种"] = big_df["pz"] + "-" + big_df["tc"]
1136
+ big_df = big_df[["日期", "品种", "成交量"]]
1137
+ big_df.sort_values(["日期"], ignore_index=True, inplace=True)
1138
+ return big_df
2741
1139
 
2742
1140
 
2743
1141
  if __name__ == "__main__":
@@ -2748,100 +1146,131 @@ if __name__ == "__main__":
2748
1146
  # 金十数据中心-经济指标-美国-经济状况-美国GDP
2749
1147
  macro_usa_gdp_monthly_df = macro_usa_gdp_monthly()
2750
1148
  print(macro_usa_gdp_monthly_df)
1149
+
2751
1150
  # 金十数据中心-经济指标-美国-物价水平-美国CPI月率报告
2752
1151
  macro_usa_cpi_monthly_df = macro_usa_cpi_monthly()
2753
1152
  print(macro_usa_cpi_monthly_df)
1153
+
2754
1154
  # 金十数据中心-经济指标-美国-物价水平-美国核心CPI月率报告
2755
1155
  macro_usa_core_cpi_monthly_df = macro_usa_core_cpi_monthly()
2756
1156
  print(macro_usa_core_cpi_monthly_df)
1157
+
2757
1158
  # 金十数据中心-经济指标-美国-物价水平-美国个人支出月率报告
2758
1159
  macro_usa_personal_spending_df = macro_usa_personal_spending()
2759
1160
  print(macro_usa_personal_spending_df)
1161
+
2760
1162
  # 金十数据中心-经济指标-美国-物价水平-美国零售销售月率报告
2761
1163
  macro_usa_retail_sales_df = macro_usa_retail_sales()
2762
1164
  print(macro_usa_retail_sales_df)
1165
+
2763
1166
  # 金十数据中心-经济指标-美国-物价水平-美国进口物价指数报告
2764
1167
  macro_usa_import_price_df = macro_usa_import_price()
2765
1168
  print(macro_usa_import_price_df)
1169
+
2766
1170
  # 金十数据中心-经济指标-美国-物价水平-美国出口价格指数报告
2767
1171
  macro_usa_export_price_df = macro_usa_export_price()
2768
1172
  print(macro_usa_export_price_df)
1173
+
2769
1174
  # 金十数据中心-经济指标-美国-劳动力市场-LMCI
2770
1175
  macro_usa_lmci_df = macro_usa_lmci()
2771
1176
  print(macro_usa_lmci_df)
1177
+
2772
1178
  # 金十数据中心-经济指标-美国-劳动力市场-失业率-美国失业率报告
2773
1179
  macro_usa_unemployment_rate_df = macro_usa_unemployment_rate()
2774
1180
  print(macro_usa_unemployment_rate_df)
1181
+
2775
1182
  # 金十数据中心-经济指标-美国-劳动力市场-失业率-美国挑战者企业裁员人数报告
2776
1183
  macro_usa_job_cuts_df = macro_usa_job_cuts()
2777
1184
  print(macro_usa_job_cuts_df)
1185
+
2778
1186
  # 金十数据中心-经济指标-美国-劳动力市场-就业人口-美国非农就业人数报告
2779
1187
  macro_usa_non_farm_df = macro_usa_non_farm()
2780
1188
  print(macro_usa_non_farm_df)
1189
+
2781
1190
  # 金十数据中心-经济指标-美国-劳动力市场-就业人口-美国ADP就业人数报告
2782
1191
  macro_usa_adp_employment_df = macro_usa_adp_employment()
2783
1192
  print(macro_usa_adp_employment_df)
1193
+
2784
1194
  # 金十数据中心-经济指标-美国-劳动力市场-消费者收入与支出-美国核心PCE物价指数年率报告
2785
1195
  macro_usa_core_pce_price_df = macro_usa_core_pce_price()
2786
1196
  print(macro_usa_core_pce_price_df)
1197
+
2787
1198
  # 金十数据中心-经济指标-美国-劳动力市场-消费者收入与支出-美国实际个人消费支出季率初值报告
2788
1199
  macro_usa_real_consumer_spending_df = macro_usa_real_consumer_spending()
2789
1200
  print(macro_usa_real_consumer_spending_df)
1201
+
2790
1202
  # 金十数据中心-经济指标-美国-贸易状况-美国贸易帐报告
2791
1203
  macro_usa_trade_balance_df = macro_usa_trade_balance()
2792
1204
  print(macro_usa_trade_balance_df)
1205
+
2793
1206
  # 金十数据中心-经济指标-美国-贸易状况-美国经常帐报告
2794
1207
  macro_usa_current_account_df = macro_usa_current_account()
2795
1208
  print(macro_usa_current_account_df)
1209
+
2796
1210
  # 金十数据中心-经济指标-美国-产业指标-制造业-贝克休斯钻井报告
2797
1211
  macro_usa_rig_count_df = macro_usa_rig_count()
2798
1212
  print(macro_usa_rig_count_df)
2799
- # 金十数据中心-经济指标-美国-产业指标-制造业-美国个人支出月率报告
1213
+
2800
1214
  # 金十数据中心-经济指标-美国-产业指标-制造业-美国生产者物价指数(PPI)报告
2801
1215
  macro_usa_ppi_df = macro_usa_ppi()
2802
1216
  print(macro_usa_ppi_df)
1217
+
2803
1218
  # 金十数据中心-经济指标-美国-产业指标-制造业-美国核心生产者物价指数(PPI)报告
2804
1219
  macro_usa_core_ppi_df = macro_usa_core_ppi()
2805
1220
  print(macro_usa_core_ppi_df)
1221
+
2806
1222
  # 金十数据中心-经济指标-美国-产业指标-制造业-美国API原油库存报告
2807
1223
  macro_usa_api_crude_stock_df = macro_usa_api_crude_stock()
2808
1224
  print(macro_usa_api_crude_stock_df)
1225
+
2809
1226
  # 金十数据中心-经济指标-美国-产业指标-制造业-美国Markit制造业PMI初值报告
2810
1227
  macro_usa_pmi_df = macro_usa_pmi()
2811
1228
  print(macro_usa_pmi_df)
1229
+
2812
1230
  # 金十数据中心-经济指标-美国-产业指标-制造业-美国ISM制造业PMI报告
2813
1231
  macro_usa_ism_pmi_df = macro_usa_ism_pmi()
2814
1232
  print(macro_usa_ism_pmi_df)
1233
+
2815
1234
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国NAHB房产市场指数报告
2816
1235
  macro_usa_nahb_house_market_index_df = macro_usa_nahb_house_market_index()
2817
1236
  print(macro_usa_nahb_house_market_index_df)
1237
+
2818
1238
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国新屋开工总数年化报告
2819
1239
  macro_usa_house_starts_df = macro_usa_house_starts()
2820
1240
  print(macro_usa_house_starts_df)
1241
+
2821
1242
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国新屋销售总数年化报告
2822
1243
  macro_usa_new_home_sales_df = macro_usa_new_home_sales()
2823
1244
  print(macro_usa_new_home_sales_df)
1245
+
2824
1246
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国营建许可总数报告
2825
1247
  macro_usa_building_permits_df = macro_usa_building_permits()
2826
1248
  print(macro_usa_building_permits_df)
1249
+
2827
1250
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国成屋销售总数年化报告
2828
1251
  macro_usa_exist_home_sales_df = macro_usa_exist_home_sales()
2829
1252
  print(macro_usa_exist_home_sales_df)
1253
+
2830
1254
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国FHFA房价指数月率报告
2831
1255
  macro_usa_house_price_index_df = macro_usa_house_price_index()
2832
1256
  print(macro_usa_house_price_index_df)
1257
+
2833
1258
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国S&P/CS20座大城市房价指数年率报告
2834
1259
  macro_usa_spcs20_df = macro_usa_spcs20()
2835
1260
  print(macro_usa_spcs20_df)
1261
+
2836
1262
  # 金十数据中心-经济指标-美国-产业指标-房地产-美国成屋签约销售指数月率报告
2837
1263
  macro_usa_pending_home_sales_df = macro_usa_pending_home_sales()
2838
1264
  print(macro_usa_pending_home_sales_df)
1265
+
2839
1266
  # 金十数据中心-经济指标-美国-领先指标-美国谘商会消费者信心指数报告
2840
1267
  macro_usa_cb_consumer_confidence_df = macro_usa_cb_consumer_confidence()
2841
1268
  print(macro_usa_cb_consumer_confidence_df)
1269
+
2842
1270
  # 金十数据中心-经济指标-美国-领先指标-美国NFIB小型企业信心指数报告
2843
1271
  macro_usa_nfib_small_business_df = macro_usa_nfib_small_business()
2844
1272
  print(macro_usa_nfib_small_business_df)
1273
+
2845
1274
  # 金十数据中心-经济指标-美国-领先指标-美国密歇根大学消费者信心指数初值报告
2846
1275
  macro_usa_michigan_consumer_sentiment_df = macro_usa_michigan_consumer_sentiment()
2847
1276
  print(macro_usa_michigan_consumer_sentiment_df)
@@ -2861,14 +1290,21 @@ if __name__ == "__main__":
2861
1290
  # 金十数据中心-美国商品期货交易委员会CFTC外汇类非商业持仓报告
2862
1291
  macro_usa_cftc_nc_holding_df = macro_usa_cftc_nc_holding()
2863
1292
  print(macro_usa_cftc_nc_holding_df)
1293
+
2864
1294
  # 金十数据中心-美国商品期货交易委员会CFTC商品类非商业持仓报告
2865
1295
  macro_usa_cftc_c_holding_df = macro_usa_cftc_c_holding()
2866
1296
  print(macro_usa_cftc_c_holding_df)
1297
+
2867
1298
  # 金十数据中心-美国商品期货交易委员会CFTC外汇类商业持仓报告
2868
1299
  macro_usa_cftc_merchant_currency_holding_df = (
2869
1300
  macro_usa_cftc_merchant_currency_holding()
2870
1301
  )
2871
1302
  print(macro_usa_cftc_merchant_currency_holding_df)
1303
+
2872
1304
  # 金十数据中心-美国商品期货交易委员会CFTC商品类商业持仓报告
2873
1305
  macro_usa_cftc_merchant_goods_holding_df = macro_usa_cftc_merchant_goods_holding()
2874
1306
  print(macro_usa_cftc_merchant_goods_holding_df)
1307
+
1308
+ # 金十数据中心-CME-贵金属
1309
+ macro_usa_cme_merchant_goods_holding_df = macro_usa_cme_merchant_goods_holding()
1310
+ print(macro_usa_cme_merchant_goods_holding_df)