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
akshare/futures/cot.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2025/1/10 18:30
|
|
5
5
|
Desc: 期货-中国-交易所-会员持仓数据接口
|
|
6
6
|
大连商品交易所、上海期货交易所、郑州商品交易所、中国金融期货交易所、广州期货交易所
|
|
7
7
|
采集前 20 会员持仓数据;
|
|
@@ -13,6 +13,7 @@ http://www.czce.com.cn/cn/DFSStaticFiles/Future/2020/20200727/FutureDataHolding.
|
|
|
13
13
|
20100825
|
|
14
14
|
http://www.czce.com.cn/cn/exchange/2014/datatradeholding/20140515.txt
|
|
15
15
|
"""
|
|
16
|
+
|
|
16
17
|
import datetime
|
|
17
18
|
import json
|
|
18
19
|
import re
|
|
@@ -53,9 +54,9 @@ intColumns = [
|
|
|
53
54
|
|
|
54
55
|
|
|
55
56
|
def get_rank_sum_daily(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
start_day: str = "20210510",
|
|
58
|
+
end_day: str = "20210510",
|
|
59
|
+
vars_list: list = cons.contract_symbols,
|
|
59
60
|
):
|
|
60
61
|
"""
|
|
61
62
|
采集四个期货交易所前 5、前 10、前 15、前 20 会员持仓排名数据
|
|
@@ -147,7 +148,7 @@ def get_rank_sum(date: str = "20210525", vars_list: list = cons.contract_symbols
|
|
|
147
148
|
return False
|
|
148
149
|
big_dict.update(data)
|
|
149
150
|
if len(czce_var) > 0:
|
|
150
|
-
data = get_czce_rank_table(date
|
|
151
|
+
data = get_czce_rank_table(date)
|
|
151
152
|
if data is False:
|
|
152
153
|
return False
|
|
153
154
|
big_dict.update(data)
|
|
@@ -166,15 +167,14 @@ def get_rank_sum(date: str = "20210525", vars_list: list = cons.contract_symbols
|
|
|
166
167
|
for symbol, table in big_dict.items():
|
|
167
168
|
table = table.map(lambda x: 0 if x == "" else x)
|
|
168
169
|
for symbol_inner in set(table["symbol"]):
|
|
169
|
-
|
|
170
170
|
var = symbol_varieties(symbol_inner)
|
|
171
171
|
if var in vars_list:
|
|
172
172
|
if var in czce_var:
|
|
173
173
|
for col in [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
item
|
|
175
|
+
for item in table.columns
|
|
176
|
+
if item.find("open_interest") > -1
|
|
177
|
+
] + ["vol", "vol_chg"]:
|
|
178
178
|
table[col] = [
|
|
179
179
|
float(value.replace(",", "")) if value != "-" else 0.0
|
|
180
180
|
for value in table[col]
|
|
@@ -256,8 +256,8 @@ def get_rank_sum(date: str = "20210525", vars_list: list = cons.contract_symbols
|
|
|
256
256
|
add_vars = [
|
|
257
257
|
i
|
|
258
258
|
for i in cons.market_exchange_symbols["dce"]
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
+ cons.market_exchange_symbols["shfe"]
|
|
260
|
+
+ cons.market_exchange_symbols["cffex"]
|
|
261
261
|
if i in records["variety"].tolist()
|
|
262
262
|
]
|
|
263
263
|
for var in add_vars:
|
|
@@ -270,11 +270,13 @@ def get_rank_sum(date: str = "20210525", vars_list: list = cons.contract_symbols
|
|
|
270
270
|
return records.reset_index(drop=True)
|
|
271
271
|
|
|
272
272
|
|
|
273
|
-
def get_shfe_rank_table(
|
|
273
|
+
def get_shfe_rank_table(
|
|
274
|
+
date: str = None, vars_list: list = cons.contract_symbols
|
|
275
|
+
) -> dict:
|
|
274
276
|
"""
|
|
275
277
|
上海期货交易所会员成交及持仓排名表
|
|
276
278
|
https://www.shfe.com.cn/
|
|
277
|
-
https://
|
|
279
|
+
https://tsite.shfe.com.cn/statements/dataview.html?paramid=kx
|
|
278
280
|
注:该交易所只公布每个品种内部的标的排名,没有公布品种的总排名
|
|
279
281
|
数据从 20020107 开始,每交易日 16:30 左右更新数据
|
|
280
282
|
:param date: 交易日
|
|
@@ -298,17 +300,17 @@ def get_shfe_rank_table(date: str = None, vars_list: str = cons.contract_symbols
|
|
|
298
300
|
date 日期 string YYYYMMDD
|
|
299
301
|
"""
|
|
300
302
|
date = cons.convert_date(date) if date is not None else datetime.date.today()
|
|
301
|
-
if date < datetime.date(2002, 1, 7):
|
|
302
|
-
print("shfe数据源开始日期为20020107,跳过")
|
|
303
|
+
if date < datetime.date(year=2002, month=1, day=7):
|
|
304
|
+
print("shfe数据源开始日期为 20020107,跳过")
|
|
303
305
|
return {}
|
|
304
306
|
if date.strftime("%Y%m%d") not in calendar:
|
|
305
307
|
warnings.warn("%s非交易日" % date.strftime("%Y%m%d"))
|
|
306
308
|
return {}
|
|
307
309
|
url = cons.SHFE_VOL_RANK_URL % (date.strftime("%Y%m%d"))
|
|
308
|
-
r = requests_link(url, "utf-8", headers=cons.shfe_headers)
|
|
310
|
+
r = requests_link(url, encoding="utf-8", headers=cons.shfe_headers)
|
|
309
311
|
try:
|
|
310
312
|
context = json.loads(r.text)
|
|
311
|
-
except:
|
|
313
|
+
except: # noqa: E722
|
|
312
314
|
return {}
|
|
313
315
|
df = pd.DataFrame(context["o_cursor"])
|
|
314
316
|
|
|
@@ -345,7 +347,7 @@ def get_shfe_rank_table(date: str = None, vars_list: str = cons.contract_symbols
|
|
|
345
347
|
]:
|
|
346
348
|
try:
|
|
347
349
|
del df[col]
|
|
348
|
-
except:
|
|
350
|
+
except: # noqa: E722
|
|
349
351
|
pass
|
|
350
352
|
get_vars = [var for var in vars_list if var in df["variety"].tolist()]
|
|
351
353
|
big_dict = {}
|
|
@@ -353,7 +355,7 @@ def get_shfe_rank_table(date: str = None, vars_list: str = cons.contract_symbols
|
|
|
353
355
|
df_var = df[df["variety"] == var]
|
|
354
356
|
for symbol in set(df_var["symbol"]):
|
|
355
357
|
df_symbol = df_var[df_var["symbol"] == symbol].copy()
|
|
356
|
-
df_symbol[
|
|
358
|
+
df_symbol["symbol"] = df_symbol["symbol"].str.upper()
|
|
357
359
|
big_dict[symbol] = df_symbol.reset_index(drop=True)
|
|
358
360
|
return big_dict
|
|
359
361
|
|
|
@@ -369,10 +371,16 @@ def _czce_df_read(url, skip_rows, encoding="utf-8", header=0):
|
|
|
369
371
|
:return: pd.DataFrame
|
|
370
372
|
"""
|
|
371
373
|
headers = {
|
|
372
|
-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,
|
|
373
|
-
"
|
|
374
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,"
|
|
375
|
+
"image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
|
|
376
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
377
|
+
"Chrome/84.0.4147.89 Safari/537.36",
|
|
374
378
|
"Host": "www.czce.com.cn",
|
|
375
|
-
"Cookie": "XquW6dFMPxV380S=CAaD3sMkdXv3fUoaJlICIEv0MVegGq5EoMyBcxkOjCgSjmpuovYFuTLtYFcxTZGw;
|
|
379
|
+
"Cookie": "XquW6dFMPxV380S=CAaD3sMkdXv3fUoaJlICIEv0MVegGq5EoMyBcxkOjCgSjmpuovYFuTLtYFcxTZGw; "
|
|
380
|
+
"XquW6dFMPxV380T=5QTTjUlA6f6WiDO7fMGmqNxHBWz.hKIc8lb_tc1o4nHrJM4nsXCAI9VHaKyV_jkHh4cIVvD25kGQAh."
|
|
381
|
+
"MvLL1SHRA20HCG9mVVHPhAzktNdPK3evjm0NYbTg2Gu_XGGtPhecxLvdFQ0."
|
|
382
|
+
"JlAxy_z0C15_KdO8kOI18i4K0rFERNPxjXq5qG1Gs.QiOm976wODY.pe8XCQtAsuLYJ."
|
|
383
|
+
"N4DpTgNfHJp04jhMl0SntHhr.jhh3dFjMXBx.JEHngXBzY6gQAhER7uSKAeSktruxFeuKlebse.vrPghHqWvJm4WPTEvDQ8q",
|
|
376
384
|
}
|
|
377
385
|
r = requests_link(url, encoding, headers=headers)
|
|
378
386
|
|
|
@@ -395,14 +403,11 @@ def _czce_df_read(url, skip_rows, encoding="utf-8", header=0):
|
|
|
395
403
|
return data
|
|
396
404
|
|
|
397
405
|
|
|
398
|
-
def get_czce_rank_table(
|
|
399
|
-
date: str = "20210428", vars_list: list = cons.contract_symbols
|
|
400
|
-
) -> dict:
|
|
406
|
+
def get_czce_rank_table(date: str = "20210428") -> dict:
|
|
401
407
|
"""
|
|
402
408
|
郑州商品交易所前 20 会员持仓排名数据明细
|
|
403
409
|
注:该交易所既公布了品种排名, 也公布了标的排名
|
|
404
410
|
:param date: 日期 format:YYYY-MM-DD 或 YYYYMMDD 或 datetime.date对象 为空时为当天
|
|
405
|
-
:param vars_list: 合约品种如RB、AL等列表 为空时为所有商品, 数据从20050509开始,每交易日16:30左右更新数据
|
|
406
411
|
:return: pd.DataFrame
|
|
407
412
|
rank 排名 int
|
|
408
413
|
vol_party_name 成交量排序的当前名次会员 string(中文)
|
|
@@ -420,8 +425,10 @@ def get_czce_rank_table(
|
|
|
420
425
|
"""
|
|
421
426
|
date = cons.convert_date(date) if date is not None else datetime.date.today()
|
|
422
427
|
headers = {
|
|
423
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
428
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
429
|
+
"Chrome/108.0.0.0 Safari/537.36"
|
|
424
430
|
}
|
|
431
|
+
temp_df = pd.DataFrame()
|
|
425
432
|
if date < datetime.date(2015, 10, 8):
|
|
426
433
|
print("CZCE可获取的数据源开始日期为 20151008, 请输入合适的日期参数")
|
|
427
434
|
return {}
|
|
@@ -429,7 +436,10 @@ def get_czce_rank_table(
|
|
|
429
436
|
warnings.warn("%s非交易日" % date.strftime("%Y%m%d"))
|
|
430
437
|
return {}
|
|
431
438
|
if date >= datetime.date(2015, 10, 8):
|
|
432
|
-
url =
|
|
439
|
+
url = (
|
|
440
|
+
f"http://www.czce.com.cn/cn/DFSStaticFiles/Future/{date.year}/"
|
|
441
|
+
f"{date.isoformat().replace('-', '')}/FutureDataHolding.xls"
|
|
442
|
+
)
|
|
433
443
|
r = requests.get(url, headers=headers)
|
|
434
444
|
temp_df = pd.read_excel(BytesIO(r.content))
|
|
435
445
|
|
|
@@ -452,8 +462,8 @@ def get_czce_rank_table(
|
|
|
452
462
|
big_dict = {}
|
|
453
463
|
for i in range(len(temp_symbol_index_list) - 1):
|
|
454
464
|
inner_temp_df = temp_df[
|
|
455
|
-
|
|
456
|
-
|
|
465
|
+
temp_symbol_index_list[i] + 2 : temp_symbol_index_list[i + 1] - 1
|
|
466
|
+
]
|
|
457
467
|
inner_temp_df.columns = [
|
|
458
468
|
"rank",
|
|
459
469
|
"vol_party_name",
|
|
@@ -468,7 +478,7 @@ def get_czce_rank_table(
|
|
|
468
478
|
]
|
|
469
479
|
inner_temp_df.reset_index(inplace=True, drop=True)
|
|
470
480
|
big_dict[symbol_list[i]] = inner_temp_df
|
|
471
|
-
inner_temp_df = temp_df[temp_symbol_index_list[i + 1] + 2: -1]
|
|
481
|
+
inner_temp_df = temp_df[temp_symbol_index_list[i + 1] + 2 : -1]
|
|
472
482
|
inner_temp_df.columns = [
|
|
473
483
|
"rank",
|
|
474
484
|
"vol_party_name",
|
|
@@ -501,7 +511,8 @@ def _get_dce_contract_list(date, var):
|
|
|
501
511
|
"""
|
|
502
512
|
url = "http://www.dce.com.cn/publicweb/quotesdata/memberDealPosiQuotes.html"
|
|
503
513
|
headers = {
|
|
504
|
-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;
|
|
514
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;"
|
|
515
|
+
"q=0.8,application/signed-exchange;v=b3;q=0.9",
|
|
505
516
|
"Accept-Encoding": "gzip, deflate",
|
|
506
517
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
|
507
518
|
"Cache-Control": "no-cache",
|
|
@@ -510,7 +521,8 @@ def _get_dce_contract_list(date, var):
|
|
|
510
521
|
"Origin": "http://www.dce.com.cn",
|
|
511
522
|
"Pragma": "no-cache",
|
|
512
523
|
"Upgrade-Insecure-Requests": "1",
|
|
513
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
524
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
525
|
+
"Chrome/81.0.4044.138 Safari/537.36",
|
|
514
526
|
}
|
|
515
527
|
params = {
|
|
516
528
|
"memberDealPosiQuotes.variety": var.lower(),
|
|
@@ -535,8 +547,8 @@ def _get_dce_contract_list(date, var):
|
|
|
535
547
|
for item in soup.find_all(attrs={"name": "contract"})
|
|
536
548
|
]
|
|
537
549
|
contract_list = [var.lower() + item for item in contract_list]
|
|
538
|
-
return contract_list
|
|
539
|
-
except:
|
|
550
|
+
return contract_list # noqa: E722
|
|
551
|
+
except: # noqa: E722
|
|
540
552
|
time.sleep(5)
|
|
541
553
|
continue
|
|
542
554
|
|
|
@@ -629,7 +641,7 @@ def get_dce_rank_table(date: str = "20230706", vars_list=cons.contract_symbols)
|
|
|
629
641
|
"short_open_interest_chg"
|
|
630
642
|
].astype(float)
|
|
631
643
|
big_dict[symbol] = temp_df
|
|
632
|
-
except:
|
|
644
|
+
except: # noqa: E722
|
|
633
645
|
temp_url = "http://www.dce.com.cn/publicweb/quotesdata/memberDealPosiQuotes.html"
|
|
634
646
|
payload = {
|
|
635
647
|
"memberDealPosiQuotes.variety": var.lower(),
|
|
@@ -719,7 +731,8 @@ def get_cffex_rank_table(date: str = "20190805", vars_list=cons.contract_symbols
|
|
|
719
731
|
warnings.warn("%s非交易日" % date.strftime("%Y%m%d"))
|
|
720
732
|
return {}
|
|
721
733
|
headers = {
|
|
722
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
734
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
735
|
+
"Chrome/81.0.4044.138 Safari/537.36",
|
|
723
736
|
}
|
|
724
737
|
big_dict = {}
|
|
725
738
|
for var in vars_list:
|
|
@@ -738,11 +751,11 @@ def get_cffex_rank_table(date: str = "20190805", vars_list=cons.contract_symbols
|
|
|
738
751
|
try:
|
|
739
752
|
# 当所需要的合约没有数据时
|
|
740
753
|
temp_df = pd.read_table(BytesIO(r.content), encoding="gbk", header=None)
|
|
741
|
-
except:
|
|
754
|
+
except: # noqa: E722
|
|
742
755
|
continue
|
|
743
756
|
need_index = temp_df.iloc[:, 0].str.contains("交易日")
|
|
744
757
|
if sum(need_index) > 2:
|
|
745
|
-
table = temp_df.iloc[temp_df[need_index].index[1]:, 0].str.split(
|
|
758
|
+
table = temp_df.iloc[temp_df[need_index].index[1] :, 0].str.split(
|
|
746
759
|
",", expand=True
|
|
747
760
|
)
|
|
748
761
|
table.columns = table.iloc[0, :]
|
|
@@ -787,7 +800,7 @@ def _table_cut_cal(table_cut, symbol):
|
|
|
787
800
|
|
|
788
801
|
|
|
789
802
|
def futures_dce_position_rank(
|
|
790
|
-
|
|
803
|
+
date: str = "20160919", vars_list=cons.contract_symbols
|
|
791
804
|
) -> dict:
|
|
792
805
|
"""
|
|
793
806
|
大连商品交易所-每日持仓排名-具体合约
|
|
@@ -805,7 +818,8 @@ def futures_dce_position_rank(
|
|
|
805
818
|
return {}
|
|
806
819
|
url = "http://www.dce.com.cn/publicweb/quotesdata/exportMemberDealPosiQuotesBatchData.html"
|
|
807
820
|
headers = {
|
|
808
|
-
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;
|
|
821
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;"
|
|
822
|
+
"q=0.8,application/signed-exchange;v=b3;q=0.9",
|
|
809
823
|
"Accept-Encoding": "gzip, deflate",
|
|
810
824
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
|
811
825
|
"Cache-Control": "no-cache",
|
|
@@ -817,7 +831,8 @@ def futures_dce_position_rank(
|
|
|
817
831
|
"Pragma": "no-cache",
|
|
818
832
|
"Referer": "http://www.dce.com.cn/publicweb/quotesdata/memberDealPosiQuotes.html",
|
|
819
833
|
"Upgrade-Insecure-Requests": "1",
|
|
820
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
834
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
835
|
+
"Chrome/81.0.4044.138 Safari/537.36",
|
|
821
836
|
}
|
|
822
837
|
payload = {
|
|
823
838
|
"memberDealPosiQuotes.variety": "a",
|
|
@@ -831,35 +846,39 @@ def futures_dce_position_rank(
|
|
|
831
846
|
}
|
|
832
847
|
r = requests.post(url, payload, headers=headers)
|
|
833
848
|
big_dict = dict()
|
|
834
|
-
with zipfile.ZipFile(BytesIO(r.content), "r") as z:
|
|
849
|
+
with zipfile.ZipFile(BytesIO(r.content), mode="r") as z:
|
|
835
850
|
for i in z.namelist():
|
|
836
851
|
file_name = i.encode("cp437").decode("GBK")
|
|
837
852
|
if not file_name.startswith(date.strftime("%Y%m%d")):
|
|
838
853
|
continue
|
|
839
854
|
try:
|
|
840
|
-
data = pd.read_table(z.open(i), header=None, sep="\t")
|
|
855
|
+
data = pd.read_table(z.open(i), header=None, sep="\t")
|
|
856
|
+
if sum(data.iloc[:, 0].str.find("会员类别") == 0) > 0:
|
|
857
|
+
data = data.iloc[:-6]
|
|
841
858
|
if len(data) < 12: # 处理没有活跃合约的情况
|
|
842
859
|
big_dict[file_name.split("_")[1]] = pd.DataFrame()
|
|
843
860
|
continue
|
|
844
861
|
temp_filter = data[data.iloc[:, 0].str.find("名次") == 0].index.tolist()
|
|
845
862
|
if (
|
|
846
|
-
|
|
863
|
+
temp_filter[1] - temp_filter[0] < 5
|
|
847
864
|
): # 过滤有无成交量但是有买卖持仓的数据, 如 20201105_c2011_成交量_买持仓_卖持仓排名.txt
|
|
848
865
|
big_dict[file_name.split("_")[1]] = pd.DataFrame()
|
|
849
866
|
continue
|
|
850
867
|
start_list = data[data.iloc[:, 0].str.find("名次") == 0].index.tolist()
|
|
851
868
|
data = data.iloc[
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
869
|
+
start_list[0] :,
|
|
870
|
+
data.columns[data.iloc[start_list[0], :].notnull()],
|
|
871
|
+
]
|
|
855
872
|
data.reset_index(inplace=True, drop=True)
|
|
856
873
|
start_list = data[data.iloc[:, 0].str.find("名次") == 0].index.tolist()
|
|
857
|
-
end_list = data[
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
874
|
+
end_list = data[
|
|
875
|
+
data.iloc[:, 0].str.contains(r"(?:总计|合计)", na=False)
|
|
876
|
+
].index.tolist()
|
|
877
|
+
part_one = data[start_list[0] : end_list[0]].iloc[1:, :]
|
|
878
|
+
part_two = data[start_list[1] : end_list[1]].iloc[1:, :]
|
|
879
|
+
part_three = data[start_list[2] : end_list[2]].iloc[1:, :]
|
|
861
880
|
temp_df = pd.concat(
|
|
862
|
-
[
|
|
881
|
+
objs=[
|
|
863
882
|
part_one.reset_index(drop=True),
|
|
864
883
|
part_two.reset_index(drop=True),
|
|
865
884
|
part_three.reset_index(drop=True),
|
|
@@ -930,7 +949,7 @@ def futures_dce_position_rank(
|
|
|
930
949
|
temp_df["vol"] = pd.to_numeric(temp_df["vol"], errors="coerce")
|
|
931
950
|
temp_df["vol_chg"] = pd.to_numeric(temp_df["vol_chg"], errors="coerce")
|
|
932
951
|
big_dict[file_name.split("_")[1]] = temp_df
|
|
933
|
-
except UnicodeDecodeError
|
|
952
|
+
except UnicodeDecodeError:
|
|
934
953
|
try:
|
|
935
954
|
data = pd.read_table(
|
|
936
955
|
z.open(i),
|
|
@@ -939,7 +958,7 @@ def futures_dce_position_rank(
|
|
|
939
958
|
encoding="gb2312",
|
|
940
959
|
skiprows=3,
|
|
941
960
|
)
|
|
942
|
-
except:
|
|
961
|
+
except: # noqa: E722
|
|
943
962
|
data = pd.read_table(
|
|
944
963
|
z.open(i),
|
|
945
964
|
header=None,
|
|
@@ -949,11 +968,11 @@ def futures_dce_position_rank(
|
|
|
949
968
|
)
|
|
950
969
|
start_list = data[data.iloc[:, 0].str.find("名次") == 0].index.tolist()
|
|
951
970
|
end_list = data[data.iloc[:, 0].str.find("总计") == 0].index.tolist()
|
|
952
|
-
part_one = data[start_list[0]: end_list[0]].iloc[1:, :]
|
|
953
|
-
part_two = data[start_list[1]: end_list[1]].iloc[1:, :]
|
|
954
|
-
part_three = data[start_list[2]: end_list[2]].iloc[1:, :]
|
|
971
|
+
part_one = data[start_list[0] : end_list[0]].iloc[1:, :]
|
|
972
|
+
part_two = data[start_list[1] : end_list[1]].iloc[1:, :]
|
|
973
|
+
part_three = data[start_list[2] : end_list[2]].iloc[1:, :]
|
|
955
974
|
temp_df = pd.concat(
|
|
956
|
-
[
|
|
975
|
+
objs=[
|
|
957
976
|
part_one.reset_index(drop=True),
|
|
958
977
|
part_two.reset_index(drop=True),
|
|
959
978
|
part_three.reset_index(drop=True),
|
|
@@ -1058,7 +1077,7 @@ def futures_dce_position_rank_other(date: str = "20160104"):
|
|
|
1058
1077
|
"contract": "",
|
|
1059
1078
|
}
|
|
1060
1079
|
r = requests.post(url, data=payload)
|
|
1061
|
-
soup = BeautifulSoup(r.text, "lxml")
|
|
1080
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
1062
1081
|
symbol_list = [
|
|
1063
1082
|
item["onclick"].strip("javascript:setVariety(").strip("');")
|
|
1064
1083
|
for item in soup.find_all(attrs={"class": "selBox"})[-3].find_all("input")
|
|
@@ -1076,7 +1095,7 @@ def futures_dce_position_rank_other(date: str = "20160104"):
|
|
|
1076
1095
|
"contract": "",
|
|
1077
1096
|
}
|
|
1078
1097
|
r = requests.post(url, data=payload)
|
|
1079
|
-
soup = BeautifulSoup(r.text, "lxml")
|
|
1098
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
1080
1099
|
contract_list = [
|
|
1081
1100
|
item["onclick"].strip("javascript:setContract_id('").strip("');")
|
|
1082
1101
|
for item in soup.find_all(attrs={"name": "contract"})
|
|
@@ -1142,16 +1161,17 @@ def __futures_gfex_vars_list() -> list:
|
|
|
1142
1161
|
"""
|
|
1143
1162
|
url = "http://www.gfex.com.cn/u/interfacesWebVariety/loadList"
|
|
1144
1163
|
headers = {
|
|
1145
|
-
|
|
1164
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
1165
|
+
"Chrome/119.0.0.0 Safari/537.36"
|
|
1146
1166
|
}
|
|
1147
1167
|
r = requests.post(url=url, headers=headers)
|
|
1148
1168
|
data_json = r.json()
|
|
1149
|
-
temp_df = pd.DataFrame(data_json[
|
|
1150
|
-
var_list = temp_df[
|
|
1169
|
+
temp_df = pd.DataFrame(data_json["data"])
|
|
1170
|
+
var_list = temp_df["varietyId"].tolist()
|
|
1151
1171
|
return var_list
|
|
1152
1172
|
|
|
1153
1173
|
|
|
1154
|
-
def __futures_gfex_contract_list(symbol: str = "si", date: str = "
|
|
1174
|
+
def __futures_gfex_contract_list(symbol: str = "si", date: str = "20240729") -> list:
|
|
1155
1175
|
"""
|
|
1156
1176
|
广州期货交易所-合约具体名称列表
|
|
1157
1177
|
http://www.gfex.com.cn/gfex/rcjccpm/hqsj_tjsj.shtml
|
|
@@ -1164,23 +1184,25 @@ def __futures_gfex_contract_list(symbol: str = "si", date: str = "20231113") ->
|
|
|
1164
1184
|
"""
|
|
1165
1185
|
url = "http://www.gfex.com.cn/u/interfacesWebTiMemberDealPosiQuotes/loadListContract_id"
|
|
1166
1186
|
payload = {
|
|
1167
|
-
|
|
1168
|
-
|
|
1187
|
+
"variety": symbol,
|
|
1188
|
+
"trade_date": date,
|
|
1169
1189
|
}
|
|
1170
1190
|
headers = {
|
|
1171
|
-
|
|
1191
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
1192
|
+
"Chrome/119.0.0.0 Safari/537.36"
|
|
1172
1193
|
}
|
|
1173
1194
|
r = requests.post(url=url, data=payload, headers=headers)
|
|
1174
1195
|
data_json = r.json()
|
|
1175
|
-
temp_df = pd.DataFrame(data_json[
|
|
1196
|
+
temp_df = pd.DataFrame(data_json["data"])
|
|
1197
|
+
if temp_df.empty:
|
|
1198
|
+
return []
|
|
1176
1199
|
contract_list = temp_df.iloc[:, 0].tolist()
|
|
1177
1200
|
return contract_list
|
|
1178
1201
|
|
|
1179
1202
|
|
|
1180
1203
|
def __futures_gfex_contract_data(
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
date: str = "20231113") -> pd.DataFrame:
|
|
1204
|
+
symbol: str = "si", contract_id: str = "si2312", date: str = "20231113"
|
|
1205
|
+
) -> pd.DataFrame:
|
|
1184
1206
|
"""
|
|
1185
1207
|
广州期货交易所-合约具体数据
|
|
1186
1208
|
http://www.gfex.com.cn/gfex/rcjccpm/hqsj_tjsj.shtml
|
|
@@ -1195,52 +1217,78 @@ def __futures_gfex_contract_data(
|
|
|
1195
1217
|
"""
|
|
1196
1218
|
url = "http://www.gfex.com.cn/u/interfacesWebTiMemberDealPosiQuotes/loadList"
|
|
1197
1219
|
payload = {
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1220
|
+
"trade_date": date,
|
|
1221
|
+
"trade_type": "0",
|
|
1222
|
+
"variety": symbol,
|
|
1223
|
+
"contract_id": contract_id,
|
|
1224
|
+
"data_type": "1",
|
|
1203
1225
|
}
|
|
1204
1226
|
headers = {
|
|
1205
|
-
|
|
1227
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
1228
|
+
"Chrome/119.0.0.0 Safari/537.36"
|
|
1206
1229
|
}
|
|
1207
1230
|
big_df = pd.DataFrame()
|
|
1208
1231
|
for page in range(1, 4):
|
|
1209
|
-
payload.update(
|
|
1210
|
-
|
|
1211
|
-
|
|
1232
|
+
payload.update(
|
|
1233
|
+
{
|
|
1234
|
+
"data_type": page,
|
|
1235
|
+
}
|
|
1236
|
+
)
|
|
1212
1237
|
r = requests.post(url=url, data=payload, headers=headers)
|
|
1213
1238
|
data_json = r.json()
|
|
1214
|
-
temp_df = pd.DataFrame(data_json[
|
|
1239
|
+
temp_df = pd.DataFrame(data_json["data"])
|
|
1215
1240
|
if "qtySub" in temp_df.columns:
|
|
1216
|
-
temp_df.rename(
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1241
|
+
temp_df.rename(
|
|
1242
|
+
columns={
|
|
1243
|
+
"abbr": "vol_party_name",
|
|
1244
|
+
"todayQty": "vol",
|
|
1245
|
+
"qtySub": "vol_chg",
|
|
1246
|
+
},
|
|
1247
|
+
inplace=True,
|
|
1248
|
+
)
|
|
1221
1249
|
else:
|
|
1222
|
-
temp_df.rename(
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1250
|
+
temp_df.rename(
|
|
1251
|
+
columns={
|
|
1252
|
+
"abbr": "vol_party_name",
|
|
1253
|
+
"todayQty": "vol",
|
|
1254
|
+
"todayQtyChg": "vol_chg",
|
|
1255
|
+
},
|
|
1256
|
+
inplace=True,
|
|
1257
|
+
)
|
|
1227
1258
|
temp_df = temp_df[["vol_party_name", "vol", "vol_chg"]]
|
|
1228
1259
|
big_df = pd.concat(objs=[big_df, temp_df], axis=1, ignore_index=True)
|
|
1229
1260
|
big_df.reset_index(inplace=True)
|
|
1230
|
-
big_df[
|
|
1231
|
-
big_df.columns = [
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1261
|
+
big_df["index"] = big_df["index"] + 1
|
|
1262
|
+
big_df.columns = [
|
|
1263
|
+
"rank",
|
|
1264
|
+
"vol_party_name",
|
|
1265
|
+
"vol",
|
|
1266
|
+
"vol_chg",
|
|
1267
|
+
"long_party_name",
|
|
1268
|
+
"long_open_interest",
|
|
1269
|
+
"long_open_interest_chg",
|
|
1270
|
+
"short_party_name",
|
|
1271
|
+
"short_open_interest",
|
|
1272
|
+
"short_open_interest_chg",
|
|
1273
|
+
]
|
|
1274
|
+
big_df["symbol"] = contract_id.upper()
|
|
1275
|
+
big_df["variety"] = symbol.upper()
|
|
1236
1276
|
big_df = big_df.iloc[:-1, :]
|
|
1237
1277
|
|
|
1238
|
-
big_df[
|
|
1239
|
-
big_df[
|
|
1240
|
-
big_df[
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
big_df[
|
|
1278
|
+
big_df["vol"] = pd.to_numeric(big_df["vol"], errors="coerce")
|
|
1279
|
+
big_df["vol_chg"] = pd.to_numeric(big_df["vol_chg"], errors="coerce")
|
|
1280
|
+
big_df["long_open_interest"] = pd.to_numeric(
|
|
1281
|
+
big_df["long_open_interest"], errors="coerce"
|
|
1282
|
+
)
|
|
1283
|
+
big_df["long_open_interest_chg"] = pd.to_numeric(
|
|
1284
|
+
big_df["long_open_interest_chg"], errors="coerce"
|
|
1285
|
+
)
|
|
1286
|
+
big_df["short_open_interest"] = pd.to_numeric(
|
|
1287
|
+
big_df["short_open_interest"], errors="coerce"
|
|
1288
|
+
)
|
|
1289
|
+
big_df["short_open_interest_chg"] = pd.to_numeric(
|
|
1290
|
+
big_df["short_open_interest_chg"], errors="coerce"
|
|
1291
|
+
)
|
|
1244
1292
|
return big_df
|
|
1245
1293
|
|
|
1246
1294
|
|
|
@@ -1267,18 +1315,19 @@ def futures_gfex_position_rank(date: str = "20231113", vars_list: list = None):
|
|
|
1267
1315
|
big_dict = {}
|
|
1268
1316
|
for item in vars_list:
|
|
1269
1317
|
try:
|
|
1270
|
-
futures_contract_list = __futures_gfex_contract_list(
|
|
1271
|
-
|
|
1272
|
-
|
|
1318
|
+
futures_contract_list = __futures_gfex_contract_list(
|
|
1319
|
+
symbol=item.lower(), date=date
|
|
1320
|
+
)
|
|
1321
|
+
except: # noqa: E722
|
|
1322
|
+
return big_dict
|
|
1273
1323
|
for name in futures_contract_list:
|
|
1274
1324
|
try:
|
|
1275
1325
|
temp_df = __futures_gfex_contract_data(
|
|
1276
|
-
symbol=item.lower(),
|
|
1277
|
-
|
|
1278
|
-
date=date)
|
|
1326
|
+
symbol=item.lower(), contract_id=name, date=date
|
|
1327
|
+
)
|
|
1279
1328
|
big_dict[name] = temp_df
|
|
1280
|
-
except:
|
|
1281
|
-
return
|
|
1329
|
+
except: # noqa: E722
|
|
1330
|
+
return big_dict
|
|
1282
1331
|
return big_dict
|
|
1283
1332
|
|
|
1284
1333
|
|
|
@@ -1295,42 +1344,41 @@ if __name__ == "__main__":
|
|
|
1295
1344
|
print(get_cffex_rank_table_df)
|
|
1296
1345
|
|
|
1297
1346
|
# 上海期货交易所
|
|
1298
|
-
get_shfe_rank_table_df = get_shfe_rank_table(date="
|
|
1347
|
+
get_shfe_rank_table_df = get_shfe_rank_table(date="20240509")
|
|
1299
1348
|
print(get_shfe_rank_table_df)
|
|
1300
1349
|
|
|
1301
1350
|
# 大连商品交易所-老接口
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
# )
|
|
1317
|
-
# print(get_dce_rank_table_fourth_df)
|
|
1351
|
+
get_dce_rank_table_first_df = get_dce_rank_table(date="20131227")
|
|
1352
|
+
print(get_dce_rank_table_first_df)
|
|
1353
|
+
|
|
1354
|
+
get_dce_rank_table_second_df = get_dce_rank_table(date="20171227")
|
|
1355
|
+
print(get_dce_rank_table_second_df)
|
|
1356
|
+
|
|
1357
|
+
get_dce_rank_table_third_df = get_dce_rank_table(date="20200929")
|
|
1358
|
+
print(get_dce_rank_table_third_df)
|
|
1359
|
+
|
|
1360
|
+
get_dce_rank_table_third_df = get_dce_rank_table(date="20230706")
|
|
1361
|
+
print(get_dce_rank_table_third_df)
|
|
1362
|
+
|
|
1363
|
+
get_dce_rank_table_fourth_df = get_dce_rank_table(date="20210517", vars_list=["V"])
|
|
1364
|
+
print(get_dce_rank_table_fourth_df)
|
|
1318
1365
|
|
|
1319
1366
|
# 大连商品交易所-新接口
|
|
1320
|
-
futures_dce_detail_dict = futures_dce_position_rank(date="
|
|
1367
|
+
futures_dce_detail_dict = futures_dce_position_rank(date="20240517")
|
|
1321
1368
|
print(futures_dce_detail_dict)
|
|
1322
1369
|
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1370
|
+
futures_dce_position_rank_other_df = futures_dce_position_rank_other(
|
|
1371
|
+
date="20200727"
|
|
1372
|
+
)
|
|
1373
|
+
print(futures_dce_position_rank_other_df)
|
|
1327
1374
|
|
|
1328
1375
|
# 广州期货交易所
|
|
1329
|
-
futures_gfex_position_rank_df = futures_gfex_position_rank(date="
|
|
1376
|
+
futures_gfex_position_rank_df = futures_gfex_position_rank(date="20240729")
|
|
1330
1377
|
print(futures_gfex_position_rank_df)
|
|
1331
1378
|
|
|
1332
1379
|
# 总接口
|
|
1333
1380
|
get_rank_sum_daily_df = get_rank_sum_daily(
|
|
1334
|
-
start_day="20231010",
|
|
1381
|
+
start_day="20231010",
|
|
1382
|
+
end_day="20231013",
|
|
1335
1383
|
)
|
|
1336
1384
|
print(get_rank_sum_daily_df)
|