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,12 +1,11 @@
|
|
|
1
1
|
# -*- coding:utf-8 -*-
|
|
2
2
|
# !/usr/bin/env python
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/4/14 15:00
|
|
5
5
|
Desc: 东方财富网-数据中心-沪深港通持股
|
|
6
6
|
https://data.eastmoney.com/hsgtcg/
|
|
7
7
|
沪深港通详情: https://finance.eastmoney.com/news/1622,20161118685370149.html
|
|
8
8
|
"""
|
|
9
|
-
import json
|
|
10
9
|
|
|
11
10
|
import pandas as pd
|
|
12
11
|
import requests
|
|
@@ -24,9 +23,12 @@ def stock_hsgt_fund_flow_summary_em() -> pd.DataFrame:
|
|
|
24
23
|
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
|
|
25
24
|
params = {
|
|
26
25
|
"reportName": "RPT_MUTUAL_QUOTA",
|
|
27
|
-
"columns": "TRADE_DATE,MUTUAL_TYPE,BOARD_TYPE,MUTUAL_TYPE_NAME,FUNDS_DIRECTION,
|
|
28
|
-
"
|
|
29
|
-
|
|
26
|
+
"columns": "TRADE_DATE,MUTUAL_TYPE,BOARD_TYPE,MUTUAL_TYPE_NAME,FUNDS_DIRECTION,"
|
|
27
|
+
"INDEX_CODE,INDEX_NAME,BOARD_CODE",
|
|
28
|
+
"quoteColumns": "status~07~BOARD_CODE,dayNetAmtIn~07~BOARD_CODE,dayAmtRemain~07~BOARD_CODE,"
|
|
29
|
+
"dayAmtThreshold~07~BOARD_CODE,f104~07~BOARD_CODE,f105~07~BOARD_CODE,"
|
|
30
|
+
"f106~07~BOARD_CODE,f3~03~INDEX_CODE~INDEX_f3,netBuyAmt~07~BOARD_CODE",
|
|
31
|
+
"quoteType": "0",
|
|
30
32
|
"pageNumber": "1",
|
|
31
33
|
"pageSize": "2000",
|
|
32
34
|
"sortTypes": "1",
|
|
@@ -57,32 +59,34 @@ def stock_hsgt_fund_flow_summary_em() -> pd.DataFrame:
|
|
|
57
59
|
"指数涨跌幅",
|
|
58
60
|
"成交净买额",
|
|
59
61
|
]
|
|
60
|
-
temp_df = temp_df[
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
temp_df[
|
|
78
|
-
temp_df[
|
|
79
|
-
temp_df[
|
|
80
|
-
temp_df[
|
|
81
|
-
temp_df[
|
|
82
|
-
temp_df[
|
|
83
|
-
temp_df[
|
|
84
|
-
temp_df[
|
|
85
|
-
temp_df[
|
|
62
|
+
temp_df = temp_df[
|
|
63
|
+
[
|
|
64
|
+
"交易日",
|
|
65
|
+
"类型",
|
|
66
|
+
"板块",
|
|
67
|
+
"资金方向",
|
|
68
|
+
"交易状态",
|
|
69
|
+
"成交净买额",
|
|
70
|
+
"资金净流入",
|
|
71
|
+
"当日资金余额",
|
|
72
|
+
"上涨数",
|
|
73
|
+
"持平数",
|
|
74
|
+
"下跌数",
|
|
75
|
+
"相关指数",
|
|
76
|
+
"指数涨跌幅",
|
|
77
|
+
]
|
|
78
|
+
]
|
|
79
|
+
temp_df["交易日"] = pd.to_datetime(temp_df["交易日"], errors="coerce").dt.date
|
|
80
|
+
temp_df["成交净买额"] = pd.to_numeric(temp_df["成交净买额"], errors="coerce")
|
|
81
|
+
temp_df["资金净流入"] = pd.to_numeric(temp_df["资金净流入"], errors="coerce")
|
|
82
|
+
temp_df["当日资金余额"] = pd.to_numeric(temp_df["当日资金余额"], errors="coerce")
|
|
83
|
+
temp_df["上涨数"] = pd.to_numeric(temp_df["上涨数"], errors="coerce")
|
|
84
|
+
temp_df["持平数"] = pd.to_numeric(temp_df["持平数"], errors="coerce")
|
|
85
|
+
temp_df["下跌数"] = pd.to_numeric(temp_df["下跌数"], errors="coerce")
|
|
86
|
+
temp_df["指数涨跌幅"] = pd.to_numeric(temp_df["指数涨跌幅"], errors="coerce")
|
|
87
|
+
temp_df["成交净买额"] = temp_df["成交净买额"] / 10000
|
|
88
|
+
temp_df["资金净流入"] = temp_df["资金净流入"] / 10000
|
|
89
|
+
temp_df["当日资金余额"] = temp_df["当日资金余额"] / 10000
|
|
86
90
|
return temp_df
|
|
87
91
|
|
|
88
92
|
|
|
@@ -103,7 +107,8 @@ def stock_hk_ggt_components_em() -> pd.DataFrame:
|
|
|
103
107
|
"fltt": "2",
|
|
104
108
|
"fid": "f3",
|
|
105
109
|
"fs": "b:DLMK0146,b:DLMK0144",
|
|
106
|
-
"fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f23,f24,
|
|
110
|
+
"fields": "f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f19,f20,f21,f23,f24,"
|
|
111
|
+
"f25,f26,f22,f33,f11,f62,f128,f136,f115,f152",
|
|
107
112
|
"_": "1639974456250",
|
|
108
113
|
}
|
|
109
114
|
r = requests.get(url, params=params)
|
|
@@ -167,312 +172,6 @@ def stock_hk_ggt_components_em() -> pd.DataFrame:
|
|
|
167
172
|
return temp_df
|
|
168
173
|
|
|
169
174
|
|
|
170
|
-
def stock_hsgt_north_net_flow_in_em(symbol: str = "沪股通") -> pd.DataFrame:
|
|
171
|
-
"""
|
|
172
|
-
东方财富网-数据中心-沪深港通持股-北向概括-净流入
|
|
173
|
-
http://data.eastmoney.com/hsgtcg/
|
|
174
|
-
:param symbol: choice of {"沪股通", "深股通", "北上"}
|
|
175
|
-
:type symbol: str
|
|
176
|
-
:return: 东方财富网-数据中心-沪深港通持股-北向概括-净流入
|
|
177
|
-
:rtype: pandas.DataFrame
|
|
178
|
-
"""
|
|
179
|
-
url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
|
|
180
|
-
params = {
|
|
181
|
-
"fields1": "f1,f3,f5",
|
|
182
|
-
"fields2": "f51,f52",
|
|
183
|
-
"klt": "101",
|
|
184
|
-
"lmt": "5000",
|
|
185
|
-
"ut": "b2884a393a59ad64002292a3e90d46a5",
|
|
186
|
-
"cb": "jQuery18305732402561585701_1584961751919",
|
|
187
|
-
"_": "1584962164273",
|
|
188
|
-
}
|
|
189
|
-
r = requests.get(url, params=params)
|
|
190
|
-
data_text = r.text
|
|
191
|
-
data_json = json.loads(data_text[data_text.find("{") : -2])
|
|
192
|
-
if symbol == "沪股通":
|
|
193
|
-
temp_df = (
|
|
194
|
-
pd.DataFrame(data_json["data"]["hk2sh"])
|
|
195
|
-
.iloc[:, 0]
|
|
196
|
-
.str.split(",", expand=True)
|
|
197
|
-
)
|
|
198
|
-
temp_df.columns = ["date", "value"]
|
|
199
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
200
|
-
return temp_df
|
|
201
|
-
if symbol == "深股通":
|
|
202
|
-
temp_df = (
|
|
203
|
-
pd.DataFrame(data_json["data"]["hk2sz"])
|
|
204
|
-
.iloc[:, 0]
|
|
205
|
-
.str.split(",", expand=True)
|
|
206
|
-
)
|
|
207
|
-
temp_df.columns = ["date", "value"]
|
|
208
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
209
|
-
return temp_df
|
|
210
|
-
if symbol == "北上":
|
|
211
|
-
temp_df = (
|
|
212
|
-
pd.DataFrame(data_json["data"]["s2n"])
|
|
213
|
-
.iloc[:, 0]
|
|
214
|
-
.str.split(",", expand=True)
|
|
215
|
-
)
|
|
216
|
-
temp_df.columns = ["date", "value"]
|
|
217
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
218
|
-
return temp_df
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
def stock_hsgt_north_cash_em(symbol: str = "沪股通") -> pd.DataFrame:
|
|
222
|
-
"""
|
|
223
|
-
东方财富网-数据中心-沪深港通持股-北向概括-资金余额
|
|
224
|
-
http://data.eastmoney.com/hsgtcg/
|
|
225
|
-
:param symbol: choice of {"沪股通", "深股通", "北上"}
|
|
226
|
-
:type symbol: str
|
|
227
|
-
:return: 东方财富网-数据中心-沪深港通持股-北向概括-资金余额
|
|
228
|
-
:rtype: pandas.DataFrame
|
|
229
|
-
"""
|
|
230
|
-
url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
|
|
231
|
-
params = {
|
|
232
|
-
"fields1": "f1,f3,f5",
|
|
233
|
-
"fields2": "f51,f53",
|
|
234
|
-
"klt": "101",
|
|
235
|
-
"lmt": "5000",
|
|
236
|
-
"ut": "b2884a393a59ad64002292a3e90d46a5",
|
|
237
|
-
"cb": "jQuery18305732402561585701_1584961751919",
|
|
238
|
-
"_": "1584962164273",
|
|
239
|
-
}
|
|
240
|
-
r = requests.get(url, params=params)
|
|
241
|
-
data_text = r.text
|
|
242
|
-
data_json = json.loads(data_text[data_text.find("{") : -2])
|
|
243
|
-
if symbol == "沪股通":
|
|
244
|
-
temp_df = (
|
|
245
|
-
pd.DataFrame(data_json["data"]["hk2sh"])
|
|
246
|
-
.iloc[:, 0]
|
|
247
|
-
.str.split(",", expand=True)
|
|
248
|
-
)
|
|
249
|
-
temp_df.columns = ["date", "value"]
|
|
250
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
251
|
-
return temp_df
|
|
252
|
-
if symbol == "深股通":
|
|
253
|
-
temp_df = (
|
|
254
|
-
pd.DataFrame(data_json["data"]["hk2sz"])
|
|
255
|
-
.iloc[:, 0]
|
|
256
|
-
.str.split(",", expand=True)
|
|
257
|
-
)
|
|
258
|
-
temp_df.columns = ["date", "value"]
|
|
259
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
260
|
-
return temp_df
|
|
261
|
-
if symbol == "北上":
|
|
262
|
-
temp_df = (
|
|
263
|
-
pd.DataFrame(data_json["data"]["s2n"])
|
|
264
|
-
.iloc[:, 0]
|
|
265
|
-
.str.split(",", expand=True)
|
|
266
|
-
)
|
|
267
|
-
temp_df.columns = ["date", "value"]
|
|
268
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
269
|
-
return temp_df
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
def stock_hsgt_north_acc_flow_in_em(symbol: str = "沪股通") -> pd.DataFrame:
|
|
273
|
-
"""
|
|
274
|
-
东方财富网-数据中心-沪深港通持股-北向概况-累计净流入
|
|
275
|
-
http://data.eastmoney.com/hsgtcg/
|
|
276
|
-
:param symbol: choice of {"沪股通", "深股通", "北上"}
|
|
277
|
-
:type symbol: str
|
|
278
|
-
:return: 东方财富网-数据中心-沪深港通持股-北向概括-累计净流入
|
|
279
|
-
:rtype: pandas.DataFrame
|
|
280
|
-
"""
|
|
281
|
-
url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
|
|
282
|
-
params = {
|
|
283
|
-
"fields1": "f1,f3,f5",
|
|
284
|
-
"fields2": "f51,f54",
|
|
285
|
-
"klt": "101",
|
|
286
|
-
"lmt": "5000",
|
|
287
|
-
"ut": "b2884a393a59ad64002292a3e90d46a5",
|
|
288
|
-
"cb": "jQuery18305732402561585701_1584961751919",
|
|
289
|
-
"_": "1584962164273",
|
|
290
|
-
}
|
|
291
|
-
r = requests.get(url, params=params)
|
|
292
|
-
data_text = r.text
|
|
293
|
-
data_json = json.loads(data_text[data_text.find("{") : -2])
|
|
294
|
-
if symbol == "沪股通":
|
|
295
|
-
temp_df = (
|
|
296
|
-
pd.DataFrame(data_json["data"]["hk2sh"])
|
|
297
|
-
.iloc[:, 0]
|
|
298
|
-
.str.split(",", expand=True)
|
|
299
|
-
)
|
|
300
|
-
temp_df.columns = ["date", "value"]
|
|
301
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
302
|
-
return temp_df
|
|
303
|
-
if symbol == "深股通":
|
|
304
|
-
temp_df = (
|
|
305
|
-
pd.DataFrame(data_json["data"]["hk2sz"])
|
|
306
|
-
.iloc[:, 0]
|
|
307
|
-
.str.split(",", expand=True)
|
|
308
|
-
)
|
|
309
|
-
temp_df.columns = ["date", "value"]
|
|
310
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
311
|
-
return temp_df
|
|
312
|
-
if symbol == "北上":
|
|
313
|
-
temp_df = (
|
|
314
|
-
pd.DataFrame(data_json["data"]["s2n"])
|
|
315
|
-
.iloc[:, 0]
|
|
316
|
-
.str.split(",", expand=True)
|
|
317
|
-
)
|
|
318
|
-
temp_df.columns = ["date", "value"]
|
|
319
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
320
|
-
return temp_df
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
def stock_hsgt_south_net_flow_in_em(symbol: str = "沪股通") -> pd.DataFrame:
|
|
324
|
-
"""
|
|
325
|
-
东方财富网-数据中心-沪深港通持股-南向概括-净流入
|
|
326
|
-
http://data.eastmoney.com/hsgtcg/
|
|
327
|
-
:param symbol: choice of {"沪股通", "深股通", "南下"}
|
|
328
|
-
:type symbol: str
|
|
329
|
-
:return: 东方财富网-数据中心-沪深港通持股-南向概括-净流入
|
|
330
|
-
:rtype: pandas.DataFrame
|
|
331
|
-
"""
|
|
332
|
-
url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
|
|
333
|
-
params = {
|
|
334
|
-
"fields1": "f2,f4,f6",
|
|
335
|
-
"fields2": "f51,f52",
|
|
336
|
-
"klt": "101",
|
|
337
|
-
"lmt": "5000",
|
|
338
|
-
"ut": "b2884a393a59ad64002292a3e90d46a5",
|
|
339
|
-
"cb": "jQuery18307854355493858363_1584963487410",
|
|
340
|
-
"_": "1584964176697",
|
|
341
|
-
}
|
|
342
|
-
r = requests.get(url, params=params)
|
|
343
|
-
data_text = r.text
|
|
344
|
-
data_json = json.loads(data_text[data_text.find("{") : -2])
|
|
345
|
-
if symbol == "沪股通":
|
|
346
|
-
temp_df = (
|
|
347
|
-
pd.DataFrame(data_json["data"]["sh2hk"])
|
|
348
|
-
.iloc[:, 0]
|
|
349
|
-
.str.split(",", expand=True)
|
|
350
|
-
)
|
|
351
|
-
temp_df.columns = ["date", "value"]
|
|
352
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
353
|
-
return temp_df
|
|
354
|
-
if symbol == "深股通":
|
|
355
|
-
temp_df = (
|
|
356
|
-
pd.DataFrame(data_json["data"]["sz2hk"])
|
|
357
|
-
.iloc[:, 0]
|
|
358
|
-
.str.split(",", expand=True)
|
|
359
|
-
)
|
|
360
|
-
temp_df.columns = ["date", "value"]
|
|
361
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
362
|
-
return temp_df
|
|
363
|
-
if symbol == "南下":
|
|
364
|
-
temp_df = (
|
|
365
|
-
pd.DataFrame(data_json["data"]["n2s"])
|
|
366
|
-
.iloc[:, 0]
|
|
367
|
-
.str.split(",", expand=True)
|
|
368
|
-
)
|
|
369
|
-
temp_df.columns = ["date", "value"]
|
|
370
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
371
|
-
return temp_df
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
def stock_hsgt_south_cash_em(symbol: str = "沪股通") -> pd.DataFrame:
|
|
375
|
-
"""
|
|
376
|
-
东方财富网-数据中心-沪深港通持股-南向概括-资金余额
|
|
377
|
-
http://data.eastmoney.com/hsgtcg/
|
|
378
|
-
:param symbol: choice of {"沪股通", "深股通", "南下"}
|
|
379
|
-
:type symbol: str
|
|
380
|
-
:return: 东方财富网-数据中心-沪深港通持股-南向概括-资金余额
|
|
381
|
-
:rtype: pandas.DataFrame
|
|
382
|
-
"""
|
|
383
|
-
url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
|
|
384
|
-
params = {
|
|
385
|
-
"fields1": "f2,f4,f6",
|
|
386
|
-
"fields2": "f51,f53",
|
|
387
|
-
"klt": "101",
|
|
388
|
-
"lmt": "5000",
|
|
389
|
-
"ut": "b2884a393a59ad64002292a3e90d46a5",
|
|
390
|
-
"cb": "jQuery18307854355493858363_1584963487410",
|
|
391
|
-
"_": "1584964176697",
|
|
392
|
-
}
|
|
393
|
-
r = requests.get(url, params=params)
|
|
394
|
-
data_text = r.text
|
|
395
|
-
data_json = json.loads(data_text[data_text.find("{") : -2])
|
|
396
|
-
if symbol == "沪股通":
|
|
397
|
-
temp_df = (
|
|
398
|
-
pd.DataFrame(data_json["data"]["sh2hk"])
|
|
399
|
-
.iloc[:, 0]
|
|
400
|
-
.str.split(",", expand=True)
|
|
401
|
-
)
|
|
402
|
-
temp_df.columns = ["date", "value"]
|
|
403
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
404
|
-
return temp_df
|
|
405
|
-
if symbol == "深股通":
|
|
406
|
-
temp_df = (
|
|
407
|
-
pd.DataFrame(data_json["data"]["sz2hk"])
|
|
408
|
-
.iloc[:, 0]
|
|
409
|
-
.str.split(",", expand=True)
|
|
410
|
-
)
|
|
411
|
-
temp_df.columns = ["date", "value"]
|
|
412
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
413
|
-
return temp_df
|
|
414
|
-
if symbol == "南下":
|
|
415
|
-
temp_df = (
|
|
416
|
-
pd.DataFrame(data_json["data"]["n2s"])
|
|
417
|
-
.iloc[:, 0]
|
|
418
|
-
.str.split(",", expand=True)
|
|
419
|
-
)
|
|
420
|
-
temp_df.columns = ["date", "value"]
|
|
421
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
422
|
-
return temp_df
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
def stock_hsgt_south_acc_flow_in_em(symbol: str = "沪股通") -> pd.DataFrame:
|
|
426
|
-
"""
|
|
427
|
-
东方财富网-数据中心-沪深港通持股-南向概括-累计净流入
|
|
428
|
-
http://data.eastmoney.com/hsgtcg/
|
|
429
|
-
:param symbol: choice of {"沪股通", "深股通", "南下"}
|
|
430
|
-
:type symbol: str
|
|
431
|
-
:return: 东方财富网-数据中心-沪深港通持股-南向概括-累计净流入
|
|
432
|
-
:rtype: pandas.DataFrame
|
|
433
|
-
"""
|
|
434
|
-
url = "http://push2his.eastmoney.com/api/qt/kamt.kline/get"
|
|
435
|
-
params = {
|
|
436
|
-
"fields1": "f2,f4,f6",
|
|
437
|
-
"fields2": "f51,f54",
|
|
438
|
-
"klt": "101",
|
|
439
|
-
"lmt": "5000",
|
|
440
|
-
"ut": "b2884a393a59ad64002292a3e90d46a5",
|
|
441
|
-
"cb": "jQuery18307854355493858363_1584963487410",
|
|
442
|
-
"_": "1584964176697",
|
|
443
|
-
}
|
|
444
|
-
r = requests.get(url, params=params)
|
|
445
|
-
data_text = r.text
|
|
446
|
-
data_json = json.loads(data_text[data_text.find("{") : -2])
|
|
447
|
-
if symbol == "沪股通":
|
|
448
|
-
temp_df = (
|
|
449
|
-
pd.DataFrame(data_json["data"]["sh2hk"])
|
|
450
|
-
.iloc[:, 0]
|
|
451
|
-
.str.split(",", expand=True)
|
|
452
|
-
)
|
|
453
|
-
temp_df.columns = ["date", "value"]
|
|
454
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
455
|
-
return temp_df
|
|
456
|
-
if symbol == "深股通":
|
|
457
|
-
temp_df = (
|
|
458
|
-
pd.DataFrame(data_json["data"]["sz2hk"])
|
|
459
|
-
.iloc[:, 0]
|
|
460
|
-
.str.split(",", expand=True)
|
|
461
|
-
)
|
|
462
|
-
temp_df.columns = ["date", "value"]
|
|
463
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
464
|
-
return temp_df
|
|
465
|
-
if symbol == "南下":
|
|
466
|
-
temp_df = (
|
|
467
|
-
pd.DataFrame(data_json["data"]["n2s"])
|
|
468
|
-
.iloc[:, 0]
|
|
469
|
-
.str.split(",", expand=True)
|
|
470
|
-
)
|
|
471
|
-
temp_df.columns = ["date", "value"]
|
|
472
|
-
temp_df["value"] = pd.to_numeric(temp_df["value"])
|
|
473
|
-
return temp_df
|
|
474
|
-
|
|
475
|
-
|
|
476
175
|
def stock_hsgt_hold_stock_em(
|
|
477
176
|
market: str = "沪股通", indicator: str = "5日排行"
|
|
478
177
|
) -> pd.DataFrame:
|
|
@@ -496,6 +195,8 @@ def stock_hsgt_hold_stock_em(
|
|
|
496
195
|
.strip(")")
|
|
497
196
|
)
|
|
498
197
|
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
|
|
198
|
+
indicator_type = ""
|
|
199
|
+
filter_str = ""
|
|
499
200
|
if indicator == "今日排行":
|
|
500
201
|
indicator_type = "1"
|
|
501
202
|
if indicator == "3日排行":
|
|
@@ -511,9 +212,7 @@ def stock_hsgt_hold_stock_em(
|
|
|
511
212
|
if indicator == "年排行":
|
|
512
213
|
indicator_type = "Y"
|
|
513
214
|
if market == "北向":
|
|
514
|
-
filter_str = (
|
|
515
|
-
f"""(TRADE_DATE='{date}')(INTERVAL_TYPE="{indicator_type}")"""
|
|
516
|
-
)
|
|
215
|
+
filter_str = f"""(TRADE_DATE='{date}')(INTERVAL_TYPE="{indicator_type}")"""
|
|
517
216
|
elif market == "沪股通":
|
|
518
217
|
filter_str = f"""(TRADE_DATE='{date}')(INTERVAL_TYPE="{indicator_type}")(MUTUAL_TYPE="001")"""
|
|
519
218
|
elif market == "深股通":
|
|
@@ -612,8 +311,12 @@ def stock_hsgt_hold_stock_em(
|
|
|
612
311
|
big_df["今日涨跌幅"] = pd.to_numeric(big_df["今日涨跌幅"], errors="coerce")
|
|
613
312
|
big_df["今日持股-股数"] = pd.to_numeric(big_df["今日持股-股数"], errors="coerce")
|
|
614
313
|
big_df["今日持股-市值"] = pd.to_numeric(big_df["今日持股-市值"], errors="coerce")
|
|
615
|
-
big_df["今日持股-占流通股比"] = pd.to_numeric(
|
|
616
|
-
|
|
314
|
+
big_df["今日持股-占流通股比"] = pd.to_numeric(
|
|
315
|
+
big_df["今日持股-占流通股比"], errors="coerce"
|
|
316
|
+
)
|
|
317
|
+
big_df["今日持股-占总股本比"] = pd.to_numeric(
|
|
318
|
+
big_df["今日持股-占总股本比"], errors="coerce"
|
|
319
|
+
)
|
|
617
320
|
big_df[f'{indicator.split("排")[0]}增持估计-股数'] = pd.to_numeric(
|
|
618
321
|
big_df[f'{indicator.split("排")[0]}增持估计-股数'], errors="coerce"
|
|
619
322
|
)
|
|
@@ -654,6 +357,7 @@ def stock_hsgt_stock_statistics_em(
|
|
|
654
357
|
"""
|
|
655
358
|
start_date = "-".join([start_date[:4], start_date[4:6], start_date[6:]])
|
|
656
359
|
end_date = "-".join([end_date[:4], end_date[4:6], end_date[6:]])
|
|
360
|
+
big_df = pd.DataFrame()
|
|
657
361
|
if symbol == "南向持股":
|
|
658
362
|
params = {
|
|
659
363
|
"sortColumns": "TRADE_DATE",
|
|
@@ -669,9 +373,7 @@ def stock_hsgt_stock_statistics_em(
|
|
|
669
373
|
}
|
|
670
374
|
if start_date == end_date:
|
|
671
375
|
params.update(
|
|
672
|
-
{
|
|
673
|
-
"filter": f"""(INTERVAL_TYPE="1")(RN=1)(TRADE_DATE='{start_date}')"""
|
|
674
|
-
}
|
|
376
|
+
{"filter": f"""(INTERVAL_TYPE="1")(RN=1)(TRADE_DATE='{start_date}')"""}
|
|
675
377
|
)
|
|
676
378
|
url = "http://datacenter-web.eastmoney.com/api/data/v1/get"
|
|
677
379
|
r = requests.get(url, params=params)
|
|
@@ -736,10 +438,18 @@ def stock_hsgt_stock_statistics_em(
|
|
|
736
438
|
big_df["当日涨跌幅"] = pd.to_numeric(big_df["当日涨跌幅"], errors="coerce")
|
|
737
439
|
big_df["持股数量"] = pd.to_numeric(big_df["持股数量"], errors="coerce")
|
|
738
440
|
big_df["持股市值"] = pd.to_numeric(big_df["持股市值"], errors="coerce")
|
|
739
|
-
big_df["持股数量占发行股百分比"] = pd.to_numeric(
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
big_df["持股市值变化-
|
|
441
|
+
big_df["持股数量占发行股百分比"] = pd.to_numeric(
|
|
442
|
+
big_df["持股数量占发行股百分比"], errors="coerce"
|
|
443
|
+
)
|
|
444
|
+
big_df["持股市值变化-1日"] = pd.to_numeric(
|
|
445
|
+
big_df["持股市值变化-1日"], errors="coerce"
|
|
446
|
+
)
|
|
447
|
+
big_df["持股市值变化-5日"] = pd.to_numeric(
|
|
448
|
+
big_df["持股市值变化-5日"], errors="coerce"
|
|
449
|
+
)
|
|
450
|
+
big_df["持股市值变化-10日"] = pd.to_numeric(
|
|
451
|
+
big_df["持股市值变化-10日"], errors="coerce"
|
|
452
|
+
)
|
|
743
453
|
elif symbol == "北向持股":
|
|
744
454
|
params = {
|
|
745
455
|
"sortColumns": "TRADE_DATE",
|
|
@@ -836,10 +546,18 @@ def stock_hsgt_stock_statistics_em(
|
|
|
836
546
|
big_df["当日涨跌幅"] = pd.to_numeric(big_df["当日涨跌幅"], errors="coerce")
|
|
837
547
|
big_df["持股数量"] = pd.to_numeric(big_df["持股数量"], errors="coerce")
|
|
838
548
|
big_df["持股市值"] = pd.to_numeric(big_df["持股市值"], errors="coerce")
|
|
839
|
-
big_df["持股数量占发行股百分比"] = pd.to_numeric(
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
big_df["持股市值变化-
|
|
549
|
+
big_df["持股数量占发行股百分比"] = pd.to_numeric(
|
|
550
|
+
big_df["持股数量占发行股百分比"], errors="coerce"
|
|
551
|
+
)
|
|
552
|
+
big_df["持股市值变化-1日"] = pd.to_numeric(
|
|
553
|
+
big_df["持股市值变化-1日"], errors="coerce"
|
|
554
|
+
)
|
|
555
|
+
big_df["持股市值变化-5日"] = pd.to_numeric(
|
|
556
|
+
big_df["持股市值变化-5日"], errors="coerce"
|
|
557
|
+
)
|
|
558
|
+
big_df["持股市值变化-10日"] = pd.to_numeric(
|
|
559
|
+
big_df["持股市值变化-10日"], errors="coerce"
|
|
560
|
+
)
|
|
843
561
|
elif symbol == "沪股通持股":
|
|
844
562
|
params = {
|
|
845
563
|
"sortColumns": "TRADE_DATE",
|
|
@@ -934,10 +652,18 @@ def stock_hsgt_stock_statistics_em(
|
|
|
934
652
|
big_df["当日涨跌幅"] = pd.to_numeric(big_df["当日涨跌幅"], errors="coerce")
|
|
935
653
|
big_df["持股数量"] = pd.to_numeric(big_df["持股数量"], errors="coerce")
|
|
936
654
|
big_df["持股市值"] = pd.to_numeric(big_df["持股市值"], errors="coerce")
|
|
937
|
-
big_df["持股数量占发行股百分比"] = pd.to_numeric(
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
big_df["持股市值变化-
|
|
655
|
+
big_df["持股数量占发行股百分比"] = pd.to_numeric(
|
|
656
|
+
big_df["持股数量占发行股百分比"], errors="coerce"
|
|
657
|
+
)
|
|
658
|
+
big_df["持股市值变化-1日"] = pd.to_numeric(
|
|
659
|
+
big_df["持股市值变化-1日"], errors="coerce"
|
|
660
|
+
)
|
|
661
|
+
big_df["持股市值变化-5日"] = pd.to_numeric(
|
|
662
|
+
big_df["持股市值变化-5日"], errors="coerce"
|
|
663
|
+
)
|
|
664
|
+
big_df["持股市值变化-10日"] = pd.to_numeric(
|
|
665
|
+
big_df["持股市值变化-10日"], errors="coerce"
|
|
666
|
+
)
|
|
941
667
|
elif symbol == "深股通持股":
|
|
942
668
|
params = {
|
|
943
669
|
"sortColumns": "TRADE_DATE",
|
|
@@ -1032,10 +758,18 @@ def stock_hsgt_stock_statistics_em(
|
|
|
1032
758
|
big_df["当日涨跌幅"] = pd.to_numeric(big_df["当日涨跌幅"], errors="coerce")
|
|
1033
759
|
big_df["持股数量"] = pd.to_numeric(big_df["持股数量"], errors="coerce")
|
|
1034
760
|
big_df["持股市值"] = pd.to_numeric(big_df["持股市值"], errors="coerce")
|
|
1035
|
-
big_df["持股数量占发行股百分比"] = pd.to_numeric(
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
big_df["持股市值变化-
|
|
761
|
+
big_df["持股数量占发行股百分比"] = pd.to_numeric(
|
|
762
|
+
big_df["持股数量占发行股百分比"], errors="coerce"
|
|
763
|
+
)
|
|
764
|
+
big_df["持股市值变化-1日"] = pd.to_numeric(
|
|
765
|
+
big_df["持股市值变化-1日"], errors="coerce"
|
|
766
|
+
)
|
|
767
|
+
big_df["持股市值变化-5日"] = pd.to_numeric(
|
|
768
|
+
big_df["持股市值变化-5日"], errors="coerce"
|
|
769
|
+
)
|
|
770
|
+
big_df["持股市值变化-10日"] = pd.to_numeric(
|
|
771
|
+
big_df["持股市值变化-10日"], errors="coerce"
|
|
772
|
+
)
|
|
1039
773
|
return big_df
|
|
1040
774
|
|
|
1041
775
|
|
|
@@ -1046,7 +780,7 @@ def stock_hsgt_institution_statistics_em(
|
|
|
1046
780
|
):
|
|
1047
781
|
"""
|
|
1048
782
|
东方财富网-数据中心-沪深港通-沪深港通持股-每日机构统计
|
|
1049
|
-
|
|
783
|
+
https://data.eastmoney.com/hsgtcg/InstitutionStatistics.aspx
|
|
1050
784
|
:param market: choice of {"北向持股", "南向持股", "沪股通持股", "深股通持股"}
|
|
1051
785
|
:type market: str
|
|
1052
786
|
:param start_date: 指定数据获取开始的时间, e.g., "20200713"
|
|
@@ -1310,17 +1044,24 @@ def stock_hsgt_institution_statistics_em(
|
|
|
1310
1044
|
return big_df
|
|
1311
1045
|
|
|
1312
1046
|
|
|
1313
|
-
def stock_hsgt_hist_em(symbol: str = "
|
|
1047
|
+
def stock_hsgt_hist_em(symbol: str = "北向资金") -> pd.DataFrame:
|
|
1314
1048
|
"""
|
|
1315
1049
|
东方财富网-数据中心-资金流向-沪深港通资金流向-沪深港通历史数据
|
|
1316
|
-
|
|
1317
|
-
:param symbol: choice of {"沪股通", "深股通", "港股通沪", "港股通深"}
|
|
1050
|
+
https://data.eastmoney.com/hsgt/index.html
|
|
1051
|
+
:param symbol: choice of {"北向资金", "沪股通", "深股通", "南向资金", "港股通沪", "港股通深"}
|
|
1318
1052
|
:type symbol: str
|
|
1319
1053
|
:return: 沪深港通历史数据
|
|
1320
1054
|
:rtype: pandas.DataFrame
|
|
1321
1055
|
"""
|
|
1322
|
-
symbol_map = {
|
|
1323
|
-
|
|
1056
|
+
symbol_map = {
|
|
1057
|
+
"北向资金": "5",
|
|
1058
|
+
"沪股通": "1",
|
|
1059
|
+
"深股通": "3",
|
|
1060
|
+
"南向资金": "6",
|
|
1061
|
+
"港股通沪": "2",
|
|
1062
|
+
"港股通深": "4",
|
|
1063
|
+
}
|
|
1064
|
+
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
|
|
1324
1065
|
params = {
|
|
1325
1066
|
"sortColumns": "TRADE_DATE",
|
|
1326
1067
|
"sortTypes": "-1",
|
|
@@ -1341,11 +1082,15 @@ def stock_hsgt_hist_em(symbol: str = "沪股通") -> pd.DataFrame:
|
|
|
1341
1082
|
r = requests.get(url, params=params)
|
|
1342
1083
|
data_json = r.json()
|
|
1343
1084
|
temp_df = pd.DataFrame(data_json["result"]["data"])
|
|
1344
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
1345
|
-
if symbol == "
|
|
1085
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
1086
|
+
if symbol == "北向资金":
|
|
1087
|
+
index_name = "沪深300"
|
|
1088
|
+
elif symbol == "沪股通":
|
|
1346
1089
|
index_name = "上证指数"
|
|
1347
1090
|
elif symbol == "深股通":
|
|
1348
1091
|
index_name = "深证指数"
|
|
1092
|
+
elif symbol == "南向资金":
|
|
1093
|
+
index_name = "沪深300"
|
|
1349
1094
|
else:
|
|
1350
1095
|
index_name = "恒生指数"
|
|
1351
1096
|
|
|
@@ -1359,11 +1104,12 @@ def stock_hsgt_hist_em(symbol: str = "沪股通") -> pd.DataFrame:
|
|
|
1359
1104
|
"ACCUM_DEAL_AMT": "历史累计净买额",
|
|
1360
1105
|
"BUY_AMT": "买入成交额",
|
|
1361
1106
|
"SELL_AMT": "卖出成交额",
|
|
1362
|
-
"LEAD_STOCKS_CODE": "
|
|
1107
|
+
"LEAD_STOCKS_CODE": "领涨股-代码",
|
|
1363
1108
|
"LEAD_STOCKS_NAME": "领涨股",
|
|
1364
|
-
"LS_CHANGE_RATE": "
|
|
1109
|
+
"LS_CHANGE_RATE": "领涨股-涨跌幅",
|
|
1365
1110
|
"INDEX_CLOSE_PRICE": index_name,
|
|
1366
|
-
"INDEX_CHANGE_RATE": "
|
|
1111
|
+
"INDEX_CHANGE_RATE": f"{index_name}-涨跌幅",
|
|
1112
|
+
"HOLD_MARKET_CAP": "持股市值",
|
|
1367
1113
|
},
|
|
1368
1114
|
inplace=True,
|
|
1369
1115
|
)
|
|
@@ -1376,25 +1122,39 @@ def stock_hsgt_hist_em(symbol: str = "沪股通") -> pd.DataFrame:
|
|
|
1376
1122
|
"历史累计净买额",
|
|
1377
1123
|
"当日资金流入",
|
|
1378
1124
|
"当日余额",
|
|
1125
|
+
"持股市值",
|
|
1379
1126
|
"领涨股",
|
|
1380
|
-
"
|
|
1127
|
+
"领涨股-涨跌幅",
|
|
1381
1128
|
index_name,
|
|
1382
|
-
"
|
|
1129
|
+
f"{index_name}-涨跌幅",
|
|
1130
|
+
"领涨股-代码",
|
|
1383
1131
|
]
|
|
1384
1132
|
]
|
|
1385
|
-
big_df["日期"] = pd.to_datetime(big_df["日期"]).dt.date
|
|
1386
|
-
big_df["
|
|
1387
|
-
big_df["
|
|
1133
|
+
big_df["日期"] = pd.to_datetime(big_df["日期"], errors="coerce").dt.date
|
|
1134
|
+
big_df.sort_values(["日期"], inplace=True, ignore_index=True)
|
|
1135
|
+
big_df["当日资金流入"] = (
|
|
1136
|
+
pd.to_numeric(big_df["当日资金流入"], errors="coerce") / 100
|
|
1137
|
+
)
|
|
1138
|
+
big_df["当日余额"] = pd.to_numeric(big_df["当日余额"], errors="coerce") / 100
|
|
1388
1139
|
if symbol == "沪股通" or symbol == "深股通":
|
|
1389
|
-
big_df["历史累计净买额"] =
|
|
1140
|
+
big_df["历史累计净买额"] = (
|
|
1141
|
+
pd.to_numeric(big_df["历史累计净买额"], errors="coerce") / 100
|
|
1142
|
+
)
|
|
1390
1143
|
else:
|
|
1391
|
-
big_df["历史累计净买额"] =
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
big_df["
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
big_df["
|
|
1144
|
+
big_df["历史累计净买额"] = (
|
|
1145
|
+
pd.to_numeric(big_df["历史累计净买额"], errors="coerce") / 100 / 10000
|
|
1146
|
+
)
|
|
1147
|
+
big_df["当日成交净买额"] = (
|
|
1148
|
+
pd.to_numeric(big_df["当日成交净买额"], errors="coerce") / 100
|
|
1149
|
+
)
|
|
1150
|
+
big_df["买入成交额"] = pd.to_numeric(big_df["买入成交额"], errors="coerce") / 100
|
|
1151
|
+
big_df["卖出成交额"] = pd.to_numeric(big_df["卖出成交额"], errors="coerce") / 100
|
|
1152
|
+
big_df["领涨股-涨跌幅"] = pd.to_numeric(big_df["领涨股-涨跌幅"], errors="coerce")
|
|
1153
|
+
big_df[index_name] = pd.to_numeric(big_df[index_name], errors="coerce")
|
|
1154
|
+
big_df[f"{index_name}-涨跌幅"] = pd.to_numeric(
|
|
1155
|
+
big_df[f"{index_name}-涨跌幅"], errors="coerce"
|
|
1156
|
+
)
|
|
1157
|
+
big_df["持股市值"] = pd.to_numeric(big_df["持股市值"], errors="coerce")
|
|
1398
1158
|
return big_df
|
|
1399
1159
|
|
|
1400
1160
|
|
|
@@ -1414,9 +1174,7 @@ def stock_hsgt_board_rank_em(
|
|
|
1414
1174
|
url = "https://data.eastmoney.com/hsgtcg/hy.html"
|
|
1415
1175
|
r = requests.get(url)
|
|
1416
1176
|
soup = BeautifulSoup(r.text, "lxml")
|
|
1417
|
-
current_date = (
|
|
1418
|
-
soup.find(attrs={"id": "bkph_date"}).text.strip("(").strip(")")
|
|
1419
|
-
)
|
|
1177
|
+
current_date = soup.find(attrs={"id": "bkph_date"}).text.strip("(").strip(")")
|
|
1420
1178
|
symbol_map = {
|
|
1421
1179
|
"北向资金增持行业板块排行": "5",
|
|
1422
1180
|
"北向资金增持概念板块排行": "4",
|
|
@@ -1509,15 +1267,33 @@ def stock_hsgt_board_rank_em(
|
|
|
1509
1267
|
]
|
|
1510
1268
|
]
|
|
1511
1269
|
temp_df["最新涨跌幅"] = pd.to_numeric(temp_df["最新涨跌幅"], errors="coerce")
|
|
1512
|
-
temp_df["北向资金今日持股-股票只数"] = pd.to_numeric(
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
temp_df["
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
temp_df["
|
|
1519
|
-
|
|
1520
|
-
|
|
1270
|
+
temp_df["北向资金今日持股-股票只数"] = pd.to_numeric(
|
|
1271
|
+
temp_df["北向资金今日持股-股票只数"], errors="coerce"
|
|
1272
|
+
)
|
|
1273
|
+
temp_df["北向资金今日持股-市值"] = pd.to_numeric(
|
|
1274
|
+
temp_df["北向资金今日持股-市值"], errors="coerce"
|
|
1275
|
+
)
|
|
1276
|
+
temp_df["北向资金今日持股-占板块比"] = pd.to_numeric(
|
|
1277
|
+
temp_df["北向资金今日持股-占板块比"], errors="coerce"
|
|
1278
|
+
)
|
|
1279
|
+
temp_df["北向资金今日持股-占北向资金比"] = pd.to_numeric(
|
|
1280
|
+
temp_df["北向资金今日持股-占北向资金比"], errors="coerce"
|
|
1281
|
+
)
|
|
1282
|
+
temp_df["北向资金今日增持估计-股票只数"] = pd.to_numeric(
|
|
1283
|
+
temp_df["北向资金今日增持估计-股票只数"], errors="coerce"
|
|
1284
|
+
)
|
|
1285
|
+
temp_df["北向资金今日增持估计-市值"] = pd.to_numeric(
|
|
1286
|
+
temp_df["北向资金今日增持估计-市值"], errors="coerce"
|
|
1287
|
+
)
|
|
1288
|
+
temp_df["北向资金今日增持估计-市值增幅"] = pd.to_numeric(
|
|
1289
|
+
temp_df["北向资金今日增持估计-市值增幅"], errors="coerce"
|
|
1290
|
+
)
|
|
1291
|
+
temp_df["北向资金今日增持估计-占板块比"] = pd.to_numeric(
|
|
1292
|
+
temp_df["北向资金今日增持估计-占板块比"], errors="coerce"
|
|
1293
|
+
)
|
|
1294
|
+
temp_df["北向资金今日增持估计-占北向资金比"] = pd.to_numeric(
|
|
1295
|
+
temp_df["北向资金今日增持估计-占北向资金比"], errors="coerce"
|
|
1296
|
+
)
|
|
1521
1297
|
temp_df["报告时间"] = pd.to_datetime(temp_df["报告时间"], errors="coerce").dt.date
|
|
1522
1298
|
return temp_df
|
|
1523
1299
|
|
|
@@ -1626,7 +1402,7 @@ def stock_hsgt_individual_detail_em(
|
|
|
1626
1402
|
data_json = r.json()
|
|
1627
1403
|
try:
|
|
1628
1404
|
data_json["result"]["pages"]
|
|
1629
|
-
except TypeError
|
|
1405
|
+
except TypeError:
|
|
1630
1406
|
params.update(
|
|
1631
1407
|
{
|
|
1632
1408
|
"filter": f"""(SECURITY_CODE="{symbol}")(MARKET_CODE="001")(HOLD_DATE>='{'-'.join([start_date[:4], start_date[4:6], start_date[6:]])}')(HOLD_DATE<='{'-'.join([end_date[:4], end_date[4:6], end_date[6:]])}')""",
|
|
@@ -1697,42 +1473,6 @@ if __name__ == "__main__":
|
|
|
1697
1473
|
stock_hk_ggt_components_em_df = stock_hk_ggt_components_em()
|
|
1698
1474
|
print(stock_hk_ggt_components_em_df)
|
|
1699
1475
|
|
|
1700
|
-
stock_hsgt_north_net_flow_in_em_df = stock_hsgt_north_net_flow_in_em(
|
|
1701
|
-
symbol="沪股通"
|
|
1702
|
-
)
|
|
1703
|
-
print(stock_hsgt_north_net_flow_in_em_df)
|
|
1704
|
-
|
|
1705
|
-
stock_hsgt_north_net_flow_in_em_df = stock_hsgt_north_net_flow_in_em(
|
|
1706
|
-
symbol="深股通"
|
|
1707
|
-
)
|
|
1708
|
-
print(stock_hsgt_north_net_flow_in_em_df)
|
|
1709
|
-
|
|
1710
|
-
stock_hsgt_north_net_flow_in_em_df = stock_hsgt_north_net_flow_in_em(
|
|
1711
|
-
symbol="北上"
|
|
1712
|
-
)
|
|
1713
|
-
print(stock_hsgt_north_net_flow_in_em_df)
|
|
1714
|
-
|
|
1715
|
-
stock_hsgt_north_cash_em_df = stock_hsgt_north_cash_em(symbol="沪股通")
|
|
1716
|
-
print(stock_hsgt_north_cash_em_df)
|
|
1717
|
-
|
|
1718
|
-
stock_hsgt_north_acc_flow_in_em_df = stock_hsgt_north_acc_flow_in_em(
|
|
1719
|
-
symbol="北上"
|
|
1720
|
-
)
|
|
1721
|
-
print(stock_hsgt_north_acc_flow_in_em_df)
|
|
1722
|
-
|
|
1723
|
-
stock_hsgt_south_net_flow_in_em_df = stock_hsgt_south_net_flow_in_em(
|
|
1724
|
-
symbol="沪股通"
|
|
1725
|
-
)
|
|
1726
|
-
print(stock_hsgt_south_net_flow_in_em_df)
|
|
1727
|
-
|
|
1728
|
-
stock_hsgt_south_cash_em_df = stock_hsgt_south_cash_em(symbol="沪股通")
|
|
1729
|
-
print(stock_hsgt_south_cash_em_df)
|
|
1730
|
-
|
|
1731
|
-
stock_hsgt_south_acc_flow_in_em_df = stock_hsgt_south_acc_flow_in_em(
|
|
1732
|
-
symbol="沪股通"
|
|
1733
|
-
)
|
|
1734
|
-
print(stock_hsgt_south_acc_flow_in_em_df)
|
|
1735
|
-
|
|
1736
1476
|
stock_hsgt_hold_stock_em_df = stock_hsgt_hold_stock_em(
|
|
1737
1477
|
market="北向", indicator="今日排行"
|
|
1738
1478
|
)
|
|
@@ -1773,35 +1513,27 @@ if __name__ == "__main__":
|
|
|
1773
1513
|
)
|
|
1774
1514
|
print(stock_hsgt_stock_statistics_em_df)
|
|
1775
1515
|
|
|
1776
|
-
stock_hsgt_institution_statistics_em_df = (
|
|
1777
|
-
|
|
1778
|
-
market="北向持股", start_date="20240110", end_date="20240110"
|
|
1779
|
-
)
|
|
1516
|
+
stock_hsgt_institution_statistics_em_df = stock_hsgt_institution_statistics_em(
|
|
1517
|
+
market="北向持股", start_date="20240110", end_date="20240110"
|
|
1780
1518
|
)
|
|
1781
1519
|
print(stock_hsgt_institution_statistics_em_df)
|
|
1782
1520
|
|
|
1783
|
-
stock_hsgt_institution_statistics_em_df = (
|
|
1784
|
-
|
|
1785
|
-
market="南向持股", start_date="20240110", end_date="20240110"
|
|
1786
|
-
)
|
|
1521
|
+
stock_hsgt_institution_statistics_em_df = stock_hsgt_institution_statistics_em(
|
|
1522
|
+
market="南向持股", start_date="20240110", end_date="20240110"
|
|
1787
1523
|
)
|
|
1788
1524
|
print(stock_hsgt_institution_statistics_em_df)
|
|
1789
1525
|
|
|
1790
|
-
stock_hsgt_institution_statistics_em_df = (
|
|
1791
|
-
|
|
1792
|
-
market="沪股通持股", start_date="20240110", end_date="20240110"
|
|
1793
|
-
)
|
|
1526
|
+
stock_hsgt_institution_statistics_em_df = stock_hsgt_institution_statistics_em(
|
|
1527
|
+
market="沪股通持股", start_date="20240110", end_date="20240110"
|
|
1794
1528
|
)
|
|
1795
1529
|
print(stock_hsgt_institution_statistics_em_df)
|
|
1796
1530
|
|
|
1797
|
-
stock_hsgt_institution_statistics_em_df = (
|
|
1798
|
-
|
|
1799
|
-
market="深股通持股", start_date="20240110", end_date="20240110"
|
|
1800
|
-
)
|
|
1531
|
+
stock_hsgt_institution_statistics_em_df = stock_hsgt_institution_statistics_em(
|
|
1532
|
+
market="深股通持股", start_date="20240110", end_date="20240110"
|
|
1801
1533
|
)
|
|
1802
1534
|
print(stock_hsgt_institution_statistics_em_df)
|
|
1803
1535
|
|
|
1804
|
-
stock_hsgt_hist_em_df = stock_hsgt_hist_em(symbol="
|
|
1536
|
+
stock_hsgt_hist_em_df = stock_hsgt_hist_em(symbol="北向资金")
|
|
1805
1537
|
print(stock_hsgt_hist_em_df)
|
|
1806
1538
|
|
|
1807
1539
|
stock_hsgt_board_rank_em_df = stock_hsgt_board_rank_em(
|