akshare 1.12.99__py3-none-any.whl → 1.15.72__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.
- akshare/__init__.py +441 -138
- akshare/air/air_hebei.py +79 -53
- akshare/air/air_zhenqi.py +29 -43
- akshare/air/sunrise_tad.py +32 -17
- akshare/bank/bank_cbirc_2020.py +12 -9
- akshare/bond/bond_cb_ths.py +17 -9
- akshare/bond/bond_china.py +38 -39
- akshare/bond/bond_china_money.py +75 -48
- akshare/bond/bond_info_cm.py +28 -8
- akshare/bond/bond_issue_cninfo.py +73 -30
- akshare/bond/bond_zh_cov.py +1 -1
- akshare/bond/bond_zh_sina.py +57 -51
- akshare/cal/__init__.py +0 -0
- akshare/cal/rv.py +170 -0
- akshare/cost/cost_living.py +7 -5
- akshare/currency/currency_safe.py +7 -6
- akshare/data/cninfo.js +15 -0
- akshare/datasets.py +10 -21
- akshare/economic/macro_bank.py +95 -653
- akshare/economic/macro_china.py +772 -1024
- akshare/economic/macro_china_hk.py +65 -243
- akshare/economic/macro_china_nbs.py +24 -7
- akshare/economic/macro_constitute.py +17 -12
- akshare/economic/macro_euro.py +13 -6
- akshare/economic/macro_finance_ths.py +133 -0
- akshare/economic/macro_info_ws.py +100 -0
- akshare/economic/macro_japan.py +5 -4
- akshare/economic/macro_other.py +12 -9
- akshare/economic/macro_usa.py +376 -1940
- akshare/economic/marco_cnbs.py +11 -6
- akshare/energy/energy_carbon.py +94 -125
- akshare/event/migration.py +3 -2
- akshare/exceptions.py +43 -0
- akshare/file_fold/calendar.json +245 -2
- akshare/fortune/fortune_500.py +15 -48
- akshare/fund/fund_amac.py +157 -75
- akshare/fund/fund_em.py +191 -184
- akshare/fund/fund_etf_em.py +16 -15
- akshare/fund/fund_etf_sina.py +71 -23
- akshare/fund/fund_etf_ths.py +93 -0
- akshare/fund/fund_fee_em.py +98 -0
- akshare/fund/fund_portfolio_em.py +60 -50
- akshare/fund/fund_rank_em.py +91 -82
- akshare/fund/fund_report_cninfo.py +63 -48
- akshare/fund/fund_scale_sina.py +20 -10
- akshare/fund/fund_xq.py +139 -109
- akshare/futures/cons.py +8 -31
- akshare/futures/cot.py +185 -137
- akshare/futures/futures_basis.py +97 -32
- akshare/futures/futures_comm_ctp.py +37 -0
- akshare/futures/futures_comm_qihuo.py +74 -45
- akshare/futures/futures_daily_bar.py +121 -184
- akshare/futures/futures_hf_em.py +66 -61
- akshare/futures/futures_hq_sina.py +79 -61
- akshare/futures/futures_index_ccidx.py +6 -3
- akshare/futures/futures_inventory_99.py +61 -272
- akshare/futures/futures_news_shmet.py +4 -2
- akshare/futures/futures_roll_yield.py +12 -25
- akshare/futures/futures_spot_stock_em.py +19 -13
- akshare/futures/futures_stock_js.py +14 -12
- akshare/futures/futures_to_spot.py +38 -33
- akshare/futures/futures_warehouse_receipt.py +75 -71
- akshare/futures/futures_zh_sina.py +5 -5
- akshare/futures/symbol_var.py +18 -13
- akshare/futures_derivative/futures_contract_info_czce.py +60 -52
- akshare/futures_derivative/futures_contract_info_ine.py +43 -34
- akshare/futures_derivative/futures_contract_info_shfe.py +46 -35
- akshare/futures_derivative/futures_cot_sina.py +26 -19
- akshare/futures_derivative/futures_spot_sys.py +21 -8
- akshare/fx/currency_investing.py +19 -285
- akshare/index/index_cflp.py +29 -26
- akshare/index/index_cni.py +86 -88
- akshare/index/index_cons.py +26 -10
- akshare/index/index_cx.py +248 -47
- akshare/index/index_drewry.py +17 -16
- akshare/index/index_option_qvix.py +329 -0
- akshare/index/index_research_fund_sw.py +134 -0
- akshare/index/{index_sw_research.py → index_research_sw.py} +122 -58
- akshare/index/index_spot.py +9 -5
- akshare/index/index_stock_hk.py +35 -16
- akshare/index/index_stock_us_sina.py +1 -1
- akshare/index/index_stock_zh.py +180 -89
- akshare/index/index_stock_zh_csindex.py +15 -369
- akshare/index/index_sw.py +62 -34
- akshare/index/index_yw.py +46 -23
- akshare/index/index_zh_a_scope.py +48 -0
- akshare/index/index_zh_em.py +6 -4
- akshare/interest_rate/interbank_rate_em.py +14 -9
- akshare/movie/artist_yien.py +32 -5
- akshare/movie/movie_yien.py +92 -18
- akshare/movie/video_yien.py +28 -5
- akshare/news/news_baidu.py +78 -44
- akshare/news/news_cctv.py +38 -38
- akshare/news/news_stock.py +6 -3
- akshare/nlp/nlp_interface.py +7 -8
- akshare/option/cons.py +11 -11
- akshare/option/option_comm_qihuo.py +86 -0
- akshare/option/option_commodity.py +178 -51
- akshare/option/option_daily_stats_sse_szse.py +146 -0
- akshare/option/option_em.py +147 -138
- akshare/option/option_finance_sina.py +160 -137
- akshare/option/option_lhb_em.py +62 -56
- akshare/option/option_risk_indicator_sse.py +17 -14
- akshare/other/other_car_cpca.py +934 -0
- akshare/other/{other_car.py → other_car_gasgoo.py} +15 -54
- akshare/qdii/__init__.py +0 -0
- akshare/qdii/qdii_jsl.py +233 -0
- akshare/request.py +117 -0
- akshare/spot/spot_hog_soozhu.py +232 -0
- akshare/spot/spot_price_qh.py +121 -0
- akshare/spot/spot_sge.py +63 -10
- akshare/stock/stock_allotment_cninfo.py +10 -9
- akshare/stock/stock_board_concept_em.py +23 -14
- akshare/stock/stock_board_industry_em.py +40 -34
- akshare/stock/stock_cg_equity_mortgage.py +15 -11
- akshare/stock/stock_cg_guarantee.py +41 -51
- akshare/stock/stock_cg_lawsuit.py +36 -35
- akshare/stock/stock_dividend_cninfo.py +12 -6
- akshare/stock/stock_dzjy_em.py +347 -260
- akshare/stock/stock_fund_em.py +332 -84
- akshare/stock/stock_hk_famous.py +108 -0
- akshare/stock/stock_hk_sina.py +8 -7
- akshare/stock/stock_hold_control_cninfo.py +100 -15
- akshare/stock/stock_hold_control_em.py +4 -3
- akshare/stock/stock_hold_num_cninfo.py +18 -12
- akshare/stock/stock_hot_rank_em.py +2 -1
- akshare/stock/stock_hot_search_baidu.py +5 -2
- akshare/stock/stock_industry_cninfo.py +24 -18
- akshare/stock/stock_industry_pe_cninfo.py +45 -31
- akshare/stock/stock_industry_sw.py +9 -10
- akshare/stock/stock_info.py +25 -15
- akshare/stock/stock_info_em.py +5 -2
- akshare/stock/stock_intraday_em.py +5 -2
- akshare/stock/stock_intraday_sina.py +22 -18
- akshare/stock/stock_ipo_summary_cninfo.py +25 -10
- akshare/stock/stock_new_cninfo.py +32 -19
- akshare/stock/stock_news_cx.py +39 -0
- akshare/stock/stock_profile_cninfo.py +9 -8
- akshare/stock/stock_rank_forecast.py +8 -6
- akshare/stock/stock_share_changes_cninfo.py +18 -14
- akshare/stock/stock_share_hold.py +24 -19
- akshare/stock/stock_summary.py +54 -26
- akshare/stock/stock_us_famous.py +15 -6
- akshare/stock/stock_us_pink.py +7 -5
- akshare/stock/stock_us_sina.py +15 -12
- akshare/stock/stock_xq.py +38 -12
- akshare/stock/stock_zh_a_sina.py +53 -78
- akshare/stock/stock_zh_b_sina.py +32 -55
- akshare/stock/stock_zh_kcb_report.py +11 -9
- akshare/stock/stock_zh_kcb_sina.py +67 -64
- akshare/stock_feature/stock_a_below_net_asset_statistics.py +5 -2
- akshare/stock_feature/stock_a_high_low.py +5 -2
- akshare/stock_feature/stock_a_indicator.py +12 -9
- akshare/stock_feature/stock_a_pe_and_pb.py +27 -6
- akshare/stock_feature/stock_account_em.py +58 -40
- akshare/stock_feature/stock_analyst_em.py +36 -27
- akshare/stock_feature/stock_board_industry_ths.py +136 -400
- akshare/stock_feature/stock_comment_em.py +118 -85
- akshare/stock_feature/stock_concept_futu.py +183 -0
- akshare/stock_feature/stock_cyq_em.py +58 -54
- akshare/stock_feature/stock_disclosure_cninfo.py +147 -102
- akshare/stock_feature/stock_esg_sina.py +216 -11
- akshare/stock_feature/stock_fhps_em.py +60 -25
- akshare/stock_feature/stock_fhps_ths.py +25 -6
- akshare/stock_feature/stock_fund_flow.py +38 -25
- akshare/stock_feature/stock_gdfx_em.py +180 -95
- akshare/stock_feature/stock_gdhs.py +73 -49
- akshare/stock_feature/stock_gpzy_em.py +78 -46
- akshare/stock_feature/stock_hist_em.py +55 -23
- akshare/stock_feature/stock_hk_valuation_baidu.py +20 -8
- akshare/stock_feature/stock_hsgt_em.py +184 -452
- akshare/stock_feature/stock_info.py +52 -29
- akshare/stock_feature/stock_inner_trade_xq.py +39 -31
- akshare/stock_feature/stock_irm_cninfo.py +32 -9
- akshare/stock_feature/stock_jgdy_em.py +41 -38
- akshare/stock_feature/stock_lh_yybpm.py +36 -37
- akshare/stock_feature/stock_lhb_em.py +135 -71
- akshare/stock_feature/stock_lhb_sina.py +93 -46
- akshare/stock_feature/stock_margin_em.py +102 -0
- akshare/stock_feature/{stock_sse_margin.py → stock_margin_sse.py} +21 -15
- akshare/stock_feature/{stock_szse_margin.py → stock_margin_szse.py} +23 -19
- akshare/stock_feature/stock_market_legu.py +13 -8
- akshare/stock_feature/stock_pankou_em.py +72 -34
- akshare/stock_feature/stock_report_em.py +244 -54
- akshare/stock_feature/stock_research_report_em.py +48 -19
- akshare/stock_feature/stock_sns_sseinfo.py +15 -12
- akshare/stock_feature/stock_sy_em.py +86 -33
- akshare/stock_feature/stock_technology_ths.py +152 -120
- akshare/stock_feature/stock_tfp_em.py +35 -13
- akshare/stock_feature/stock_three_report_em.py +119 -77
- akshare/stock_feature/stock_ttm_lyr.py +4 -7
- akshare/stock_feature/stock_value_em.py +83 -0
- akshare/stock_feature/stock_wencai.py +21 -9
- akshare/stock_feature/stock_yjyg_em.py +63 -28
- akshare/stock_feature/stock_zf_pg.py +61 -38
- akshare/stock_feature/stock_zh_valuation_baidu.py +3 -2
- akshare/stock_feature/stock_ztb_em.py +62 -40
- akshare/stock_fundamental/stock_finance.py +150 -58
- akshare/stock_fundamental/stock_finance_ths.py +116 -31
- akshare/stock_fundamental/stock_mda_ym.py +5 -3
- akshare/stock_fundamental/stock_notice.py +29 -15
- akshare/stock_fundamental/stock_profit_forecast_em.py +31 -13
- akshare/stock_fundamental/stock_profit_forecast_ths.py +19 -10
- akshare/stock_fundamental/stock_register_em.py +448 -0
- akshare/stock_fundamental/stock_restricted_em.py +79 -32
- akshare/stock_fundamental/stock_zygc.py +10 -8
- akshare/stock_fundamental/stock_zyjs_ths.py +5 -3
- akshare/tool/trade_date_hist.py +4 -3
- akshare/utils/cons.py +10 -0
- akshare/utils/context.py +43 -0
- akshare/utils/demjson.py +2 -2
- akshare/utils/func.py +26 -0
- akshare/utils/tqdm.py +13 -3
- {akshare-1.12.99.dist-info → akshare-1.15.72.dist-info}/METADATA +52 -69
- akshare-1.15.72.dist-info/RECORD +385 -0
- {akshare-1.12.99.dist-info → akshare-1.15.72.dist-info}/WHEEL +1 -1
- tests/test_func.py +3 -5
- akshare/bond/bond_futures.py +0 -50
- akshare/bond/bond_investing.py +0 -139
- akshare/crypto/crypto_hist_investing.py +0 -249
- akshare/fortune/fortune_it_juzi.py +0 -123
- akshare/futures/futures_international.py +0 -170
- akshare/futures/futures_news_baidu.py +0 -54
- akshare/futures/inventory_data.py +0 -100
- akshare/futures_derivative/futures_index_price_nh.py +0 -61
- akshare/futures_derivative/futures_index_return_nh.py +0 -47
- akshare/futures_derivative/futures_index_volatility_nh.py +0 -51
- akshare/futures_derivative/futures_other_index_nh.py +0 -145
- akshare/index/index_fear_greed_funddb.py +0 -71
- akshare/index/index_investing.py +0 -232
- akshare/sport/sport_olympic_winter.py +0 -39
- akshare/stock_feature/stock_board_concept_ths.py +0 -422
- akshare/stock_fundamental/stock_register.py +0 -292
- akshare-1.12.99.dist-info/RECORD +0 -374
- {akshare-1.12.99.dist-info → akshare-1.15.72.dist-info}/LICENSE +0 -0
- {akshare-1.12.99.dist-info → akshare-1.15.72.dist-info}/top_level.txt +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/
|
|
4
|
+
Date: 2024/10/23 13:00
|
|
5
5
|
Desc: 申万宏源研究-指数系列
|
|
6
|
-
https://www.
|
|
6
|
+
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import math
|
|
9
10
|
|
|
10
11
|
import pandas as pd
|
|
@@ -16,7 +17,7 @@ from akshare.utils.tqdm import get_tqdm
|
|
|
16
17
|
def index_hist_sw(symbol: str = "801030", period: str = "day") -> pd.DataFrame:
|
|
17
18
|
"""
|
|
18
19
|
申万宏源研究-指数发布-指数详情-指数历史数据
|
|
19
|
-
https://www.
|
|
20
|
+
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex/releasedetail?code=801001&name=%E7%94%B3%E4%B8%8750
|
|
20
21
|
:param symbol: 指数代码
|
|
21
22
|
:type symbol: str
|
|
22
23
|
:param period: choice of {"day", "week", "month"}
|
|
@@ -29,15 +30,16 @@ def index_hist_sw(symbol: str = "801030", period: str = "day") -> pd.DataFrame:
|
|
|
29
30
|
"week": "WEEK",
|
|
30
31
|
"month": "MONTH",
|
|
31
32
|
}
|
|
32
|
-
url = "https://www.
|
|
33
|
+
url = "https://www.swsresearch.com/institute-sw/api/index_publish/trend/"
|
|
33
34
|
params = {
|
|
34
35
|
"swindexcode": symbol,
|
|
35
36
|
"period": period_map[period],
|
|
36
37
|
}
|
|
37
38
|
headers = {
|
|
38
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
39
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
40
|
+
"Chrome/114.0.0.0 Safari/537.36",
|
|
39
41
|
}
|
|
40
|
-
r = requests.get(url, params=params, headers=headers)
|
|
42
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
41
43
|
data_json = r.json()
|
|
42
44
|
temp_df = pd.DataFrame(data_json["data"])
|
|
43
45
|
temp_df.rename(
|
|
@@ -79,22 +81,23 @@ def index_hist_sw(symbol: str = "801030", period: str = "day") -> pd.DataFrame:
|
|
|
79
81
|
def index_min_sw(symbol: str = "801001") -> pd.DataFrame:
|
|
80
82
|
"""
|
|
81
83
|
申万宏源研究-指数发布-指数详情-指数分时数据
|
|
82
|
-
https://www.
|
|
84
|
+
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex/releasedetail?code=801001&name=%E7%94%B3%E4%B8%8750
|
|
83
85
|
:param symbol: 指数代码
|
|
84
86
|
:type symbol: str
|
|
85
87
|
:return: 指数分时数据
|
|
86
88
|
:rtype: pandas.DataFrame
|
|
87
89
|
"""
|
|
88
90
|
url = (
|
|
89
|
-
"https://www.
|
|
91
|
+
"https://www.swsresearch.com/institute-sw/api/index_publish/details/timelines/"
|
|
90
92
|
)
|
|
91
93
|
params = {
|
|
92
94
|
"swindexcode": symbol,
|
|
93
95
|
}
|
|
94
96
|
headers = {
|
|
95
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
97
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
98
|
+
"Chrome/114.0.0.0 Safari/537.36"
|
|
96
99
|
}
|
|
97
|
-
r = requests.get(url, params=params, headers=headers)
|
|
100
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
98
101
|
data_json = r.json()
|
|
99
102
|
temp_df = pd.DataFrame(data_json["data"])
|
|
100
103
|
temp_df.rename(
|
|
@@ -124,18 +127,19 @@ def index_min_sw(symbol: str = "801001") -> pd.DataFrame:
|
|
|
124
127
|
def index_component_sw(symbol: str = "801001") -> pd.DataFrame:
|
|
125
128
|
"""
|
|
126
129
|
申万宏源研究-指数发布-指数详情-成分股
|
|
127
|
-
https://www.
|
|
130
|
+
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex/releasedetail?code=801001&name=%E7%94%B3%E4%B8%8750
|
|
128
131
|
:param symbol: 指数代码
|
|
129
132
|
:type symbol: str
|
|
130
133
|
:return: 成分股
|
|
131
134
|
:rtype: pandas.DataFrame
|
|
132
135
|
"""
|
|
133
|
-
url = "https://www.
|
|
136
|
+
url = "https://www.swsresearch.com/institute-sw/api/index_publish/details/component_stocks/"
|
|
134
137
|
params = {"swindexcode": symbol, "page": "1", "page_size": "10000"}
|
|
135
138
|
headers = {
|
|
136
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
139
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
140
|
+
"Chrome/114.0.0.0 Safari/537.36"
|
|
137
141
|
}
|
|
138
|
-
r = requests.get(url, params=params, headers=headers)
|
|
142
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
139
143
|
data_json = r.json()
|
|
140
144
|
temp_df = pd.DataFrame(data_json["data"]["results"])
|
|
141
145
|
temp_df.reset_index(inplace=True)
|
|
@@ -164,21 +168,75 @@ def index_component_sw(symbol: str = "801001") -> pd.DataFrame:
|
|
|
164
168
|
return temp_df
|
|
165
169
|
|
|
166
170
|
|
|
171
|
+
def __index_realtime_sw(symbol: str = "大类风格指数") -> pd.DataFrame:
|
|
172
|
+
"""
|
|
173
|
+
申万宏源研究-申万指数-股票指数
|
|
174
|
+
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex
|
|
175
|
+
:param symbol: choice of {"大类风格指数", "金创指数"}
|
|
176
|
+
:type symbol: str
|
|
177
|
+
:return: 指数系列实时行情数据
|
|
178
|
+
:rtype: pandas.DataFrame
|
|
179
|
+
"""
|
|
180
|
+
url = "https://www.swsresearch.com/insWechatSw/dflgOrJcIndex/pageList"
|
|
181
|
+
payload = {
|
|
182
|
+
"pageNo": 1,
|
|
183
|
+
"pageSize": 10,
|
|
184
|
+
"indexTypeName": symbol,
|
|
185
|
+
"sortField": "",
|
|
186
|
+
"rule": "",
|
|
187
|
+
"indexType": 1,
|
|
188
|
+
}
|
|
189
|
+
headers = {
|
|
190
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
191
|
+
"Chrome/114.0.0.0 Safari/537.36"
|
|
192
|
+
}
|
|
193
|
+
r = requests.post(url, json=payload, headers=headers, verify=False)
|
|
194
|
+
data_json = r.json()
|
|
195
|
+
temp_df = pd.DataFrame(data_json["data"]["list"])
|
|
196
|
+
temp_df.rename(
|
|
197
|
+
columns={
|
|
198
|
+
"swIndexCode": "指数代码",
|
|
199
|
+
"swIndexName": "指数名称",
|
|
200
|
+
"lastCloseIndex": "昨收盘",
|
|
201
|
+
"lastMarkup": "日涨跌幅",
|
|
202
|
+
"yearMarkup": "年涨跌幅",
|
|
203
|
+
},
|
|
204
|
+
inplace=True,
|
|
205
|
+
)
|
|
206
|
+
temp_df = temp_df[
|
|
207
|
+
[
|
|
208
|
+
"指数代码",
|
|
209
|
+
"指数名称",
|
|
210
|
+
"昨收盘",
|
|
211
|
+
"日涨跌幅",
|
|
212
|
+
"年涨跌幅",
|
|
213
|
+
]
|
|
214
|
+
]
|
|
215
|
+
temp_df["昨收盘"] = pd.to_numeric(temp_df["昨收盘"], errors="coerce")
|
|
216
|
+
temp_df["日涨跌幅"] = pd.to_numeric(temp_df["日涨跌幅"], errors="coerce")
|
|
217
|
+
temp_df["年涨跌幅"] = pd.to_numeric(temp_df["年涨跌幅"], errors="coerce")
|
|
218
|
+
return temp_df
|
|
219
|
+
|
|
220
|
+
|
|
167
221
|
def index_realtime_sw(symbol: str = "二级行业") -> pd.DataFrame:
|
|
168
222
|
"""
|
|
169
223
|
申万宏源研究-指数系列
|
|
170
|
-
https://www.
|
|
171
|
-
:param symbol: choice of {"市场表征", "一级行业", "二级行业", "风格指数"}
|
|
224
|
+
https://www.swsresearch.com/institute_sw/allIndex/releasedIndex
|
|
225
|
+
:param symbol: choice of {"市场表征", "一级行业", "二级行业", "风格指数", "大类风格指数", "金创指数"}
|
|
172
226
|
:type symbol: str
|
|
173
227
|
:return: 指数系列实时行情数据
|
|
174
228
|
:rtype: pandas.DataFrame
|
|
175
229
|
"""
|
|
176
|
-
|
|
230
|
+
if symbol in {"大类风格指数", "金创指数"}:
|
|
231
|
+
temp_df = __index_realtime_sw(symbol)
|
|
232
|
+
return temp_df
|
|
233
|
+
url = "https://www.swsresearch.com/institute-sw/api/index_publish/current/"
|
|
177
234
|
params = {"page": "1", "page_size": "50", "indextype": symbol}
|
|
178
235
|
headers = {
|
|
179
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
236
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
237
|
+
"Chrome/114.0.0.0 Safari/537.36"
|
|
180
238
|
}
|
|
181
|
-
r = requests.get(url, params=params, headers=headers)
|
|
239
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
182
240
|
data_json = r.json()
|
|
183
241
|
total_num = data_json["data"]["count"]
|
|
184
242
|
total_page = math.ceil(total_num / 50)
|
|
@@ -186,10 +244,10 @@ def index_realtime_sw(symbol: str = "二级行业") -> pd.DataFrame:
|
|
|
186
244
|
tqdm = get_tqdm()
|
|
187
245
|
for page in tqdm(range(1, total_page + 1), leave=False):
|
|
188
246
|
params.update({"page": page})
|
|
189
|
-
r = requests.get(url, params=params, headers=headers)
|
|
247
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
190
248
|
data_json = r.json()
|
|
191
249
|
temp_df = pd.DataFrame(data_json["data"]["results"])
|
|
192
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
250
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
193
251
|
big_df.columns = [
|
|
194
252
|
"指数代码",
|
|
195
253
|
"指数名称",
|
|
@@ -225,13 +283,13 @@ def index_realtime_sw(symbol: str = "二级行业") -> pd.DataFrame:
|
|
|
225
283
|
|
|
226
284
|
|
|
227
285
|
def index_analysis_daily_sw(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
286
|
+
symbol: str = "市场表征",
|
|
287
|
+
start_date: str = "20221103",
|
|
288
|
+
end_date: str = "20221103",
|
|
231
289
|
) -> pd.DataFrame:
|
|
232
290
|
"""
|
|
233
291
|
申万宏源研究-指数分析
|
|
234
|
-
https://www.
|
|
292
|
+
https://www.swsresearch.com/institute_sw/allIndex/analysisIndex
|
|
235
293
|
:param symbol: choice of {"市场表征", "一级行业", "二级行业", "风格指数"}
|
|
236
294
|
:type symbol: str
|
|
237
295
|
:param start_date: 开始日期
|
|
@@ -241,7 +299,7 @@ def index_analysis_daily_sw(
|
|
|
241
299
|
:return: 指数分析
|
|
242
300
|
:rtype: pandas.DataFrame
|
|
243
301
|
"""
|
|
244
|
-
url = "https://www.
|
|
302
|
+
url = "https://www.swsresearch.com/institute-sw/api/index_analysis/index_analysis_report/"
|
|
245
303
|
params = {
|
|
246
304
|
"page": "1",
|
|
247
305
|
"page_size": "50",
|
|
@@ -252,9 +310,10 @@ def index_analysis_daily_sw(
|
|
|
252
310
|
"swindexcode": "all",
|
|
253
311
|
}
|
|
254
312
|
headers = {
|
|
255
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
313
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
314
|
+
"Chrome/114.0.0.0 Safari/537.36"
|
|
256
315
|
}
|
|
257
|
-
r = requests.get(url, params=params, headers=headers)
|
|
316
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
258
317
|
data_json = r.json()
|
|
259
318
|
total_num = data_json["data"]["count"]
|
|
260
319
|
total_page = math.ceil(total_num / 50)
|
|
@@ -262,10 +321,10 @@ def index_analysis_daily_sw(
|
|
|
262
321
|
tqdm = get_tqdm()
|
|
263
322
|
for page in tqdm(range(1, total_page + 1), leave=False):
|
|
264
323
|
params.update({"page": page})
|
|
265
|
-
r = requests.get(url, params=params, headers=headers)
|
|
324
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
266
325
|
data_json = r.json()
|
|
267
326
|
temp_df = pd.DataFrame(data_json["data"]["results"])
|
|
268
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
327
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
269
328
|
big_df.rename(
|
|
270
329
|
columns={
|
|
271
330
|
"swindexcode": "指数代码",
|
|
@@ -297,40 +356,43 @@ def index_analysis_daily_sw(
|
|
|
297
356
|
big_df["流通市值"] = pd.to_numeric(big_df["流通市值"], errors="coerce")
|
|
298
357
|
big_df["平均流通市值"] = pd.to_numeric(big_df["平均流通市值"], errors="coerce")
|
|
299
358
|
big_df["股息率"] = pd.to_numeric(big_df["股息率"], errors="coerce")
|
|
300
|
-
big_df.sort_values(["发布日期"], inplace=True, ignore_index=True)
|
|
359
|
+
big_df.sort_values(by=["发布日期"], inplace=True, ignore_index=True)
|
|
301
360
|
return big_df
|
|
302
361
|
|
|
303
362
|
|
|
304
363
|
def index_analysis_week_month_sw(symbol: str = "month") -> pd.DataFrame:
|
|
305
364
|
"""
|
|
306
365
|
申万宏源研究-周/月报表-日期序列
|
|
307
|
-
https://www.
|
|
366
|
+
https://www.swsresearch.com/institute_sw/allIndex/analysisIndex
|
|
308
367
|
:param symbol: choice of {"week", "month"}
|
|
309
368
|
:type symbol: str
|
|
310
369
|
:return: 日期序列
|
|
311
370
|
:rtype: pandas.DataFrame
|
|
312
371
|
"""
|
|
313
|
-
url = "https://www.
|
|
372
|
+
url = "https://www.swsresearch.com/institute-sw/api/index_analysis/week_month_datetime/"
|
|
314
373
|
params = {"type": symbol.upper()}
|
|
315
374
|
headers = {
|
|
316
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
375
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
376
|
+
"Chrome/114.0.0.0 Safari/537.36"
|
|
317
377
|
}
|
|
318
|
-
r = requests.get(url, params=params, headers=headers)
|
|
378
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
319
379
|
data_json = r.json()
|
|
320
380
|
temp_df = pd.DataFrame(data_json["data"])
|
|
321
|
-
temp_df["bargaindate"] = pd.to_datetime(
|
|
381
|
+
temp_df["bargaindate"] = pd.to_datetime(
|
|
382
|
+
temp_df["bargaindate"], errors="coerce"
|
|
383
|
+
).dt.date
|
|
322
384
|
temp_df.columns = ["date"]
|
|
323
|
-
temp_df.sort_values(["date"], inplace=True, ignore_index=True)
|
|
385
|
+
temp_df.sort_values(by=["date"], inplace=True, ignore_index=True)
|
|
324
386
|
return temp_df
|
|
325
387
|
|
|
326
388
|
|
|
327
389
|
def index_analysis_weekly_sw(
|
|
328
|
-
|
|
329
|
-
|
|
390
|
+
symbol: str = "市场表征",
|
|
391
|
+
date: str = "20221104",
|
|
330
392
|
) -> pd.DataFrame:
|
|
331
393
|
"""
|
|
332
394
|
申万宏源研究-指数分析-周报告
|
|
333
|
-
https://www.
|
|
395
|
+
https://www.swsresearch.com/institute_sw/allIndex/analysisIndex
|
|
334
396
|
:param symbol: choice of {"市场表征", "一级行业", "二级行业", "风格指数"}
|
|
335
397
|
:type symbol: str
|
|
336
398
|
:param date: 查询日期; 通过调用 ak.index_analysis_week_month_sw(date="20221104") 接口获取
|
|
@@ -338,7 +400,7 @@ def index_analysis_weekly_sw(
|
|
|
338
400
|
:return: 指数分析
|
|
339
401
|
:rtype: pandas.DataFrame
|
|
340
402
|
"""
|
|
341
|
-
url = "https://www.
|
|
403
|
+
url = "https://www.swsresearch.com/institute-sw/api/index_analysis/index_analysis_reports/"
|
|
342
404
|
params = {
|
|
343
405
|
"page": "1",
|
|
344
406
|
"page_size": "50",
|
|
@@ -348,9 +410,10 @@ def index_analysis_weekly_sw(
|
|
|
348
410
|
"swindexcode": "all",
|
|
349
411
|
}
|
|
350
412
|
headers = {
|
|
351
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
413
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
414
|
+
"Chrome/114.0.0.0 Safari/537.36"
|
|
352
415
|
}
|
|
353
|
-
r = requests.get(url, params=params, headers=headers)
|
|
416
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
354
417
|
data_json = r.json()
|
|
355
418
|
total_num = data_json["data"]["count"]
|
|
356
419
|
total_page = math.ceil(total_num / 50)
|
|
@@ -358,10 +421,10 @@ def index_analysis_weekly_sw(
|
|
|
358
421
|
tqdm = get_tqdm()
|
|
359
422
|
for page in tqdm(range(1, total_page + 1), leave=False):
|
|
360
423
|
params.update({"page": page})
|
|
361
|
-
r = requests.get(url, params=params, headers=headers)
|
|
424
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
362
425
|
data_json = r.json()
|
|
363
426
|
temp_df = pd.DataFrame(data_json["data"]["results"])
|
|
364
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
427
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
365
428
|
big_df.rename(
|
|
366
429
|
columns={
|
|
367
430
|
"swindexcode": "指数代码",
|
|
@@ -394,17 +457,17 @@ def index_analysis_weekly_sw(
|
|
|
394
457
|
big_df["平均流通市值"] = pd.to_numeric(big_df["平均流通市值"], errors="coerce")
|
|
395
458
|
big_df["股息率"] = pd.to_numeric(big_df["股息率"], errors="coerce")
|
|
396
459
|
|
|
397
|
-
big_df.sort_values(["发布日期"], inplace=True, ignore_index=True)
|
|
460
|
+
big_df.sort_values(by=["发布日期"], inplace=True, ignore_index=True)
|
|
398
461
|
return big_df
|
|
399
462
|
|
|
400
463
|
|
|
401
464
|
def index_analysis_monthly_sw(
|
|
402
|
-
|
|
403
|
-
|
|
465
|
+
symbol: str = "市场表征",
|
|
466
|
+
date: str = "20221031",
|
|
404
467
|
) -> pd.DataFrame:
|
|
405
468
|
"""
|
|
406
469
|
申万宏源研究-指数分析-月报告
|
|
407
|
-
https://www.
|
|
470
|
+
https://www.swsresearch.com/institute_sw/allIndex/analysisIndex
|
|
408
471
|
:param symbol: choice of {"市场表征", "一级行业", "二级行业", "风格指数"}
|
|
409
472
|
:type symbol: str
|
|
410
473
|
:param date: 查询日期; 通过调用 ak.index_analysis_week_month_sw() 接口获取
|
|
@@ -412,7 +475,7 @@ def index_analysis_monthly_sw(
|
|
|
412
475
|
:return: 指数分析
|
|
413
476
|
:rtype: pandas.DataFrame
|
|
414
477
|
"""
|
|
415
|
-
url = "https://www.
|
|
478
|
+
url = "https://www.swsresearch.com/institute-sw/api/index_analysis/index_analysis_reports/"
|
|
416
479
|
params = {
|
|
417
480
|
"page": "1",
|
|
418
481
|
"page_size": "50",
|
|
@@ -422,9 +485,10 @@ def index_analysis_monthly_sw(
|
|
|
422
485
|
"swindexcode": "all",
|
|
423
486
|
}
|
|
424
487
|
headers = {
|
|
425
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
488
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
489
|
+
"Chrome/114.0.0.0 Safari/537.36"
|
|
426
490
|
}
|
|
427
|
-
r = requests.get(url, params=params, headers=headers)
|
|
491
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
428
492
|
data_json = r.json()
|
|
429
493
|
total_num = data_json["data"]["count"]
|
|
430
494
|
total_page = math.ceil(total_num / 50)
|
|
@@ -432,10 +496,10 @@ def index_analysis_monthly_sw(
|
|
|
432
496
|
tqdm = get_tqdm()
|
|
433
497
|
for page in tqdm(range(1, total_page + 1), leave=False):
|
|
434
498
|
params.update({"page": page})
|
|
435
|
-
r = requests.get(url, params=params, headers=headers)
|
|
499
|
+
r = requests.get(url, params=params, headers=headers, verify=False)
|
|
436
500
|
data_json = r.json()
|
|
437
501
|
temp_df = pd.DataFrame(data_json["data"]["results"])
|
|
438
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
502
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
439
503
|
big_df.rename(
|
|
440
504
|
columns={
|
|
441
505
|
"swindexcode": "指数代码",
|
|
@@ -467,7 +531,7 @@ def index_analysis_monthly_sw(
|
|
|
467
531
|
big_df["流通市值"] = pd.to_numeric(big_df["流通市值"], errors="coerce")
|
|
468
532
|
big_df["平均流通市值"] = pd.to_numeric(big_df["平均流通市值"], errors="coerce")
|
|
469
533
|
big_df["股息率"] = pd.to_numeric(big_df["股息率"], errors="coerce")
|
|
470
|
-
big_df.sort_values(["发布日期"], inplace=True, ignore_index=True)
|
|
534
|
+
big_df.sort_values(by=["发布日期"], inplace=True, ignore_index=True)
|
|
471
535
|
return big_df
|
|
472
536
|
|
|
473
537
|
|
|
@@ -485,7 +549,7 @@ if __name__ == "__main__":
|
|
|
485
549
|
print(index_realtime_sw_df)
|
|
486
550
|
|
|
487
551
|
index_analysis_daily_sw_df = index_analysis_daily_sw(
|
|
488
|
-
symbol="市场表征", start_date="
|
|
552
|
+
symbol="市场表征", start_date="20241025", end_date="20241025"
|
|
489
553
|
)
|
|
490
554
|
print(index_analysis_daily_sw_df)
|
|
491
555
|
|
|
@@ -493,11 +557,11 @@ if __name__ == "__main__":
|
|
|
493
557
|
print(index_analysis_week_month_sw_df)
|
|
494
558
|
|
|
495
559
|
index_analysis_weekly_sw_df = index_analysis_weekly_sw(
|
|
496
|
-
symbol="市场表征", date="
|
|
560
|
+
symbol="市场表征", date="20241025"
|
|
497
561
|
)
|
|
498
562
|
print(index_analysis_weekly_sw_df)
|
|
499
563
|
|
|
500
564
|
index_analysis_monthly_sw_df = index_analysis_monthly_sw(
|
|
501
|
-
symbol="市场表征", date="
|
|
565
|
+
symbol="市场表征", date="20240930"
|
|
502
566
|
)
|
|
503
567
|
print(index_analysis_monthly_sw_df)
|
akshare/index/index_spot.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/12/26 18:30
|
|
5
5
|
Desc: 商品现货价格指数
|
|
6
|
-
|
|
6
|
+
https://finance.sina.com.cn/futuremarket/spotprice.shtml#titlePos_0
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import pandas as pd
|
|
9
10
|
import requests
|
|
10
11
|
|
|
@@ -12,13 +13,13 @@ import requests
|
|
|
12
13
|
def spot_goods(symbol: str = "波罗的海干散货指数") -> pd.DataFrame:
|
|
13
14
|
"""
|
|
14
15
|
新浪财经-商品现货价格指数
|
|
15
|
-
|
|
16
|
+
https://finance.sina.com.cn/futuremarket/spotprice.shtml#titlePos_0
|
|
16
17
|
:param symbol: choice of {"波罗的海干散货指数", "钢坯价格指数", "澳大利亚粉矿价格"}
|
|
17
18
|
:type symbol: str
|
|
18
19
|
:return: 商品现货价格指数
|
|
19
20
|
:rtype: pandas.DataFrame
|
|
20
21
|
"""
|
|
21
|
-
url = "
|
|
22
|
+
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/GoodsIndexService.get_goods_index"
|
|
22
23
|
symbol_url_dict = {
|
|
23
24
|
"波罗的海干散货指数": "BDI",
|
|
24
25
|
"钢坯价格指数": "GP",
|
|
@@ -31,10 +32,13 @@ def spot_goods(symbol: str = "波罗的海干散货指数") -> pd.DataFrame:
|
|
|
31
32
|
temp_df = pd.DataFrame(data_json["result"]["data"]["data"])
|
|
32
33
|
temp_df = temp_df[["opendate", "price", "zde", "zdf"]]
|
|
33
34
|
temp_df.columns = ["日期", "指数", "涨跌额", "涨跌幅"]
|
|
34
|
-
temp_df["日期"] = pd.to_datetime(
|
|
35
|
+
temp_df["日期"] = pd.to_datetime(
|
|
36
|
+
temp_df["日期"], format="%Y-%m-%d", errors="coerce"
|
|
37
|
+
).dt.date
|
|
35
38
|
temp_df["指数"] = pd.to_numeric(temp_df["指数"], errors="coerce")
|
|
36
39
|
temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"], errors="coerce")
|
|
37
40
|
temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"], errors="coerce")
|
|
41
|
+
temp_df.dropna(inplace=True, ignore_index=True)
|
|
38
42
|
return temp_df
|
|
39
43
|
|
|
40
44
|
|
akshare/index/index_stock_hk.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/4/14 16:00
|
|
5
5
|
Desc: 港股股票指数数据-新浪-东财
|
|
6
6
|
所有指数-实时行情数据和历史行情数据
|
|
7
7
|
https://finance.sina.com.cn/realstock/company/sz399552/nc.shtml
|
|
@@ -12,12 +12,14 @@ import re
|
|
|
12
12
|
|
|
13
13
|
import pandas as pd
|
|
14
14
|
import requests
|
|
15
|
-
|
|
15
|
+
import py_mini_racer
|
|
16
|
+
|
|
17
|
+
from functools import lru_cache
|
|
16
18
|
|
|
17
19
|
from akshare.stock.cons import hk_js_decode
|
|
18
20
|
|
|
19
21
|
|
|
20
|
-
def _replace_comma(x):
|
|
22
|
+
def _replace_comma(x) -> str:
|
|
21
23
|
"""
|
|
22
24
|
去除单元格中的 ","
|
|
23
25
|
:param x: 单元格元素
|
|
@@ -56,7 +58,12 @@ def stock_hk_index_spot_sina() -> pd.DataFrame:
|
|
|
56
58
|
:return: 所有指数的实时行情数据
|
|
57
59
|
:rtype: pandas.DataFrame
|
|
58
60
|
"""
|
|
59
|
-
url =
|
|
61
|
+
url = (
|
|
62
|
+
"https://hq.sinajs.cn/rn=mtf2t&list=hkCES100,hkCES120,hkCES280,hkCES300,hkCESA80,hkCESG10,"
|
|
63
|
+
"hkCESHKM,hkCSCMC,hkCSHK100,hkCSHKDIV,hkCSHKLC,hkCSHKLRE,hkCSHKMCS,hkCSHKME,hkCSHKPE,hkCSHKSE,"
|
|
64
|
+
"hkCSI300,hkCSRHK50,hkGEM,hkHKL,hkHSCCI,hkHSCEI,hkHSI,hkHSMBI,hkHSMOGI,hkHSMPI,hkHSTECH,hkSSE180,"
|
|
65
|
+
"hkSSE180GV,hkSSE380,hkSSE50,hkSSECEQT,hkSSECOMP,hkSSEDIV,hkSSEITOP,hkSSEMCAP,hkSSEMEGA,hkVHSI"
|
|
66
|
+
)
|
|
60
67
|
headers = {"Referer": "https://vip.stock.finance.sina.com.cn/"}
|
|
61
68
|
r = requests.get(url, headers=headers)
|
|
62
69
|
data_text = r.text
|
|
@@ -128,8 +135,7 @@ def stock_hk_index_daily_sina(symbol: str = "CES100") -> pd.DataFrame:
|
|
|
128
135
|
"d", res.text.split("=")[1].split(";")[0].replace('"', "")
|
|
129
136
|
) # 执行js解密代码
|
|
130
137
|
temp_df = pd.DataFrame(dict_list)
|
|
131
|
-
temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
|
|
132
|
-
|
|
138
|
+
temp_df["date"] = pd.to_datetime(temp_df["date"], errors="coerce").dt.date
|
|
133
139
|
temp_df["open"] = pd.to_numeric(temp_df["open"], errors="coerce")
|
|
134
140
|
temp_df["close"] = pd.to_numeric(temp_df["close"], errors="coerce")
|
|
135
141
|
temp_df["high"] = pd.to_numeric(temp_df["high"], errors="coerce")
|
|
@@ -157,7 +163,8 @@ def stock_hk_index_spot_em() -> pd.DataFrame:
|
|
|
157
163
|
"wbp2u": "|0|0|0|web",
|
|
158
164
|
"fid": "f3",
|
|
159
165
|
"fs": "m:124,m:125,m:305",
|
|
160
|
-
"fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,
|
|
166
|
+
"fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,"
|
|
167
|
+
"f26,f22,f33,f11,f62,f128,f136,f115,f152",
|
|
161
168
|
"_": "1683800547682",
|
|
162
169
|
}
|
|
163
170
|
r = requests.get(url, params=params)
|
|
@@ -212,6 +219,23 @@ def stock_hk_index_spot_em() -> pd.DataFrame:
|
|
|
212
219
|
return temp_df
|
|
213
220
|
|
|
214
221
|
|
|
222
|
+
@lru_cache()
|
|
223
|
+
def _symbol_code_dict() -> dict:
|
|
224
|
+
"""
|
|
225
|
+
缓存 ak.stock_hk_index_spot_em() 接口中的代码与内部编号
|
|
226
|
+
https://quote.eastmoney.com/center/gridlist.html#hk_index
|
|
227
|
+
:return: 代码与内部编号
|
|
228
|
+
:rtype: dict
|
|
229
|
+
"""
|
|
230
|
+
__stock_hk_index_spot_em_df = stock_hk_index_spot_em()
|
|
231
|
+
symbol_code_dict = dict(
|
|
232
|
+
zip(
|
|
233
|
+
__stock_hk_index_spot_em_df["代码"], __stock_hk_index_spot_em_df["内部编号"]
|
|
234
|
+
)
|
|
235
|
+
)
|
|
236
|
+
return symbol_code_dict
|
|
237
|
+
|
|
238
|
+
|
|
215
239
|
def stock_hk_index_daily_em(symbol: str = "HSTECF2L") -> pd.DataFrame:
|
|
216
240
|
"""
|
|
217
241
|
东方财富网-港股-股票指数数据
|
|
@@ -221,18 +245,13 @@ def stock_hk_index_daily_em(symbol: str = "HSTECF2L") -> pd.DataFrame:
|
|
|
221
245
|
:return: 指数数据
|
|
222
246
|
:rtype: pandas.DataFrame
|
|
223
247
|
"""
|
|
224
|
-
|
|
225
|
-
symbol_code_dict = dict(
|
|
226
|
-
zip(
|
|
227
|
-
__stock_hk_index_spot_em_df["代码"], __stock_hk_index_spot_em_df["内部编号"]
|
|
228
|
-
)
|
|
229
|
-
)
|
|
248
|
+
symbol_code_dict = _symbol_code_dict()
|
|
230
249
|
symbol_code_dict.update(
|
|
231
250
|
{
|
|
232
251
|
"HSAHP": "100",
|
|
233
252
|
}
|
|
234
253
|
)
|
|
235
|
-
symbol_str = symbol_code_dict[symbol]
|
|
254
|
+
symbol_str = f"{symbol_code_dict[symbol]}.{symbol}"
|
|
236
255
|
url = "https://push2his.eastmoney.com/api/qt/stock/kline/get"
|
|
237
256
|
params = {
|
|
238
257
|
"secid": symbol_str,
|
|
@@ -283,5 +302,5 @@ if __name__ == "__main__":
|
|
|
283
302
|
stock_hk_index_spot_em_df = stock_hk_index_spot_em()
|
|
284
303
|
print(stock_hk_index_spot_em_df)
|
|
285
304
|
|
|
286
|
-
|
|
287
|
-
print(
|
|
305
|
+
stock_hk_index_daily_em_df = stock_hk_index_daily_em(symbol="HSAHP")
|
|
306
|
+
print(stock_hk_index_daily_em_df)
|