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
akshare/fund/fund_etf_em.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/3/
|
|
4
|
+
Date: 2024/3/26 17:30
|
|
5
5
|
Desc: 东方财富-ETF行情
|
|
6
6
|
https://quote.eastmoney.com/sh513500.html
|
|
7
7
|
"""
|
|
@@ -35,7 +35,7 @@ def _fund_etf_code_id_map_em() -> dict:
|
|
|
35
35
|
"fields": "f12,f13",
|
|
36
36
|
"_": "1672806290972",
|
|
37
37
|
}
|
|
38
|
-
r = requests.get(url, params=params)
|
|
38
|
+
r = requests.get(url, timeout=15, params=params)
|
|
39
39
|
data_json = r.json()
|
|
40
40
|
temp_df = pd.DataFrame(data_json["data"]["diff"])
|
|
41
41
|
temp_dict = dict(zip(temp_df["f12"], temp_df["f13"]))
|
|
@@ -60,7 +60,7 @@ def fund_etf_spot_em() -> pd.DataFrame:
|
|
|
60
60
|
"invt": "2",
|
|
61
61
|
"wbp2u": "|0|0|0|web",
|
|
62
62
|
"fid": "f3",
|
|
63
|
-
"fs": "b:MK0021,b:MK0022,b:MK0023,b:MK0024",
|
|
63
|
+
"fs": "b:MK0021,b:MK0022,b:MK0023,b:MK0024,b:MK0827",
|
|
64
64
|
"fields": (
|
|
65
65
|
"f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,"
|
|
66
66
|
"f12,f13,f14,f15,f16,f17,f18,f20,f21,"
|
|
@@ -71,7 +71,7 @@ def fund_etf_spot_em() -> pd.DataFrame:
|
|
|
71
71
|
),
|
|
72
72
|
"_": "1672806290972",
|
|
73
73
|
}
|
|
74
|
-
r = requests.get(url, params=params)
|
|
74
|
+
r = requests.get(url, timeout=15, params=params)
|
|
75
75
|
data_json = r.json()
|
|
76
76
|
temp_df = pd.DataFrame(data_json["data"]["diff"])
|
|
77
77
|
temp_df.rename(
|
|
@@ -110,7 +110,7 @@ def fund_etf_spot_em() -> pd.DataFrame:
|
|
|
110
110
|
"f21": "流通市值",
|
|
111
111
|
"f20": "总市值",
|
|
112
112
|
"f402": "基金折价率",
|
|
113
|
-
"f441": "实时估值",
|
|
113
|
+
"f441": "IOPV实时估值",
|
|
114
114
|
"f297": "数据日期",
|
|
115
115
|
"f124": "更新时间",
|
|
116
116
|
},
|
|
@@ -121,7 +121,7 @@ def fund_etf_spot_em() -> pd.DataFrame:
|
|
|
121
121
|
"代码",
|
|
122
122
|
"名称",
|
|
123
123
|
"最新价",
|
|
124
|
-
"实时估值",
|
|
124
|
+
"IOPV实时估值",
|
|
125
125
|
"基金折价率",
|
|
126
126
|
"涨跌额",
|
|
127
127
|
"涨跌幅",
|
|
@@ -158,7 +158,6 @@ def fund_etf_spot_em() -> pd.DataFrame:
|
|
|
158
158
|
]
|
|
159
159
|
]
|
|
160
160
|
temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
|
|
161
|
-
temp_df["实时估值"] = pd.to_numeric(temp_df["实时估值"], errors="coerce")
|
|
162
161
|
temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"], errors="coerce")
|
|
163
162
|
temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"], errors="coerce")
|
|
164
163
|
temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
|
|
@@ -179,6 +178,7 @@ def fund_etf_spot_em() -> pd.DataFrame:
|
|
|
179
178
|
temp_df["买一"] = pd.to_numeric(temp_df["买一"], errors="coerce")
|
|
180
179
|
temp_df["卖一"] = pd.to_numeric(temp_df["卖一"], errors="coerce")
|
|
181
180
|
temp_df["最新份额"] = pd.to_numeric(temp_df["最新份额"], errors="coerce")
|
|
181
|
+
temp_df["IOPV实时估值"] = pd.to_numeric(temp_df["IOPV实时估值"], errors="coerce")
|
|
182
182
|
temp_df["基金折价率"] = pd.to_numeric(temp_df["基金折价率"], errors="coerce")
|
|
183
183
|
temp_df["主力净流入-净额"] = pd.to_numeric(
|
|
184
184
|
temp_df["主力净流入-净额"], errors="coerce"
|
|
@@ -262,17 +262,17 @@ def fund_etf_hist_em(
|
|
|
262
262
|
try:
|
|
263
263
|
market_id = code_id_dict[symbol]
|
|
264
264
|
params.update({"secid": f"{market_id}.{symbol}"})
|
|
265
|
-
r = requests.get(url, params=params)
|
|
265
|
+
r = requests.get(url, timeout=15, params=params)
|
|
266
266
|
data_json = r.json()
|
|
267
267
|
except KeyError:
|
|
268
268
|
market_id = 1
|
|
269
269
|
params.update({"secid": f"{market_id}.{symbol}"})
|
|
270
|
-
r = requests.get(url, params=params)
|
|
270
|
+
r = requests.get(url, timeout=15, params=params)
|
|
271
271
|
data_json = r.json()
|
|
272
272
|
if not data_json["data"]:
|
|
273
273
|
market_id = 0
|
|
274
274
|
params.update({"secid": f"{market_id}.{symbol}"})
|
|
275
|
-
r = requests.get(url, params=params)
|
|
275
|
+
r = requests.get(url, timeout=15, params=params)
|
|
276
276
|
data_json = r.json()
|
|
277
277
|
if not (data_json["data"] and data_json["data"]["klines"]):
|
|
278
278
|
return pd.DataFrame()
|
|
@@ -337,6 +337,7 @@ def fund_etf_hist_min_em(
|
|
|
337
337
|
"159985": "0",
|
|
338
338
|
"511090": "1",
|
|
339
339
|
"511220": "1",
|
|
340
|
+
"511380": "1",
|
|
340
341
|
}
|
|
341
342
|
)
|
|
342
343
|
adjust_map = {
|
|
@@ -355,7 +356,7 @@ def fund_etf_hist_min_em(
|
|
|
355
356
|
"secid": f"{code_id_dict[symbol]}.{symbol}",
|
|
356
357
|
"_": "1623766962675",
|
|
357
358
|
}
|
|
358
|
-
r = requests.get(url, params=params)
|
|
359
|
+
r = requests.get(url, timeout=15, params=params)
|
|
359
360
|
data_json = r.json()
|
|
360
361
|
temp_df = pd.DataFrame(
|
|
361
362
|
[item.split(",") for item in data_json["data"]["trends"]]
|
|
@@ -395,7 +396,7 @@ def fund_etf_hist_min_em(
|
|
|
395
396
|
"end": "20500000",
|
|
396
397
|
"_": "1630930917857",
|
|
397
398
|
}
|
|
398
|
-
r = requests.get(url, params=params)
|
|
399
|
+
r = requests.get(url, timeout=15, params=params)
|
|
399
400
|
data_json = r.json()
|
|
400
401
|
temp_df = pd.DataFrame(
|
|
401
402
|
[item.split(",") for item in data_json["data"]["klines"]]
|
|
@@ -477,10 +478,10 @@ if __name__ == "__main__":
|
|
|
477
478
|
print(fund_etf_hist_em_df)
|
|
478
479
|
|
|
479
480
|
fund_etf_hist_min_em_df = fund_etf_hist_min_em(
|
|
480
|
-
symbol="
|
|
481
|
+
symbol="511380",
|
|
481
482
|
period="1",
|
|
482
483
|
adjust="",
|
|
483
|
-
start_date="2024-
|
|
484
|
-
end_date="2024-
|
|
484
|
+
start_date="2024-09-04 09:30:00",
|
|
485
|
+
end_date="2024-09-04 17:40:00",
|
|
485
486
|
)
|
|
486
487
|
print(fund_etf_hist_min_em_df)
|
akshare/fund/fund_etf_sina.py
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2025/1/5 19:00
|
|
5
5
|
Desc: 新浪财经-基金行情
|
|
6
|
-
|
|
6
|
+
https://vip.stock.finance.sina.com.cn/fund_center/index.html#jjhqetf
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import pandas as pd
|
|
10
|
+
import py_mini_racer
|
|
9
11
|
import requests
|
|
10
|
-
from py_mini_racer import py_mini_racer
|
|
11
12
|
|
|
12
13
|
from akshare.stock.cons import hk_js_decode
|
|
13
14
|
from akshare.utils import demjson
|
|
@@ -27,10 +28,13 @@ def fund_etf_category_sina(symbol: str = "LOF基金") -> pd.DataFrame:
|
|
|
27
28
|
"ETF基金": "etf_hq_fund",
|
|
28
29
|
"LOF基金": "lof_hq_fund",
|
|
29
30
|
}
|
|
30
|
-
url =
|
|
31
|
+
url = (
|
|
32
|
+
"https://vip.stock.finance.sina.com.cn/quotes_service/api/jsonp.php/"
|
|
33
|
+
"IO.XSRV2.CallbackList['da_yPT46_Ll7K6WD']/Market_Center.getHQNodeDataSimple"
|
|
34
|
+
)
|
|
31
35
|
params = {
|
|
32
36
|
"page": "1",
|
|
33
|
-
"num": "
|
|
37
|
+
"num": "5000",
|
|
34
38
|
"sort": "symbol",
|
|
35
39
|
"asc": "0",
|
|
36
40
|
"node": fund_map[symbol],
|
|
@@ -95,21 +99,21 @@ def fund_etf_category_sina(symbol: str = "LOF基金") -> pd.DataFrame:
|
|
|
95
99
|
"成交额",
|
|
96
100
|
]
|
|
97
101
|
]
|
|
98
|
-
temp_df["最新价"] = pd.to_numeric(temp_df["最新价"])
|
|
99
|
-
temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"])
|
|
100
|
-
temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"])
|
|
101
|
-
temp_df["买入"] = pd.to_numeric(temp_df["买入"])
|
|
102
|
-
temp_df["卖出"] = pd.to_numeric(temp_df["卖出"])
|
|
103
|
-
temp_df["昨收"] = pd.to_numeric(temp_df["昨收"])
|
|
104
|
-
temp_df["今开"] = pd.to_numeric(temp_df["今开"])
|
|
105
|
-
temp_df["最高"] = pd.to_numeric(temp_df["最高"])
|
|
106
|
-
temp_df["最低"] = pd.to_numeric(temp_df["最低"])
|
|
107
|
-
temp_df["成交量"] = pd.to_numeric(temp_df["成交量"])
|
|
108
|
-
temp_df["成交额"] = pd.to_numeric(temp_df["成交额"])
|
|
102
|
+
temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
|
|
103
|
+
temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"], errors="coerce")
|
|
104
|
+
temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"], errors="coerce")
|
|
105
|
+
temp_df["买入"] = pd.to_numeric(temp_df["买入"], errors="coerce")
|
|
106
|
+
temp_df["卖出"] = pd.to_numeric(temp_df["卖出"], errors="coerce")
|
|
107
|
+
temp_df["昨收"] = pd.to_numeric(temp_df["昨收"], errors="coerce")
|
|
108
|
+
temp_df["今开"] = pd.to_numeric(temp_df["今开"], errors="coerce")
|
|
109
|
+
temp_df["最高"] = pd.to_numeric(temp_df["最高"], errors="coerce")
|
|
110
|
+
temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce")
|
|
111
|
+
temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
|
|
112
|
+
temp_df["成交额"] = pd.to_numeric(temp_df["成交额"], errors="coerce")
|
|
109
113
|
return temp_df
|
|
110
114
|
|
|
111
115
|
|
|
112
|
-
def fund_etf_hist_sina(symbol: str = "
|
|
116
|
+
def fund_etf_hist_sina(symbol: str = "sh510050") -> pd.DataFrame:
|
|
113
117
|
"""
|
|
114
118
|
新浪财经-基金-ETF 基金-日行情数据
|
|
115
119
|
https://finance.sina.com.cn/fund/quotes/159996/bc.shtml
|
|
@@ -128,15 +132,56 @@ def fund_etf_hist_sina(symbol: str = "sz159996") -> pd.DataFrame:
|
|
|
128
132
|
temp_df = pd.DataFrame(dict_list)
|
|
129
133
|
if temp_df.empty: # 处理获取数据为空的问题
|
|
130
134
|
return pd.DataFrame()
|
|
131
|
-
temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
temp_df["
|
|
135
|
-
temp_df["
|
|
136
|
-
temp_df["
|
|
135
|
+
temp_df["date"] = pd.to_datetime(temp_df["date"], errors="coerce").dt.tz_localize(
|
|
136
|
+
None
|
|
137
|
+
)
|
|
138
|
+
temp_df["open"] = pd.to_numeric(temp_df["open"], errors="coerce")
|
|
139
|
+
temp_df["high"] = pd.to_numeric(temp_df["high"], errors="coerce")
|
|
140
|
+
temp_df["low"] = pd.to_numeric(temp_df["low"], errors="coerce")
|
|
141
|
+
temp_df["close"] = pd.to_numeric(temp_df["close"], errors="coerce")
|
|
142
|
+
temp_df["volume"] = pd.to_numeric(temp_df["volume"], errors="coerce")
|
|
143
|
+
|
|
144
|
+
# 转换日期列为日期类型
|
|
145
|
+
temp_df["date"] = temp_df["date"].dt.date
|
|
146
|
+
temp_df = temp_df.sort_values(by="date", ascending=True)
|
|
137
147
|
return temp_df
|
|
138
148
|
|
|
139
149
|
|
|
150
|
+
def fund_etf_dividend_sina(symbol: str = "sh510050") -> pd.DataFrame:
|
|
151
|
+
"""
|
|
152
|
+
新浪财经-基金-ETF 基金-累计分红
|
|
153
|
+
https://finance.sina.com.cn/fund/quotes/510050/bc.shtml
|
|
154
|
+
:param symbol: 基金名称, 可以通过 ak.fund_etf_category_sina() 函数获取
|
|
155
|
+
:type symbol: str
|
|
156
|
+
:return: 累计分红
|
|
157
|
+
:rtype: pandas.DataFrame
|
|
158
|
+
"""
|
|
159
|
+
# 构建复权数据URL
|
|
160
|
+
factor_url = f"https://finance.sina.com.cn/realstock/company/{symbol}/hfq.js"
|
|
161
|
+
r = requests.get(factor_url)
|
|
162
|
+
text = r.text
|
|
163
|
+
if text.startswith("var"):
|
|
164
|
+
json_str = text.split("=")[1].strip().rsplit("}", maxsplit=1)[0].strip()
|
|
165
|
+
data = eval(json_str + "}") # 这里使用eval而不是json.loads因为数据格式特殊
|
|
166
|
+
|
|
167
|
+
if isinstance(data, dict) and "data" in data:
|
|
168
|
+
df = pd.DataFrame(data["data"])
|
|
169
|
+
# 重命名列
|
|
170
|
+
df.columns = ["date", "f", "s", "u"] if len(df.columns) == 4 else df.columns
|
|
171
|
+
# 移除1900-01-01的数据
|
|
172
|
+
df = df[df["date"] != "1900-01-01"]
|
|
173
|
+
# 转换日期
|
|
174
|
+
df["date"] = pd.to_datetime(df["date"])
|
|
175
|
+
# 转换数值类型
|
|
176
|
+
df[["f", "s", "u"]] = df[["f", "s", "u"]].astype(float)
|
|
177
|
+
# 按日期排序
|
|
178
|
+
df = df.sort_values("date", ascending=True, ignore_index=True)
|
|
179
|
+
temp_df = df[["date", "u"]].copy()
|
|
180
|
+
temp_df.columns = ["日期", "累计分红"]
|
|
181
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
182
|
+
return temp_df
|
|
183
|
+
|
|
184
|
+
|
|
140
185
|
if __name__ == "__main__":
|
|
141
186
|
fund_etf_category_sina_df = fund_etf_category_sina(symbol="封闭式基金")
|
|
142
187
|
print(fund_etf_category_sina_df)
|
|
@@ -152,3 +197,6 @@ if __name__ == "__main__":
|
|
|
152
197
|
|
|
153
198
|
fund_etf_hist_sina_df = fund_etf_hist_sina(symbol="sh510300")
|
|
154
199
|
print(fund_etf_hist_sina_df)
|
|
200
|
+
|
|
201
|
+
fund_etf_dividend_sina_df = fund_etf_dividend_sina(symbol="sh510050")
|
|
202
|
+
print(fund_etf_dividend_sina_df)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding:utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
Date: 2024/6/21 17:00
|
|
5
|
+
Desc: 同花顺理财-基金数据-每日净值-ETF
|
|
6
|
+
https://fund.10jqka.com.cn/datacenter/jz/kfs/etf/
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
|
|
11
|
+
import pandas as pd
|
|
12
|
+
import requests
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def fund_etf_spot_ths(date: str = "") -> pd.DataFrame:
|
|
16
|
+
"""
|
|
17
|
+
同花顺理财-基金数据-每日净值-ETF-实时行情
|
|
18
|
+
https://fund.10jqka.com.cn/datacenter/jz/kfs/etf/
|
|
19
|
+
:return: ETF 实时行情
|
|
20
|
+
:rtype: pandas.DataFrame
|
|
21
|
+
"""
|
|
22
|
+
inner_date = "-".join([date[:4], date[4:6], date[6:]]) if date != "" else 0
|
|
23
|
+
url = f"https://fund.10jqka.com.cn/data/Net/info/ETF_rate_desc_{inner_date}_0_1_9999_0_0_0_jsonp_g.html"
|
|
24
|
+
r = requests.get(url, timeout=15)
|
|
25
|
+
data_text = r.text[2:-1]
|
|
26
|
+
data_json = json.loads(data_text)
|
|
27
|
+
temp_df = pd.DataFrame(data_json["data"]["data"]).T
|
|
28
|
+
temp_df.reset_index(inplace=True, drop=True)
|
|
29
|
+
temp_df.reset_index(inplace=True)
|
|
30
|
+
temp_df["index"] = temp_df["index"] + 1
|
|
31
|
+
temp_df.rename(
|
|
32
|
+
columns={
|
|
33
|
+
"index": "序号",
|
|
34
|
+
"code": "基金代码",
|
|
35
|
+
"typename": "基金类型",
|
|
36
|
+
"net": "当前-单位净值",
|
|
37
|
+
"name": "基金名称",
|
|
38
|
+
"totalnet": "当前-累计净值",
|
|
39
|
+
"newnet": "最新-单位净值",
|
|
40
|
+
"newtotalnet": "最新-累计净值",
|
|
41
|
+
"newdate": "最新-交易日",
|
|
42
|
+
"net1": "前一日-单位净值",
|
|
43
|
+
"totalnet1": "前一日-累计净值",
|
|
44
|
+
"ranges": "增长值",
|
|
45
|
+
"rate": "增长率",
|
|
46
|
+
"shstat": "赎回状态",
|
|
47
|
+
"sgstat": "申购状态",
|
|
48
|
+
},
|
|
49
|
+
inplace=True,
|
|
50
|
+
)
|
|
51
|
+
temp_df = temp_df[
|
|
52
|
+
[
|
|
53
|
+
"序号",
|
|
54
|
+
"基金代码",
|
|
55
|
+
"基金名称",
|
|
56
|
+
"当前-单位净值",
|
|
57
|
+
"当前-累计净值",
|
|
58
|
+
"前一日-单位净值",
|
|
59
|
+
"前一日-累计净值",
|
|
60
|
+
"增长值",
|
|
61
|
+
"增长率",
|
|
62
|
+
"赎回状态",
|
|
63
|
+
"申购状态",
|
|
64
|
+
"最新-交易日",
|
|
65
|
+
"最新-单位净值",
|
|
66
|
+
"最新-累计净值",
|
|
67
|
+
"基金类型",
|
|
68
|
+
]
|
|
69
|
+
]
|
|
70
|
+
query_date = inner_date if inner_date != 0 else temp_df["最新-交易日"][0]
|
|
71
|
+
temp_df["查询日期"] = query_date
|
|
72
|
+
temp_df["查询日期"] = pd.to_datetime(temp_df["查询日期"], errors="coerce").dt.date
|
|
73
|
+
temp_df["当前-单位净值"] = pd.to_numeric(temp_df["当前-单位净值"], errors="coerce")
|
|
74
|
+
temp_df["当前-累计净值"] = pd.to_numeric(temp_df["当前-累计净值"], errors="coerce")
|
|
75
|
+
temp_df["前一日-单位净值"] = pd.to_numeric(
|
|
76
|
+
temp_df["前一日-单位净值"], errors="coerce"
|
|
77
|
+
)
|
|
78
|
+
temp_df["前一日-累计净值"] = pd.to_numeric(
|
|
79
|
+
temp_df["前一日-累计净值"], errors="coerce"
|
|
80
|
+
)
|
|
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_datetime(
|
|
86
|
+
temp_df["最新-交易日"], errors="coerce"
|
|
87
|
+
).dt.date
|
|
88
|
+
return temp_df
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if __name__ == "__main__":
|
|
92
|
+
fund_etf_spot_ths_df = fund_etf_spot_ths(date="20240620")
|
|
93
|
+
print(fund_etf_spot_ths_df)
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding:utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
Date: 2025/1/4 17:00
|
|
5
|
+
Desc: 天天基金-基金档案
|
|
6
|
+
https://fundf10.eastmoney.com/jjfl_015641.html
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import requests
|
|
10
|
+
import pandas as pd
|
|
11
|
+
from io import StringIO
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def fund_fee_em(symbol: str = "015641", indicator: str = "认购费率") -> pd.DataFrame:
|
|
15
|
+
"""
|
|
16
|
+
天天基金-基金档案-购买信息
|
|
17
|
+
https://fundf10.eastmoney.com/jjfl_015641.html
|
|
18
|
+
:param symbol: 基金代码
|
|
19
|
+
:type symbol: str
|
|
20
|
+
:param indicator: choice of {"交易状态", "申购与赎回金额", "交易确认日", "运作费用", "认购费率", "申购费率", "赎回费率"}
|
|
21
|
+
:type indicator: str
|
|
22
|
+
:return: 交易规则
|
|
23
|
+
:rtype: pandas.DataFrame
|
|
24
|
+
"""
|
|
25
|
+
url = f"https://fundf10.eastmoney.com/jjfl_{symbol}.html"
|
|
26
|
+
r = requests.get(url)
|
|
27
|
+
|
|
28
|
+
if indicator == "交易状态":
|
|
29
|
+
temp_df = pd.read_html(StringIO(r.text))[1]
|
|
30
|
+
elif indicator == "申购与赎回金额":
|
|
31
|
+
temp_df_1 = pd.read_html(StringIO(r.text))[2]
|
|
32
|
+
temp_df_2 = pd.read_html(StringIO(r.text))[3]
|
|
33
|
+
temp_df = pd.concat(objs=[temp_df_1, temp_df_2], ignore_index=True)
|
|
34
|
+
elif indicator == "交易确认日":
|
|
35
|
+
temp_df = pd.read_html(StringIO(r.text))[4]
|
|
36
|
+
elif indicator == "运作费用":
|
|
37
|
+
temp_df = pd.read_html(StringIO(r.text))[5]
|
|
38
|
+
elif indicator == "认购费率":
|
|
39
|
+
temp_df = pd.read_html(StringIO(r.text))[6]
|
|
40
|
+
temp_df["原费率"] = temp_df["原费率|天天基金优惠费率"].str.split(
|
|
41
|
+
"|", expand=True
|
|
42
|
+
)[0]
|
|
43
|
+
temp_df["天天基金优惠费率"] = temp_df["原费率|天天基金优惠费率"].str.split(
|
|
44
|
+
"|", expand=True
|
|
45
|
+
)[1]
|
|
46
|
+
del temp_df["原费率|天天基金优惠费率"]
|
|
47
|
+
temp_df.loc[3, "天天基金优惠费率"] = temp_df.loc[3, "原费率"]
|
|
48
|
+
temp_df["原费率"] = temp_df["原费率"].str.strip()
|
|
49
|
+
temp_df["天天基金优惠费率"] = temp_df["天天基金优惠费率"].str.strip()
|
|
50
|
+
elif indicator == "申购费率":
|
|
51
|
+
temp_df = pd.read_html(StringIO(r.text))[7]
|
|
52
|
+
temp_df["原费率"] = temp_df[
|
|
53
|
+
"原费率|天天基金优惠费率 银行卡购买|活期宝购买"
|
|
54
|
+
].str.split("|", expand=True)[0]
|
|
55
|
+
temp_df["天天基金优惠费率-银行卡购买"] = temp_df[
|
|
56
|
+
"原费率|天天基金优惠费率 银行卡购买|活期宝购买"
|
|
57
|
+
].str.split("|", expand=True)[1]
|
|
58
|
+
temp_df["天天基金优惠费率-活期宝购买"] = temp_df[
|
|
59
|
+
"原费率|天天基金优惠费率 银行卡购买|活期宝购买"
|
|
60
|
+
].str.split("|", expand=True)[2]
|
|
61
|
+
del temp_df["原费率|天天基金优惠费率 银行卡购买|活期宝购买"]
|
|
62
|
+
temp_df.loc[3, "天天基金优惠费率-银行卡购买"] = temp_df.loc[3, "原费率"]
|
|
63
|
+
temp_df.loc[3, "天天基金优惠费率-活期宝购买"] = temp_df.loc[3, "原费率"]
|
|
64
|
+
temp_df["原费率"] = temp_df["原费率"].str.strip()
|
|
65
|
+
temp_df["天天基金优惠费率-银行卡购买"] = temp_df[
|
|
66
|
+
"天天基金优惠费率-银行卡购买"
|
|
67
|
+
].str.strip()
|
|
68
|
+
temp_df["天天基金优惠费率-活期宝购买"] = temp_df[
|
|
69
|
+
"天天基金优惠费率-活期宝购买"
|
|
70
|
+
].str.strip()
|
|
71
|
+
elif indicator == "赎回费率":
|
|
72
|
+
temp_df = pd.read_html(StringIO(r.text))[8]
|
|
73
|
+
else:
|
|
74
|
+
temp_df = pd.DataFrame([])
|
|
75
|
+
return temp_df
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
if __name__ == "__main__":
|
|
79
|
+
fund_fee_em_df = fund_fee_em(symbol="015641", indicator="交易状态")
|
|
80
|
+
print(fund_fee_em_df)
|
|
81
|
+
|
|
82
|
+
fund_fee_em_df = fund_fee_em(symbol="015641", indicator="申购与赎回金额")
|
|
83
|
+
print(fund_fee_em_df)
|
|
84
|
+
|
|
85
|
+
fund_fee_em_df = fund_fee_em(symbol="015641", indicator="交易确认日")
|
|
86
|
+
print(fund_fee_em_df)
|
|
87
|
+
|
|
88
|
+
fund_fee_em_df = fund_fee_em(symbol="015641", indicator="运作费用")
|
|
89
|
+
print(fund_fee_em_df)
|
|
90
|
+
|
|
91
|
+
fund_fee_em_df = fund_fee_em(symbol="015641", indicator="认购费率")
|
|
92
|
+
print(fund_fee_em_df)
|
|
93
|
+
|
|
94
|
+
fund_fee_em_df = fund_fee_em(symbol="015641", indicator="申购费率")
|
|
95
|
+
print(fund_fee_em_df)
|
|
96
|
+
|
|
97
|
+
fund_fee_em_df = fund_fee_em(symbol="015641", indicator="赎回费率")
|
|
98
|
+
print(fund_fee_em_df)
|