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.
- akshare/__init__.py +442 -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.73.dist-info}/METADATA +52 -69
- akshare-1.15.73.dist-info/RECORD +385 -0
- {akshare-1.12.99.dist-info → akshare-1.15.73.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.73.dist-info}/LICENSE +0 -0
- {akshare-1.12.99.dist-info → akshare-1.15.73.dist-info}/top_level.txt +0 -0
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Date: 2024/1/22 20:30
|
|
5
5
|
Desc: 期货-期转现-交割
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
from io import StringIO, BytesIO
|
|
8
9
|
|
|
9
10
|
import pandas as pd
|
|
@@ -13,7 +14,7 @@ import requests
|
|
|
13
14
|
def futures_to_spot_shfe(date: str = "202312") -> pd.DataFrame:
|
|
14
15
|
"""
|
|
15
16
|
上海期货交易所-期转现
|
|
16
|
-
https://
|
|
17
|
+
https://tsite.shfe.com.cn/statements/dataview.html?paramid=kx
|
|
17
18
|
1、铜、铜(BC)、铝、锌、铅、镍、锡、螺纹钢、线材、热轧卷板、天然橡胶、20号胶、低硫燃料油、燃料油、石油沥青、纸浆、不锈钢的数量单位为:吨;黄金的数量单位为:克;白银的数量单位为:千克;原油的数量单位为:桶。
|
|
18
19
|
2、交割量、期转现量为单向计算。
|
|
19
20
|
:param date: 年月
|
|
@@ -21,9 +22,10 @@ def futures_to_spot_shfe(date: str = "202312") -> pd.DataFrame:
|
|
|
21
22
|
:return: 上海期货交易所期转现
|
|
22
23
|
:rtype: pandas.DataFrame
|
|
23
24
|
"""
|
|
24
|
-
url = f"
|
|
25
|
+
url = f"https://tsite.shfe.com.cn/data/instrument/ExchangeDelivery{date}.dat"
|
|
25
26
|
headers = {
|
|
26
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
27
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
28
|
+
"Chrome/100.0.4896.127 Safari/537.36",
|
|
27
29
|
}
|
|
28
30
|
r = requests.get(url, headers=headers)
|
|
29
31
|
data_json = r.json()
|
|
@@ -46,9 +48,9 @@ def futures_to_spot_shfe(date: str = "202312") -> pd.DataFrame:
|
|
|
46
48
|
"期转现量",
|
|
47
49
|
]
|
|
48
50
|
]
|
|
49
|
-
temp_df[
|
|
50
|
-
temp_df[
|
|
51
|
-
temp_df[
|
|
51
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
52
|
+
temp_df["交割量"] = pd.to_numeric(temp_df["交割量"], errors="coerce")
|
|
53
|
+
temp_df["期转现量"] = pd.to_numeric(temp_df["期转现量"], errors="coerce")
|
|
52
54
|
return temp_df
|
|
53
55
|
|
|
54
56
|
|
|
@@ -84,11 +86,11 @@ def futures_delivery_dce(date: str = "202312") -> pd.DataFrame:
|
|
|
84
86
|
temp_df["交割日期"] = (
|
|
85
87
|
temp_df["交割日期"].astype(str).str.split(".", expand=True).iloc[:, 0]
|
|
86
88
|
)
|
|
87
|
-
temp_df = temp_df[~temp_df[
|
|
89
|
+
temp_df = temp_df[~temp_df["品种"].str.contains("小计|总计")]
|
|
88
90
|
temp_df.reset_index(inplace=True, drop=True)
|
|
89
|
-
temp_df[
|
|
90
|
-
temp_df[
|
|
91
|
-
temp_df[
|
|
91
|
+
temp_df["交割日期"] = pd.to_datetime(temp_df["交割日期"], errors="coerce").dt.date
|
|
92
|
+
temp_df["交割量"] = pd.to_numeric(temp_df["交割量"], errors="coerce")
|
|
93
|
+
temp_df["交割金额"] = pd.to_numeric(temp_df["交割金额"], errors="coerce")
|
|
92
94
|
return temp_df
|
|
93
95
|
|
|
94
96
|
|
|
@@ -114,10 +116,12 @@ def futures_to_spot_dce(date: str = "202312") -> pd.DataFrame:
|
|
|
114
116
|
temp_df["期转现发生日期"] = (
|
|
115
117
|
temp_df["期转现发生日期"].astype(str).str.split(".", expand=True).iloc[:, 0]
|
|
116
118
|
)
|
|
117
|
-
temp_df = temp_df[~temp_df[
|
|
119
|
+
temp_df = temp_df[~temp_df["合约代码"].str.contains("小计|总计")]
|
|
118
120
|
temp_df.reset_index(inplace=True, drop=True)
|
|
119
|
-
temp_df[
|
|
120
|
-
|
|
121
|
+
temp_df["期转现发生日期"] = pd.to_datetime(
|
|
122
|
+
temp_df["期转现发生日期"], errors="coerce"
|
|
123
|
+
).dt.date
|
|
124
|
+
temp_df["期转现数量"] = pd.to_numeric(temp_df["期转现数量"], errors="coerce")
|
|
121
125
|
return temp_df
|
|
122
126
|
|
|
123
127
|
|
|
@@ -142,9 +146,9 @@ def futures_delivery_match_dce(symbol: str = "a") -> pd.DataFrame:
|
|
|
142
146
|
temp_df["配对日期"].astype(str).str.split(".", expand=True).iloc[:, 0]
|
|
143
147
|
)
|
|
144
148
|
temp_df = temp_df.iloc[:-1, :]
|
|
145
|
-
temp_df[
|
|
146
|
-
temp_df[
|
|
147
|
-
temp_df[
|
|
149
|
+
temp_df["配对日期"] = pd.to_datetime(temp_df["配对日期"], errors="coerce").dt.date
|
|
150
|
+
temp_df["配对手数"] = pd.to_numeric(temp_df["配对手数"], errors="coerce")
|
|
151
|
+
temp_df["交割结算价"] = pd.to_numeric(temp_df["交割结算价"], errors="coerce")
|
|
148
152
|
return temp_df
|
|
149
153
|
|
|
150
154
|
|
|
@@ -186,7 +190,7 @@ def futures_to_spot_czce(date: str = "20231228") -> pd.DataFrame:
|
|
|
186
190
|
]
|
|
187
191
|
temp_df["合约数量"] = temp_df["合约数量"].astype(str).str.replace(",", "")
|
|
188
192
|
temp_df["合约数量"] = pd.to_numeric(temp_df["合约数量"], errors="coerce")
|
|
189
|
-
temp_df = temp_df[~temp_df[
|
|
193
|
+
temp_df = temp_df[~temp_df["合约代码"].str.contains("小计|合计")]
|
|
190
194
|
temp_df.reset_index(inplace=True, drop=True)
|
|
191
195
|
return temp_df
|
|
192
196
|
|
|
@@ -208,16 +212,14 @@ def futures_delivery_match_czce(date: str = "20210106") -> pd.DataFrame:
|
|
|
208
212
|
big_df = pd.DataFrame()
|
|
209
213
|
for i, item in enumerate(index_flag):
|
|
210
214
|
try:
|
|
211
|
-
temp_inner_df = temp_df[index_flag[i] + 1: index_flag[i + 1]]
|
|
212
|
-
except:
|
|
213
|
-
temp_inner_df = temp_df[index_flag[i] + 1:]
|
|
215
|
+
temp_inner_df = temp_df[index_flag[i] + 1 : index_flag[i + 1]]
|
|
216
|
+
except: # noqa: E722
|
|
217
|
+
temp_inner_df = temp_df[index_flag[i] + 1 :]
|
|
214
218
|
temp_inner_df.columns = temp_inner_df.iloc[0, :]
|
|
215
219
|
temp_inner_df = temp_inner_df.iloc[1:-1, :]
|
|
216
220
|
temp_inner_df.reset_index(drop=True, inplace=True)
|
|
217
221
|
date_contract_str = (
|
|
218
|
-
temp_df[temp_df.iloc[:, 0].str.contains("配对日期")]
|
|
219
|
-
.iloc[:, 0]
|
|
220
|
-
.values[i]
|
|
222
|
+
temp_df[temp_df.iloc[:, 0].str.contains("配对日期")].iloc[:, 0].values[i]
|
|
221
223
|
)
|
|
222
224
|
inner_date = date_contract_str.split(":")[1].split(" ")[0]
|
|
223
225
|
symbol = date_contract_str.split(":")[-1]
|
|
@@ -268,16 +270,17 @@ def futures_delivery_czce(date: str = "20210112") -> pd.DataFrame:
|
|
|
268
270
|
def futures_delivery_shfe(date: str = "202312") -> pd.DataFrame:
|
|
269
271
|
"""
|
|
270
272
|
上海期货交易所-交割情况表
|
|
271
|
-
https://
|
|
273
|
+
https://tsite.shfe.com.cn/statements/dataview.html?paramid=kx
|
|
272
274
|
注意: 日期 -> 月度统计 -> 下拉到交割情况表
|
|
273
275
|
:param date: 年月日
|
|
274
276
|
:type date: str
|
|
275
277
|
:return: 上海期货交易所-交割情况表
|
|
276
278
|
:rtype: pandas.DataFrame
|
|
277
279
|
"""
|
|
278
|
-
url = f"
|
|
280
|
+
url = f"https://tsite.shfe.com.cn/data/dailydata/{date}monthvarietystatistics.dat"
|
|
279
281
|
headers = {
|
|
280
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
282
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
283
|
+
"Chrome/100.0.4896.127 Safari/537.36",
|
|
281
284
|
}
|
|
282
285
|
r = requests.get(url, headers=headers)
|
|
283
286
|
r.encoding = "utf-8"
|
|
@@ -301,10 +304,14 @@ def futures_delivery_shfe(date: str = "202312") -> pd.DataFrame:
|
|
|
301
304
|
"交割量-累计同比",
|
|
302
305
|
]
|
|
303
306
|
]
|
|
304
|
-
temp_df[
|
|
305
|
-
temp_df[
|
|
306
|
-
temp_df[
|
|
307
|
-
|
|
307
|
+
temp_df["交割量-本月"] = pd.to_numeric(temp_df["交割量-本月"], errors="coerce")
|
|
308
|
+
temp_df["交割量-比重"] = pd.to_numeric(temp_df["交割量-比重"], errors="coerce")
|
|
309
|
+
temp_df["交割量-本年累计"] = pd.to_numeric(
|
|
310
|
+
temp_df["交割量-本年累计"], errors="coerce"
|
|
311
|
+
)
|
|
312
|
+
temp_df["交割量-累计同比"] = pd.to_numeric(
|
|
313
|
+
temp_df["交割量-累计同比"], errors="coerce"
|
|
314
|
+
)
|
|
308
315
|
return temp_df
|
|
309
316
|
|
|
310
317
|
|
|
@@ -330,7 +337,5 @@ if __name__ == "__main__":
|
|
|
330
337
|
futures_delivery_match_dce_df = futures_delivery_match_dce(symbol="a")
|
|
331
338
|
print(futures_delivery_match_dce_df)
|
|
332
339
|
|
|
333
|
-
futures_delivery_match_czce_df = futures_delivery_match_czce(
|
|
334
|
-
date="20210106"
|
|
335
|
-
)
|
|
340
|
+
futures_delivery_match_czce_df = futures_delivery_match_czce(date="20210106")
|
|
336
341
|
print(futures_delivery_match_czce_df)
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/
|
|
4
|
+
Date: 2024/4/2 22:30
|
|
5
5
|
Desc: 期货-仓单日报
|
|
6
6
|
上海期货交易所-仓单日报
|
|
7
|
-
https://
|
|
7
|
+
https://tsite.shfe.com.cn/statements/dataview.html?paramid=dailystock
|
|
8
8
|
郑州商品交易所-交易数据-仓单日报
|
|
9
9
|
http://www.czce.com.cn/cn/jysj/cdrb/H770310index_1.htm
|
|
10
10
|
大连商品交易所-行情数据-统计数据-日统计-仓单日报
|
|
@@ -12,6 +12,7 @@ http://www.dce.com.cn/dalianshangpin/xqsj/tjsj26/rtj/cdrb/index.html
|
|
|
12
12
|
广州期货交易所-行情数据-仓单日报
|
|
13
13
|
http://www.gfex.com.cn/gfex/cdrb/hqsj_tjsj.shtml
|
|
14
14
|
"""
|
|
15
|
+
|
|
15
16
|
import re
|
|
16
17
|
from io import BytesIO, StringIO
|
|
17
18
|
|
|
@@ -30,19 +31,16 @@ def futures_czce_warehouse_receipt(date: str = "20200702") -> dict:
|
|
|
30
31
|
"""
|
|
31
32
|
url = f"http://www.czce.com.cn/cn/DFSStaticFiles/Future/{date[:4]}/{date}/FutureDataWhsheet.xls"
|
|
32
33
|
headers = {
|
|
33
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
34
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
35
|
+
"Chrome/83.0.4103.116 Safari/537.36"
|
|
34
36
|
}
|
|
35
37
|
r = requests.get(url, verify=False, headers=headers)
|
|
36
38
|
temp_df = pd.read_excel(BytesIO(r.content))
|
|
37
|
-
index_list = temp_df[
|
|
38
|
-
temp_df.iloc[:, 0].str.find("品种") == 0.0
|
|
39
|
-
].index.to_list()
|
|
39
|
+
index_list = temp_df[temp_df.iloc[:, 0].str.find("品种") == 0.0].index.to_list()
|
|
40
40
|
index_list.append(len(temp_df))
|
|
41
41
|
big_dict = {}
|
|
42
42
|
for inner_index in range(len(index_list) - 1):
|
|
43
|
-
inner_df = temp_df[
|
|
44
|
-
index_list[inner_index]: index_list[inner_index + 1]
|
|
45
|
-
]
|
|
43
|
+
inner_df = temp_df[index_list[inner_index] : index_list[inner_index + 1]]
|
|
46
44
|
inner_key = re.findall(r"[a-zA-Z]+", inner_df.iloc[0, 0])[0]
|
|
47
45
|
inner_df = inner_df.iloc[1:, :]
|
|
48
46
|
inner_df.dropna(axis=0, how="all", inplace=True)
|
|
@@ -65,7 +63,8 @@ def futures_dce_warehouse_receipt(date: str = "20200702") -> dict:
|
|
|
65
63
|
"""
|
|
66
64
|
url = "http://www.dce.com.cn/publicweb/quotesdata/wbillWeeklyQuotes.html"
|
|
67
65
|
headers = {
|
|
68
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
66
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
67
|
+
"Chrome/83.0.4103.116 Safari/537.36"
|
|
69
68
|
}
|
|
70
69
|
params = {
|
|
71
70
|
"wbillWeeklyQuotes.variety": "all",
|
|
@@ -75,9 +74,7 @@ def futures_dce_warehouse_receipt(date: str = "20200702") -> dict:
|
|
|
75
74
|
}
|
|
76
75
|
r = requests.get(url, params=params, headers=headers)
|
|
77
76
|
temp_df = pd.read_html(StringIO(r.text))[0]
|
|
78
|
-
index_list = temp_df[
|
|
79
|
-
temp_df.iloc[:, 0].str.contains("小计") == 1
|
|
80
|
-
].index.to_list()
|
|
77
|
+
index_list = temp_df[temp_df.iloc[:, 0].str.contains("小计") == 1].index.to_list()
|
|
81
78
|
index_list.insert(0, 0)
|
|
82
79
|
big_dict = {}
|
|
83
80
|
for inner_index in range(len(index_list) - 1):
|
|
@@ -85,10 +82,14 @@ def futures_dce_warehouse_receipt(date: str = "20200702") -> dict:
|
|
|
85
82
|
temp_index = 0
|
|
86
83
|
else:
|
|
87
84
|
temp_index = index_list[inner_index] + 1
|
|
88
|
-
inner_df = temp_df[temp_index: index_list[inner_index + 1] + 1]
|
|
85
|
+
inner_df = temp_df[temp_index : index_list[inner_index + 1] + 1].copy()
|
|
89
86
|
inner_key = inner_df.iloc[0, 0]
|
|
90
87
|
inner_df.reset_index(inplace=True, drop=True)
|
|
91
|
-
inner_df
|
|
88
|
+
inner_df.ffill(inplace=True)
|
|
89
|
+
# 填补 20240401 中开头没有品种的情况
|
|
90
|
+
if date == "20240401":
|
|
91
|
+
inner_df["品种"] = inner_df["品种"].fillna("玉米")
|
|
92
|
+
inner_key = inner_df.iloc[0, 0]
|
|
92
93
|
big_dict[inner_key] = inner_df
|
|
93
94
|
return big_dict
|
|
94
95
|
|
|
@@ -96,26 +97,23 @@ def futures_dce_warehouse_receipt(date: str = "20200702") -> dict:
|
|
|
96
97
|
def futures_shfe_warehouse_receipt(date: str = "20200702") -> dict:
|
|
97
98
|
"""
|
|
98
99
|
上海期货交易所指定交割仓库期货仓单日报
|
|
99
|
-
https://
|
|
100
|
+
https://tsite.shfe.com.cn/statements/dataview.html?paramid=dailystock¶mdate=20200703
|
|
100
101
|
:param date: 交易日, e.g., "20200702"
|
|
101
102
|
:type date: str
|
|
102
103
|
:return: 指定日期的仓单日报数据
|
|
103
104
|
:rtype: dict
|
|
104
105
|
"""
|
|
105
106
|
headers = {
|
|
106
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
107
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
108
|
+
"Chrome/83.0.4103.116 Safari/537.36"
|
|
107
109
|
}
|
|
108
|
-
url = f"
|
|
110
|
+
url = f"https://tsite.shfe.com.cn/data/dailydata/{date}dailystock.dat"
|
|
109
111
|
if date >= "20140519":
|
|
110
112
|
r = requests.get(url, headers=headers)
|
|
111
113
|
data_json = r.json()
|
|
112
114
|
temp_df = pd.DataFrame(data_json["o_cursor"])
|
|
113
|
-
temp_df["VARNAME"] = (
|
|
114
|
-
|
|
115
|
-
)
|
|
116
|
-
temp_df["REGNAME"] = (
|
|
117
|
-
temp_df["REGNAME"].str.split(r"$", expand=True).iloc[:, 0]
|
|
118
|
-
)
|
|
115
|
+
temp_df["VARNAME"] = temp_df["VARNAME"].str.split(r"$", expand=True).iloc[:, 0]
|
|
116
|
+
temp_df["REGNAME"] = temp_df["REGNAME"].str.split(r"$", expand=True).iloc[:, 0]
|
|
119
117
|
temp_df["WHABBRNAME"] = (
|
|
120
118
|
temp_df["WHABBRNAME"].str.split(r"$", expand=True).iloc[:, 0]
|
|
121
119
|
)
|
|
@@ -123,12 +121,12 @@ def futures_shfe_warehouse_receipt(date: str = "20200702") -> dict:
|
|
|
123
121
|
for item in set(temp_df["VARNAME"]):
|
|
124
122
|
big_dict[item] = temp_df[temp_df["VARNAME"] == item]
|
|
125
123
|
else:
|
|
126
|
-
url = f"
|
|
124
|
+
url = f"https://tsite.shfe.com.cn/data/dailydata/{date}dailystock.html"
|
|
127
125
|
r = requests.get(url, headers=headers)
|
|
128
126
|
temp_df = pd.read_html(StringIO(r.text))[0]
|
|
129
127
|
index_list = temp_df[
|
|
130
128
|
temp_df.iloc[:, 3].str.contains("单位:") == 1
|
|
131
|
-
|
|
129
|
+
].index.to_list()
|
|
132
130
|
big_dict = {}
|
|
133
131
|
for inner_index in range(len(index_list)):
|
|
134
132
|
temp_index_start = index_list[inner_index]
|
|
@@ -160,71 +158,77 @@ def futures_gfex_warehouse_receipt(date: str = "20240122") -> dict:
|
|
|
160
158
|
"""
|
|
161
159
|
url = "http://www.gfex.com.cn/u/interfacesWebTdWbillWeeklyQuotes/loadList"
|
|
162
160
|
headers = {
|
|
163
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
164
|
-
|
|
165
|
-
payload = {
|
|
166
|
-
"gen_date": date
|
|
161
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
162
|
+
"Chrome/83.0.4103.116 Safari/537.36"
|
|
167
163
|
}
|
|
164
|
+
payload = {"gen_date": date}
|
|
168
165
|
r = requests.post(url=url, data=payload, headers=headers)
|
|
169
166
|
data_json = r.json()
|
|
170
|
-
temp_df = pd.DataFrame(data_json[
|
|
171
|
-
symbol_list = list(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
temp_df['whType'] = pd.to_numeric(temp_df['whType'], errors="coerce")
|
|
190
|
-
temp_df.dropna(subset=["whType"], how="any", axis=0, ignore_index=True, inplace=True)
|
|
191
|
-
big_dict = dict()
|
|
192
|
-
for symbol in symbol_list:
|
|
193
|
-
inner_temp_df = temp_df[temp_df['symbol'] == symbol.lower()].copy()
|
|
194
|
-
inner_temp_df = inner_temp_df[[
|
|
167
|
+
temp_df = pd.DataFrame(data_json["data"])
|
|
168
|
+
symbol_list = list(
|
|
169
|
+
set([item.upper() for item in temp_df["varietyOrder"].tolist() if item != ""])
|
|
170
|
+
)
|
|
171
|
+
temp_df.rename(
|
|
172
|
+
columns={
|
|
173
|
+
"varietyOrder": "symbol",
|
|
174
|
+
"variety": "品种",
|
|
175
|
+
"whAbbr": "仓库/分库",
|
|
176
|
+
"lastWbillQty": "昨日仓单量",
|
|
177
|
+
"wbillQty": "今日仓单量",
|
|
178
|
+
"regWbillQty": "增减",
|
|
179
|
+
},
|
|
180
|
+
inplace=True,
|
|
181
|
+
)
|
|
182
|
+
temp_df = temp_df[
|
|
183
|
+
[
|
|
184
|
+
"symbol",
|
|
185
|
+
"whType",
|
|
195
186
|
"品种",
|
|
196
187
|
"仓库/分库",
|
|
197
188
|
"昨日仓单量",
|
|
198
189
|
"今日仓单量",
|
|
199
190
|
"增减",
|
|
200
|
-
]
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
191
|
+
]
|
|
192
|
+
]
|
|
193
|
+
temp_df["whType"] = pd.to_numeric(temp_df["whType"], errors="coerce")
|
|
194
|
+
temp_df.dropna(
|
|
195
|
+
subset=["whType"], how="any", axis=0, ignore_index=True, inplace=True
|
|
196
|
+
)
|
|
197
|
+
big_dict = dict()
|
|
198
|
+
for symbol in symbol_list:
|
|
199
|
+
inner_temp_df = temp_df[temp_df["symbol"] == symbol.lower()].copy()
|
|
200
|
+
inner_temp_df = inner_temp_df[
|
|
201
|
+
[
|
|
202
|
+
"品种",
|
|
203
|
+
"仓库/分库",
|
|
204
|
+
"昨日仓单量",
|
|
205
|
+
"今日仓单量",
|
|
206
|
+
"增减",
|
|
207
|
+
]
|
|
208
|
+
]
|
|
209
|
+
inner_temp_df["昨日仓单量"] = pd.to_numeric(
|
|
210
|
+
inner_temp_df["昨日仓单量"], errors="coerce"
|
|
211
|
+
)
|
|
212
|
+
inner_temp_df["今日仓单量"] = pd.to_numeric(
|
|
213
|
+
inner_temp_df["今日仓单量"], errors="coerce"
|
|
214
|
+
)
|
|
215
|
+
inner_temp_df["增减"] = pd.to_numeric(inner_temp_df["增减"], errors="coerce")
|
|
204
216
|
inner_temp_df.reset_index(inplace=True, drop=True)
|
|
205
217
|
big_dict[symbol] = inner_temp_df
|
|
206
218
|
return big_dict
|
|
207
219
|
|
|
208
220
|
|
|
209
221
|
if __name__ == "__main__":
|
|
210
|
-
czce_warehouse_receipt_df = futures_czce_warehouse_receipt(
|
|
211
|
-
date="20151019"
|
|
212
|
-
)
|
|
222
|
+
czce_warehouse_receipt_df = futures_czce_warehouse_receipt(date="20151019")
|
|
213
223
|
print(czce_warehouse_receipt_df)
|
|
214
224
|
|
|
215
|
-
futures_dce_warehouse_receipt_df = futures_dce_warehouse_receipt(
|
|
216
|
-
date="20200702"
|
|
217
|
-
)
|
|
225
|
+
futures_dce_warehouse_receipt_df = futures_dce_warehouse_receipt(date="20240401")
|
|
218
226
|
print(futures_dce_warehouse_receipt_df)
|
|
219
227
|
|
|
220
|
-
futures_shfe_warehouse_receipt_df = futures_shfe_warehouse_receipt(
|
|
221
|
-
date="20200702"
|
|
222
|
-
)
|
|
228
|
+
futures_shfe_warehouse_receipt_df = futures_shfe_warehouse_receipt(date="20200702")
|
|
223
229
|
print(futures_shfe_warehouse_receipt_df)
|
|
224
230
|
|
|
225
|
-
futures_shfe_warehouse_receipt_df = futures_shfe_warehouse_receipt(
|
|
226
|
-
date="20140516"
|
|
227
|
-
)
|
|
231
|
+
futures_shfe_warehouse_receipt_df = futures_shfe_warehouse_receipt(date="20140516")
|
|
228
232
|
print(futures_shfe_warehouse_receipt_df)
|
|
229
233
|
|
|
230
234
|
futures_gfex_warehouse_receipt_df = futures_gfex_warehouse_receipt(date="20240122")
|
|
@@ -13,7 +13,7 @@ from functools import lru_cache
|
|
|
13
13
|
|
|
14
14
|
import pandas as pd
|
|
15
15
|
import requests
|
|
16
|
-
|
|
16
|
+
import py_mini_racer
|
|
17
17
|
|
|
18
18
|
from akshare.futures.cons import (
|
|
19
19
|
zh_subscribe_exchange_symbol_url,
|
|
@@ -648,13 +648,13 @@ def futures_zh_minute_sina(symbol: str = "IF2008", period: str = "5") -> pd.Data
|
|
|
648
648
|
return temp_df
|
|
649
649
|
|
|
650
650
|
|
|
651
|
-
def futures_zh_daily_sina(symbol: str = "
|
|
651
|
+
def futures_zh_daily_sina(symbol: str = "RB0") -> pd.DataFrame:
|
|
652
652
|
"""
|
|
653
653
|
中国各品种期货日频率数据
|
|
654
654
|
https://finance.sina.com.cn/futures/quotes/V2105.shtml
|
|
655
655
|
:param symbol: 可以通过 match_main_contract(symbol="cffex") 获取, 或者访问网页获取
|
|
656
656
|
:type symbol: str
|
|
657
|
-
:return: 指定 symbol
|
|
657
|
+
:return: 指定 symbol 的数据
|
|
658
658
|
:rtype: pandas.DataFrame
|
|
659
659
|
"""
|
|
660
660
|
date = "20210412"
|
|
@@ -707,10 +707,10 @@ if __name__ == "__main__":
|
|
|
707
707
|
futures_zh_minute_sina_df = futures_zh_minute_sina(symbol="SI2406", period="1")
|
|
708
708
|
print(futures_zh_minute_sina_df)
|
|
709
709
|
|
|
710
|
-
futures_zh_daily_sina_df = futures_zh_daily_sina(symbol="
|
|
710
|
+
futures_zh_daily_sina_df = futures_zh_daily_sina(symbol="RB0")
|
|
711
711
|
print(futures_zh_daily_sina_df)
|
|
712
712
|
|
|
713
|
-
futures_zh_daily_sina_df = futures_zh_daily_sina(symbol="
|
|
713
|
+
futures_zh_daily_sina_df = futures_zh_daily_sina(symbol="RB2410")
|
|
714
714
|
print(futures_zh_daily_sina_df)
|
|
715
715
|
|
|
716
716
|
dce_text = match_main_contract(symbol="dce")
|
akshare/futures/symbol_var.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/11/28 22:00
|
|
5
5
|
Desc: 期货品种映射表
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
import re
|
|
8
9
|
|
|
9
10
|
from akshare.futures import cons
|
|
@@ -151,18 +152,20 @@ def chinese_to_english(chinese_var: str):
|
|
|
151
152
|
"低硫燃料油仓库",
|
|
152
153
|
"低硫燃料油厂库",
|
|
153
154
|
"短纤",
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
155
|
+
"涤纶短纤",
|
|
156
|
+
"生猪",
|
|
157
|
+
"花生",
|
|
158
|
+
"工业硅",
|
|
159
|
+
"氧化铝",
|
|
160
|
+
"丁二烯橡胶",
|
|
161
|
+
"碳酸锂",
|
|
162
|
+
"氧化铝仓库",
|
|
163
|
+
"氧化铝厂库",
|
|
164
|
+
"烧碱",
|
|
165
|
+
"丁二烯橡胶仓库",
|
|
166
|
+
"丁二烯橡胶厂库",
|
|
167
|
+
"PX",
|
|
168
|
+
"原木",
|
|
166
169
|
]
|
|
167
170
|
english_list = [
|
|
168
171
|
"RU",
|
|
@@ -277,6 +280,8 @@ def chinese_to_english(chinese_var: str):
|
|
|
277
280
|
"SH",
|
|
278
281
|
"BR",
|
|
279
282
|
"BR",
|
|
283
|
+
"PX",
|
|
284
|
+
"LG",
|
|
280
285
|
]
|
|
281
286
|
pos = chinese_list.index(chinese_var)
|
|
282
287
|
return english_list[pos]
|