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/fund/fund_em.py
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/12/14 15:00
|
|
5
5
|
Desc: 东方财富网站-天天基金网-基金数据-开放式基金净值
|
|
6
6
|
https://fund.eastmoney.com/manager/default.html#dt14;mcreturnjson;ftall;pn20;pi1;scabbname;stasc
|
|
7
|
-
1.基金经理基本数据, 建议包含:基金经理代码,基金经理姓名,从业起始日期,现任基金公司,管理资产总规模,上述数据可在"基金经理列表:
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
1.基金经理基本数据, 建议包含:基金经理代码,基金经理姓名,从业起始日期,现任基金公司,管理资产总规模,上述数据可在"基金经理列表:
|
|
8
|
+
https://fund.eastmoney.com/manager/default.html#dt14;mcreturnjson;ftall;pn20;pi1;scabbname;stasc 和
|
|
9
|
+
"基金经理理档案如:https://fund.eastmoney.com/manager/30040164.html 获取.
|
|
10
|
+
2.基金经理任职数据:可调取全部或特定经理,管理的基金数据,建议包含:基金经理代码,基金经理姓名,基金代码,基金简称,
|
|
11
|
+
经理位次(在当前基金的经理中排第几位),起始任职时间,截止任职时间,任职回报.在特定基金的经理信息中可以获取如:
|
|
12
|
+
https://fundf10.eastmoney.com/jjjl_001810.html
|
|
13
|
+
3.在接口:fund_basic"公募基金列表"增加数据"基金经理代码"(或第一基金经理代码),
|
|
14
|
+
"基金经理姓名"(或第一基金经理姓名),"当前基金经理人数","当前经理任职起始时间".
|
|
10
15
|
用户ID:269993
|
|
11
16
|
"""
|
|
17
|
+
|
|
12
18
|
import json
|
|
19
|
+
import math
|
|
13
20
|
import time
|
|
14
21
|
from io import StringIO
|
|
15
22
|
|
|
16
23
|
import pandas as pd
|
|
24
|
+
import py_mini_racer
|
|
17
25
|
import requests
|
|
18
26
|
|
|
19
27
|
from akshare.utils import demjson
|
|
28
|
+
from akshare.utils.cons import headers
|
|
29
|
+
from akshare.utils.tqdm import get_tqdm
|
|
20
30
|
|
|
21
31
|
|
|
22
32
|
def fund_purchase_em() -> pd.DataFrame:
|
|
@@ -26,10 +36,7 @@ def fund_purchase_em() -> pd.DataFrame:
|
|
|
26
36
|
:return: 基金申购状态
|
|
27
37
|
:rtype: pandas.DataFrame
|
|
28
38
|
"""
|
|
29
|
-
url = "
|
|
30
|
-
headers = {
|
|
31
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
|
|
32
|
-
}
|
|
39
|
+
url = "https://fund.eastmoney.com/Data/Fund_JJJZ_Data.aspx"
|
|
33
40
|
params = {
|
|
34
41
|
"t": "8",
|
|
35
42
|
"page": "1,50000",
|
|
@@ -75,12 +82,18 @@ def fund_purchase_em() -> pd.DataFrame:
|
|
|
75
82
|
"手续费",
|
|
76
83
|
]
|
|
77
84
|
]
|
|
78
|
-
temp_df["下一开放日"] = pd.to_datetime(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
temp_df["
|
|
85
|
+
temp_df["下一开放日"] = pd.to_datetime(
|
|
86
|
+
temp_df["下一开放日"], errors="coerce"
|
|
87
|
+
).dt.date
|
|
88
|
+
temp_df["最新净值/万份收益"] = pd.to_numeric(
|
|
89
|
+
temp_df["最新净值/万份收益"], errors="coerce"
|
|
90
|
+
)
|
|
91
|
+
temp_df["购买起点"] = pd.to_numeric(temp_df["购买起点"], errors="coerce")
|
|
92
|
+
temp_df["日累计限定金额"] = pd.to_numeric(
|
|
93
|
+
temp_df["日累计限定金额"], errors="coerce"
|
|
94
|
+
)
|
|
82
95
|
temp_df["手续费"] = temp_df["手续费"].str.strip("%")
|
|
83
|
-
temp_df["手续费"] = pd.to_numeric(temp_df["手续费"])
|
|
96
|
+
temp_df["手续费"] = pd.to_numeric(temp_df["手续费"], errors="coerce")
|
|
84
97
|
return temp_df
|
|
85
98
|
|
|
86
99
|
|
|
@@ -91,12 +104,9 @@ def fund_name_em() -> pd.DataFrame:
|
|
|
91
104
|
:return: 所有基金的名称和类型
|
|
92
105
|
:rtype: pandas.DataFrame
|
|
93
106
|
"""
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
url = "http://fund.eastmoney.com/js/fundcode_search.js"
|
|
98
|
-
res = requests.get(url, headers=headers)
|
|
99
|
-
text_data = res.text
|
|
107
|
+
url = "https://fund.eastmoney.com/js/fundcode_search.js"
|
|
108
|
+
r = requests.get(url, headers=headers)
|
|
109
|
+
text_data = r.text
|
|
100
110
|
data_json = demjson.decode(text_data.strip("var r = ")[:-1])
|
|
101
111
|
temp_df = pd.DataFrame(data_json)
|
|
102
112
|
temp_df.columns = ["基金代码", "拼音缩写", "基金简称", "基金类型", "拼音全称"]
|
|
@@ -104,7 +114,7 @@ def fund_name_em() -> pd.DataFrame:
|
|
|
104
114
|
|
|
105
115
|
|
|
106
116
|
def fund_info_index_em(
|
|
107
|
-
|
|
117
|
+
symbol: str = "沪深指数", indicator: str = "被动指数型"
|
|
108
118
|
) -> pd.DataFrame:
|
|
109
119
|
"""
|
|
110
120
|
东方财富网站-天天基金网-基金数据-基金信息-指数型
|
|
@@ -131,7 +141,7 @@ def fund_info_index_em(
|
|
|
131
141
|
"被动指数型": "051",
|
|
132
142
|
"增强指数型": "052",
|
|
133
143
|
}
|
|
134
|
-
url = "
|
|
144
|
+
url = "https://api.fund.eastmoney.com/FundTradeRank/GetRankList"
|
|
135
145
|
if symbol in {"股票指数", "债券指数"}:
|
|
136
146
|
params = {
|
|
137
147
|
"ft": "zs",
|
|
@@ -180,8 +190,9 @@ def fund_info_index_em(
|
|
|
180
190
|
"Host": "api.fund.eastmoney.com",
|
|
181
191
|
"Pragma": "no-cache",
|
|
182
192
|
"Proxy-Connection": "keep-alive",
|
|
183
|
-
"Referer": "
|
|
184
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
193
|
+
"Referer": "https://fund.eastmoney.com/",
|
|
194
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
195
|
+
"Chrome/103.0.0.0 Safari/537.36",
|
|
185
196
|
}
|
|
186
197
|
r = requests.get(url, params=params, headers=headers)
|
|
187
198
|
data_json = r.json()
|
|
@@ -241,19 +252,18 @@ def fund_info_index_em(
|
|
|
241
252
|
temp_df["跟踪标的"] = symbol
|
|
242
253
|
temp_df["跟踪方式"] = indicator
|
|
243
254
|
|
|
244
|
-
temp_df["单位净值"] = pd.to_numeric(temp_df["单位净值"])
|
|
245
|
-
temp_df["日增长率"] = pd.to_numeric(temp_df["日增长率"])
|
|
246
|
-
temp_df["近1周"] = pd.to_numeric(temp_df["近1周"])
|
|
247
|
-
temp_df["近1月"] = pd.to_numeric(temp_df["近1月"])
|
|
248
|
-
temp_df["近3月"] = pd.to_numeric(temp_df["近3月"])
|
|
249
|
-
temp_df["近6月"] = pd.to_numeric(temp_df["近6月"])
|
|
250
|
-
temp_df["近1年"] = pd.to_numeric(temp_df["近1年"])
|
|
251
|
-
temp_df["近2年"] = pd.to_numeric(temp_df["近2年"])
|
|
252
|
-
temp_df["近3年"] = pd.to_numeric(temp_df["近3年"])
|
|
253
|
-
temp_df["今年来"] = pd.to_numeric(temp_df["今年来"])
|
|
254
|
-
temp_df["成立来"] = pd.to_numeric(temp_df["成立来"])
|
|
255
|
-
temp_df["手续费"] = pd.to_numeric(temp_df["手续费"])
|
|
256
|
-
|
|
255
|
+
temp_df["单位净值"] = pd.to_numeric(temp_df["单位净值"], errors="coerce")
|
|
256
|
+
temp_df["日增长率"] = pd.to_numeric(temp_df["日增长率"], errors="coerce")
|
|
257
|
+
temp_df["近1周"] = pd.to_numeric(temp_df["近1周"], errors="coerce")
|
|
258
|
+
temp_df["近1月"] = pd.to_numeric(temp_df["近1月"], errors="coerce")
|
|
259
|
+
temp_df["近3月"] = pd.to_numeric(temp_df["近3月"], errors="coerce")
|
|
260
|
+
temp_df["近6月"] = pd.to_numeric(temp_df["近6月"], errors="coerce")
|
|
261
|
+
temp_df["近1年"] = pd.to_numeric(temp_df["近1年"], errors="coerce")
|
|
262
|
+
temp_df["近2年"] = pd.to_numeric(temp_df["近2年"], errors="coerce")
|
|
263
|
+
temp_df["近3年"] = pd.to_numeric(temp_df["近3年"], errors="coerce")
|
|
264
|
+
temp_df["今年来"] = pd.to_numeric(temp_df["今年来"], errors="coerce")
|
|
265
|
+
temp_df["成立来"] = pd.to_numeric(temp_df["成立来"], errors="coerce")
|
|
266
|
+
temp_df["手续费"] = pd.to_numeric(temp_df["手续费"], errors="coerce")
|
|
257
267
|
return temp_df
|
|
258
268
|
|
|
259
269
|
|
|
@@ -264,10 +274,7 @@ def fund_open_fund_daily_em() -> pd.DataFrame:
|
|
|
264
274
|
:return: 当前交易日的所有开放式基金净值数据
|
|
265
275
|
:rtype: pandas.DataFrame
|
|
266
276
|
"""
|
|
267
|
-
|
|
268
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
|
|
269
|
-
}
|
|
270
|
-
url = "http://fund.eastmoney.com/Data/Fund_JJJZ_Data.aspx"
|
|
277
|
+
url = "https://fund.eastmoney.com/Data/Fund_JJJZ_Data.aspx"
|
|
271
278
|
params = {
|
|
272
279
|
"t": "1",
|
|
273
280
|
"lx": "1",
|
|
@@ -327,11 +334,11 @@ def fund_open_fund_daily_em() -> pd.DataFrame:
|
|
|
327
334
|
|
|
328
335
|
|
|
329
336
|
def fund_open_fund_info_em(
|
|
330
|
-
|
|
337
|
+
symbol: str = "710001", indicator: str = "单位净值走势", period: str = "成立来"
|
|
331
338
|
) -> pd.DataFrame:
|
|
332
339
|
"""
|
|
333
340
|
东方财富网-天天基金网-基金数据-开放式基金净值
|
|
334
|
-
https://fund.eastmoney.com/fund.html
|
|
341
|
+
https://fund.eastmoney.com/fund.html
|
|
335
342
|
:param symbol: 基金代码; 可以通过调用 ak.fund_open_fund_daily_em() 获取所有开放式基金代码
|
|
336
343
|
:type symbol: str
|
|
337
344
|
:param indicator: 需要获取的指标
|
|
@@ -341,32 +348,24 @@ def fund_open_fund_info_em(
|
|
|
341
348
|
:return: 指定基金指定指标的数据
|
|
342
349
|
:rtype: pandas.DataFrame
|
|
343
350
|
"""
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
|
|
348
|
-
}
|
|
351
|
+
from akshare.utils.cons import headers
|
|
352
|
+
|
|
353
|
+
url = f"https://fund.eastmoney.com/pingzhongdata/{symbol}.js" # 各类数据都在里面
|
|
349
354
|
r = requests.get(url, headers=headers)
|
|
350
355
|
data_text = r.text
|
|
351
356
|
|
|
357
|
+
js_code = py_mini_racer.MiniRacer()
|
|
358
|
+
js_code.eval(data_text)
|
|
359
|
+
|
|
352
360
|
# 单位净值走势
|
|
353
361
|
if indicator == "单位净值走势":
|
|
354
|
-
|
|
355
|
-
data_json = demjson.decode(
|
|
356
|
-
data_text[
|
|
357
|
-
data_text.find("Data_netWorthTrend")
|
|
358
|
-
+ 21: data_text.find("Data_ACWorthTrend")
|
|
359
|
-
- 15
|
|
360
|
-
]
|
|
361
|
-
)
|
|
362
|
-
except:
|
|
363
|
-
return pd.DataFrame()
|
|
362
|
+
data_json = js_code.execute("Data_netWorthTrend")
|
|
364
363
|
temp_df = pd.DataFrame(data_json)
|
|
365
364
|
if temp_df.empty:
|
|
366
365
|
return pd.DataFrame()
|
|
367
|
-
temp_df["x"] = pd.to_datetime(
|
|
368
|
-
|
|
369
|
-
)
|
|
366
|
+
temp_df["x"] = pd.to_datetime(temp_df["x"], unit="ms", utc=True).dt.tz_convert(
|
|
367
|
+
"Asia/Shanghai"
|
|
368
|
+
)
|
|
370
369
|
temp_df["x"] = temp_df["x"].dt.date
|
|
371
370
|
temp_df.columns = [
|
|
372
371
|
"净值日期",
|
|
@@ -381,30 +380,23 @@ def fund_open_fund_info_em(
|
|
|
381
380
|
"日增长率",
|
|
382
381
|
]
|
|
383
382
|
]
|
|
384
|
-
temp_df["净值日期"] = pd.to_datetime(
|
|
383
|
+
temp_df["净值日期"] = pd.to_datetime(
|
|
384
|
+
temp_df["净值日期"], errors="coerce"
|
|
385
|
+
).dt.date
|
|
385
386
|
temp_df["单位净值"] = pd.to_numeric(temp_df["单位净值"], errors="coerce")
|
|
386
387
|
temp_df["日增长率"] = pd.to_numeric(temp_df["日增长率"], errors="coerce")
|
|
387
388
|
return temp_df
|
|
388
389
|
|
|
389
390
|
# 累计净值走势
|
|
390
391
|
if indicator == "累计净值走势":
|
|
391
|
-
|
|
392
|
-
data_json = demjson.decode(
|
|
393
|
-
data_text[
|
|
394
|
-
data_text.find("Data_ACWorthTrend")
|
|
395
|
-
+ 20: data_text.find("Data_grandTotal")
|
|
396
|
-
- 16
|
|
397
|
-
]
|
|
398
|
-
)
|
|
399
|
-
except:
|
|
400
|
-
return pd.DataFrame()
|
|
392
|
+
data_json = js_code.execute("Data_ACWorthTrend")
|
|
401
393
|
temp_df = pd.DataFrame(data_json)
|
|
402
394
|
if temp_df.empty:
|
|
403
395
|
return pd.DataFrame()
|
|
404
396
|
temp_df.columns = ["x", "y"]
|
|
405
|
-
temp_df["x"] = pd.to_datetime(
|
|
406
|
-
|
|
407
|
-
)
|
|
397
|
+
temp_df["x"] = pd.to_datetime(temp_df["x"], unit="ms", utc=True).dt.tz_convert(
|
|
398
|
+
"Asia/Shanghai"
|
|
399
|
+
)
|
|
408
400
|
temp_df["x"] = temp_df["x"].dt.date
|
|
409
401
|
temp_df.columns = [
|
|
410
402
|
"净值日期",
|
|
@@ -416,16 +408,16 @@ def fund_open_fund_info_em(
|
|
|
416
408
|
"累计净值",
|
|
417
409
|
]
|
|
418
410
|
]
|
|
419
|
-
temp_df["净值日期"] = pd.to_datetime(
|
|
411
|
+
temp_df["净值日期"] = pd.to_datetime(
|
|
412
|
+
temp_df["净值日期"], errors="coerce"
|
|
413
|
+
).dt.date
|
|
420
414
|
temp_df["累计净值"] = pd.to_numeric(temp_df["累计净值"], errors="coerce")
|
|
421
415
|
return temp_df
|
|
422
416
|
|
|
423
417
|
# 累计收益率走势
|
|
424
418
|
if indicator == "累计收益率走势":
|
|
425
419
|
url = "https://api.fund.eastmoney.com/pinzhong/LJSYLZS"
|
|
426
|
-
headers = {
|
|
427
|
-
'Referer': 'https://fund.eastmoney.com/'
|
|
428
|
-
}
|
|
420
|
+
headers = {"Referer": "https://fund.eastmoney.com/"}
|
|
429
421
|
period_map = {
|
|
430
422
|
"1月": "m",
|
|
431
423
|
"3月": "q",
|
|
@@ -437,14 +429,14 @@ def fund_open_fund_info_em(
|
|
|
437
429
|
"成立来": "se",
|
|
438
430
|
}
|
|
439
431
|
params = {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
432
|
+
"fundCode": symbol,
|
|
433
|
+
"indexcode": "000300",
|
|
434
|
+
"type": period_map[period],
|
|
435
|
+
"_": "1704012866899",
|
|
444
436
|
}
|
|
445
437
|
r = requests.get(url, params=params, headers=headers)
|
|
446
438
|
data_json = r.json()
|
|
447
|
-
temp_df = pd.DataFrame(data_json[
|
|
439
|
+
temp_df = pd.DataFrame(data_json["Data"][0]["data"])
|
|
448
440
|
temp_df.columns = ["日期", "累计收益率"]
|
|
449
441
|
temp_df["日期"] = pd.to_datetime(
|
|
450
442
|
temp_df["日期"], unit="ms", utc=True
|
|
@@ -455,17 +447,11 @@ def fund_open_fund_info_em(
|
|
|
455
447
|
|
|
456
448
|
# 同类排名走势
|
|
457
449
|
if indicator == "同类排名走势":
|
|
458
|
-
data_json =
|
|
459
|
-
data_text[
|
|
460
|
-
data_text.find("Data_rateInSimilarType")
|
|
461
|
-
+ 25: data_text.find("Data_rateInSimilarPersent")
|
|
462
|
-
- 16
|
|
463
|
-
]
|
|
464
|
-
)
|
|
450
|
+
data_json = js_code.execute("Data_rateInSimilarType")
|
|
465
451
|
temp_df = pd.DataFrame(data_json)
|
|
466
|
-
temp_df["x"] = pd.to_datetime(
|
|
467
|
-
|
|
468
|
-
)
|
|
452
|
+
temp_df["x"] = pd.to_datetime(temp_df["x"], unit="ms", utc=True).dt.tz_convert(
|
|
453
|
+
"Asia/Shanghai"
|
|
454
|
+
)
|
|
469
455
|
temp_df["x"] = temp_df["x"].dt.date
|
|
470
456
|
temp_df.columns = [
|
|
471
457
|
"报告日期",
|
|
@@ -479,25 +465,25 @@ def fund_open_fund_info_em(
|
|
|
479
465
|
"总排名-每日近三月排名",
|
|
480
466
|
]
|
|
481
467
|
]
|
|
482
|
-
temp_df["报告日期"] = pd.to_datetime(
|
|
483
|
-
|
|
484
|
-
|
|
468
|
+
temp_df["报告日期"] = pd.to_datetime(
|
|
469
|
+
temp_df["报告日期"], errors="coerce"
|
|
470
|
+
).dt.date
|
|
471
|
+
temp_df["同类型排名-每日近三月排名"] = pd.to_numeric(
|
|
472
|
+
temp_df["同类型排名-每日近三月排名"], errors="coerce"
|
|
473
|
+
)
|
|
474
|
+
temp_df["总排名-每日近三月排名"] = pd.to_numeric(
|
|
475
|
+
temp_df["总排名-每日近三月排名"], errors="coerce"
|
|
476
|
+
)
|
|
485
477
|
return temp_df
|
|
486
478
|
|
|
487
479
|
# 同类排名百分比
|
|
488
480
|
if indicator == "同类排名百分比":
|
|
489
|
-
data_json =
|
|
490
|
-
data_text[
|
|
491
|
-
data_text.find("Data_rateInSimilarPersent")
|
|
492
|
-
+ 26: data_text.find("Data_fluctuationScale")
|
|
493
|
-
- 23
|
|
494
|
-
]
|
|
495
|
-
)
|
|
481
|
+
data_json = js_code.execute("Data_rateInSimilarPersent")
|
|
496
482
|
temp_df = pd.DataFrame(data_json)
|
|
497
483
|
temp_df.columns = ["x", "y"]
|
|
498
|
-
temp_df["x"] = pd.to_datetime(
|
|
499
|
-
|
|
500
|
-
)
|
|
484
|
+
temp_df["x"] = pd.to_datetime(temp_df["x"], unit="ms", utc=True).dt.tz_convert(
|
|
485
|
+
"Asia/Shanghai"
|
|
486
|
+
)
|
|
501
487
|
temp_df["x"] = temp_df["x"].dt.date
|
|
502
488
|
temp_df.columns = [
|
|
503
489
|
"报告日期",
|
|
@@ -509,7 +495,9 @@ def fund_open_fund_info_em(
|
|
|
509
495
|
"同类型排名-每日近3月收益排名百分比",
|
|
510
496
|
]
|
|
511
497
|
]
|
|
512
|
-
temp_df["报告日期"] = pd.to_datetime(
|
|
498
|
+
temp_df["报告日期"] = pd.to_datetime(
|
|
499
|
+
temp_df["报告日期"], errors="coerce"
|
|
500
|
+
).dt.date
|
|
513
501
|
temp_df["同类型排名-每日近3月收益排名百分比"] = pd.to_numeric(
|
|
514
502
|
temp_df["同类型排名-每日近3月收益排名百分比"], errors="coerce"
|
|
515
503
|
)
|
|
@@ -517,21 +505,21 @@ def fund_open_fund_info_em(
|
|
|
517
505
|
|
|
518
506
|
# 分红送配详情
|
|
519
507
|
if indicator == "分红送配详情":
|
|
520
|
-
url = f"
|
|
508
|
+
url = f"https://fundf10.eastmoney.com/fhsp_{symbol}.html"
|
|
521
509
|
r = requests.get(url, headers=headers)
|
|
522
510
|
temp_df = pd.read_html(StringIO(r.text))[1]
|
|
523
511
|
if temp_df.iloc[0, 1] == "暂无分红信息!":
|
|
524
|
-
return
|
|
512
|
+
return pd.DataFrame()
|
|
525
513
|
else:
|
|
526
514
|
return temp_df
|
|
527
515
|
|
|
528
516
|
# 拆分详情
|
|
529
517
|
if indicator == "拆分详情":
|
|
530
|
-
url = f"
|
|
518
|
+
url = f"https://fundf10.eastmoney.com/fhsp_{symbol}.html"
|
|
531
519
|
r = requests.get(url, headers=headers)
|
|
532
520
|
temp_df = pd.read_html(StringIO(r.text))[2]
|
|
533
521
|
if temp_df.iloc[0, 1] == "暂无拆分信息!":
|
|
534
|
-
return
|
|
522
|
+
return pd.DataFrame()
|
|
535
523
|
else:
|
|
536
524
|
return temp_df
|
|
537
525
|
|
|
@@ -543,10 +531,7 @@ def fund_money_fund_daily_em() -> pd.DataFrame:
|
|
|
543
531
|
:return: 当前交易日的所有货币型基金收益数据
|
|
544
532
|
:rtype: pandas.DataFrame
|
|
545
533
|
"""
|
|
546
|
-
|
|
547
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
|
|
548
|
-
}
|
|
549
|
-
url = "http://fund.eastmoney.com/HBJJ_pjsyl.html"
|
|
534
|
+
url = "https://fund.eastmoney.com/HBJJ_pjsyl.html"
|
|
550
535
|
r = requests.get(url, headers=headers)
|
|
551
536
|
r.encoding = "gb2312"
|
|
552
537
|
show_day = pd.read_html(StringIO(r.text))[1].iloc[0, 5:11].tolist()
|
|
@@ -576,16 +561,17 @@ def fund_money_fund_daily_em() -> pd.DataFrame:
|
|
|
576
561
|
def fund_money_fund_info_em(fund: str = "000009") -> pd.DataFrame:
|
|
577
562
|
"""
|
|
578
563
|
东方财富网-天天基金网-基金数据-货币型基金收益-历史净值数据
|
|
579
|
-
|
|
564
|
+
https://fundf10.eastmoney.com/jjjz_004186.html
|
|
580
565
|
:param fund: 货币型基金代码, 可以通过 fund_money_fund_daily_em 来获取
|
|
581
566
|
:type fund: str
|
|
582
567
|
:return: 东方财富网站-天天基金网-基金数据-货币型基金收益-历史净值数据
|
|
583
568
|
:rtype: pandas.DataFrame
|
|
584
569
|
"""
|
|
585
|
-
url = "
|
|
570
|
+
url = "https://api.fund.eastmoney.com/f10/lsjz"
|
|
586
571
|
headers = {
|
|
587
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
588
|
-
"
|
|
572
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
573
|
+
"Chrome/80.0.3987.149 Safari/537.36",
|
|
574
|
+
"Referer": f"https://fundf10.eastmoney.com/jjjz_{fund}.html",
|
|
589
575
|
}
|
|
590
576
|
params = {
|
|
591
577
|
"callback": "jQuery18306461675574671744_1588245122574",
|
|
@@ -598,7 +584,7 @@ def fund_money_fund_info_em(fund: str = "000009") -> pd.DataFrame:
|
|
|
598
584
|
}
|
|
599
585
|
r = requests.get(url, params=params, headers=headers)
|
|
600
586
|
text_data = r.text
|
|
601
|
-
data_json = demjson.decode(text_data[text_data.find("{"): -1])
|
|
587
|
+
data_json = demjson.decode(text_data[text_data.find("{") : -1])
|
|
602
588
|
temp_df = pd.DataFrame(data_json["Data"]["LSJZList"])
|
|
603
589
|
temp_df.columns = [
|
|
604
590
|
"净值日期",
|
|
@@ -615,7 +601,9 @@ def fund_money_fund_info_em(fund: str = "000009") -> pd.DataFrame:
|
|
|
615
601
|
"_",
|
|
616
602
|
"_",
|
|
617
603
|
]
|
|
618
|
-
temp_df = temp_df[
|
|
604
|
+
temp_df = temp_df[
|
|
605
|
+
["净值日期", "每万份收益", "7日年化收益率", "申购状态", "赎回状态"]
|
|
606
|
+
]
|
|
619
607
|
return temp_df
|
|
620
608
|
|
|
621
609
|
|
|
@@ -623,14 +611,15 @@ def fund_financial_fund_daily_em() -> pd.DataFrame:
|
|
|
623
611
|
"""
|
|
624
612
|
东方财富网站-天天基金网-基金数据-理财型基金收益
|
|
625
613
|
# 该接口暂无数据
|
|
626
|
-
|
|
614
|
+
https://fund.eastmoney.com/lcjj.html#1_1__0__ljjz,desc_1_os1
|
|
627
615
|
:return: 当前交易日的所有理财型基金收益
|
|
628
616
|
:rtype: pandas.DataFrame
|
|
629
617
|
"""
|
|
630
|
-
url = "
|
|
618
|
+
url = "https://api.fund.eastmoney.com/FundNetValue/GetLCJJJZ"
|
|
631
619
|
headers = {
|
|
632
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
633
|
-
"
|
|
620
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
621
|
+
"Chrome/80.0.3987.149 Safari/537.36",
|
|
622
|
+
"Referer": "https://fund.eastmoney.com/lcjj.html",
|
|
634
623
|
}
|
|
635
624
|
params = {
|
|
636
625
|
"letter": "",
|
|
@@ -647,7 +636,7 @@ def fund_financial_fund_daily_em() -> pd.DataFrame:
|
|
|
647
636
|
data_json = r.json()
|
|
648
637
|
temp_df = pd.DataFrame(data_json["Data"]["List"])
|
|
649
638
|
if temp_df.empty:
|
|
650
|
-
return
|
|
639
|
+
return pd.DataFrame()
|
|
651
640
|
show_day = data_json["Data"]["showday"]
|
|
652
641
|
data_df = temp_df[
|
|
653
642
|
[
|
|
@@ -701,10 +690,11 @@ def fund_financial_fund_info_em(symbol: str = "000134") -> pd.DataFrame:
|
|
|
701
690
|
:return: 东方财富网站-天天基金网-基金数据-理财型基金收益-历史净值明细
|
|
702
691
|
:rtype: pandas.DataFrame
|
|
703
692
|
"""
|
|
704
|
-
url = "
|
|
693
|
+
url = "https://api.fund.eastmoney.com/f10/lsjz"
|
|
705
694
|
headers = {
|
|
706
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
707
|
-
"
|
|
695
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
696
|
+
"Chrome/80.0.3987.149 Safari/537.36",
|
|
697
|
+
"Referer": f"https://fundf10.eastmoney.com/jjjz_{symbol}.html",
|
|
708
698
|
}
|
|
709
699
|
params = {
|
|
710
700
|
"callback": "jQuery18307915911837995662_1588249228826",
|
|
@@ -717,7 +707,7 @@ def fund_financial_fund_info_em(symbol: str = "000134") -> pd.DataFrame:
|
|
|
717
707
|
}
|
|
718
708
|
r = requests.get(url, params=params, headers=headers)
|
|
719
709
|
text_data = r.text
|
|
720
|
-
data_json = demjson.decode(text_data[text_data.find("{"): -1])
|
|
710
|
+
data_json = demjson.decode(text_data[text_data.find("{") : -1])
|
|
721
711
|
temp_df = pd.DataFrame(data_json["Data"]["LSJZList"])
|
|
722
712
|
temp_df.columns = [
|
|
723
713
|
"净值日期",
|
|
@@ -734,27 +724,38 @@ def fund_financial_fund_info_em(symbol: str = "000134") -> pd.DataFrame:
|
|
|
734
724
|
"_",
|
|
735
725
|
"分红送配",
|
|
736
726
|
]
|
|
737
|
-
temp_df = temp_df[
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
727
|
+
temp_df = temp_df[
|
|
728
|
+
[
|
|
729
|
+
"净值日期",
|
|
730
|
+
"单位净值",
|
|
731
|
+
"累计净值",
|
|
732
|
+
"日增长率",
|
|
733
|
+
"申购状态",
|
|
734
|
+
"赎回状态",
|
|
735
|
+
"分红送配",
|
|
736
|
+
]
|
|
737
|
+
]
|
|
738
|
+
temp_df.sort_values(["净值日期"], inplace=True, ignore_index=True)
|
|
739
|
+
temp_df["净值日期"] = pd.to_datetime(temp_df["净值日期"]).dt.date
|
|
740
|
+
temp_df["单位净值"] = pd.to_numeric(temp_df["单位净值"], errors="coerce")
|
|
741
|
+
temp_df["累计净值"] = pd.to_numeric(temp_df["累计净值"], errors="coerce")
|
|
742
|
+
temp_df["日增长率"] = pd.to_numeric(temp_df["日增长率"], errors="coerce")
|
|
743
743
|
return temp_df
|
|
744
744
|
|
|
745
745
|
|
|
746
746
|
def fund_graded_fund_daily_em() -> pd.DataFrame:
|
|
747
747
|
"""
|
|
748
748
|
东方财富网站-天天基金网-基金数据-分级基金净值
|
|
749
|
-
|
|
749
|
+
https://fund.eastmoney.com/fjjj.html#1_1__0__zdf,desc_1
|
|
750
750
|
:return: 当前交易日的所有分级基金净值
|
|
751
751
|
:rtype: pandas.DataFrame
|
|
752
752
|
"""
|
|
753
|
+
url = "https://fund.eastmoney.com/Data/Fund_JJJZ_Data.aspx"
|
|
753
754
|
headers = {
|
|
754
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
755
|
-
"
|
|
755
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
756
|
+
"Chrome/80.0.3987.149 Safari/537.36",
|
|
757
|
+
"Referer": "https://fund.eastmoney.com/fjjj.html",
|
|
756
758
|
}
|
|
757
|
-
url = "http://fund.eastmoney.com/Data/Fund_JJJZ_Data.aspx"
|
|
758
759
|
params = {
|
|
759
760
|
"t": "1",
|
|
760
761
|
"lx": "9",
|
|
@@ -814,16 +815,17 @@ def fund_graded_fund_daily_em() -> pd.DataFrame:
|
|
|
814
815
|
def fund_graded_fund_info_em(fund: str = "150232") -> pd.DataFrame:
|
|
815
816
|
"""
|
|
816
817
|
东方财富网站-天天基金网-基金数据-分级基金净值-历史净值明细
|
|
817
|
-
|
|
818
|
+
https://fundf10.eastmoney.com/jjjz_150232.html
|
|
818
819
|
:param fund: 分级基金代码, 可以通过 fund_money_fund_daily_em 来获取
|
|
819
820
|
:type fund: str
|
|
820
821
|
:return: 东方财富网站-天天基金网-基金数据-分级基金净值-历史净值明细
|
|
821
822
|
:rtype: pandas.DataFrame
|
|
822
823
|
"""
|
|
823
|
-
url = "
|
|
824
|
+
url = "https://api.fund.eastmoney.com/f10/lsjz"
|
|
824
825
|
headers = {
|
|
825
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
826
|
-
"
|
|
826
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
827
|
+
"Chrome/80.0.3987.149 Safari/537.36",
|
|
828
|
+
"Referer": f"https://fundf10.eastmoney.com/jjjz_{fund}.html",
|
|
827
829
|
}
|
|
828
830
|
params = {
|
|
829
831
|
"callback": "jQuery18309549480723031107_1588250168187",
|
|
@@ -836,7 +838,7 @@ def fund_graded_fund_info_em(fund: str = "150232") -> pd.DataFrame:
|
|
|
836
838
|
}
|
|
837
839
|
r = requests.get(url, params=params, headers=headers)
|
|
838
840
|
text_data = r.text
|
|
839
|
-
data_json = demjson.decode(text_data[text_data.find("{"): -1])
|
|
841
|
+
data_json = demjson.decode(text_data[text_data.find("{") : -1])
|
|
840
842
|
temp_df = pd.DataFrame(data_json["Data"]["LSJZList"])
|
|
841
843
|
temp_df.columns = [
|
|
842
844
|
"净值日期",
|
|
@@ -853,21 +855,20 @@ def fund_graded_fund_info_em(fund: str = "150232") -> pd.DataFrame:
|
|
|
853
855
|
"_",
|
|
854
856
|
"_",
|
|
855
857
|
]
|
|
856
|
-
temp_df = temp_df[
|
|
858
|
+
temp_df = temp_df[
|
|
859
|
+
["净值日期", "单位净值", "累计净值", "日增长率", "申购状态", "赎回状态"]
|
|
860
|
+
]
|
|
857
861
|
return temp_df
|
|
858
862
|
|
|
859
863
|
|
|
860
864
|
def fund_etf_fund_daily_em() -> pd.DataFrame:
|
|
861
865
|
"""
|
|
862
866
|
东方财富网-天天基金网-基金数据-场内交易基金
|
|
863
|
-
|
|
867
|
+
https://fund.eastmoney.com/cnjy_dwjz.html
|
|
864
868
|
:return: 当前交易日的所有场内交易基金数据
|
|
865
869
|
:rtype: pandas.DataFrame
|
|
866
870
|
"""
|
|
867
|
-
|
|
868
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
|
|
869
|
-
}
|
|
870
|
-
url = "http://fund.eastmoney.com/cnjy_dwjz.html"
|
|
871
|
+
url = "https://fund.eastmoney.com/cnjy_dwjz.html"
|
|
871
872
|
r = requests.get(url, headers=headers)
|
|
872
873
|
r.encoding = "gb2312"
|
|
873
874
|
show_day = pd.read_html(StringIO(r.text))[1].iloc[0, 6:10].tolist()
|
|
@@ -894,13 +895,13 @@ def fund_etf_fund_daily_em() -> pd.DataFrame:
|
|
|
894
895
|
|
|
895
896
|
|
|
896
897
|
def fund_etf_fund_info_em(
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
898
|
+
fund: str = "511280",
|
|
899
|
+
start_date: str = "20000101",
|
|
900
|
+
end_date: str = "20500101",
|
|
900
901
|
) -> pd.DataFrame:
|
|
901
902
|
"""
|
|
902
903
|
东方财富网站-天天基金网-基金数据-场内交易基金-历史净值明细
|
|
903
|
-
|
|
904
|
+
https://fundf10.eastmoney.com/jjjz_511280.html
|
|
904
905
|
:param fund: 场内交易基金代码, 可以通过 fund_etf_fund_daily_em 来获取
|
|
905
906
|
:type fund: str
|
|
906
907
|
:param start_date: 开始统计时间
|
|
@@ -910,25 +911,33 @@ def fund_etf_fund_info_em(
|
|
|
910
911
|
:return: 东方财富网站-天天基金网-基金数据-场内交易基金-历史净值明细
|
|
911
912
|
:rtype: pandas.DataFrame
|
|
912
913
|
"""
|
|
913
|
-
url = "
|
|
914
|
+
url = "https://api.fund.eastmoney.com/f10/lsjz"
|
|
914
915
|
headers = {
|
|
915
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
916
|
-
"
|
|
916
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
917
|
+
"Chrome/80.0.3987.149 Safari/537.36",
|
|
918
|
+
"Referer": f"https://fundf10.eastmoney.com/jjjz_{fund}.html",
|
|
917
919
|
}
|
|
918
920
|
params = {
|
|
919
921
|
"fundCode": fund,
|
|
920
922
|
"pageIndex": "1",
|
|
921
|
-
"pageSize": "
|
|
922
|
-
"startDate": "-".join(
|
|
923
|
-
[start_date[:4], start_date[4:6], start_date[6:]]
|
|
924
|
-
),
|
|
923
|
+
"pageSize": "20",
|
|
924
|
+
"startDate": "-".join([start_date[:4], start_date[4:6], start_date[6:]]),
|
|
925
925
|
"endDate": "-".join([end_date[:4], end_date[4:6], end_date[6:]]),
|
|
926
926
|
"_": round(time.time() * 1000),
|
|
927
927
|
}
|
|
928
928
|
r = requests.get(url, params=params, headers=headers)
|
|
929
929
|
data_json = r.json()
|
|
930
|
-
|
|
931
|
-
|
|
930
|
+
total_page = math.ceil(data_json["TotalCount"] / 20)
|
|
931
|
+
df_list = []
|
|
932
|
+
tqdm = get_tqdm()
|
|
933
|
+
for page in tqdm(range(1, total_page + 1), leave=False):
|
|
934
|
+
params.update({"pageIndex": page})
|
|
935
|
+
r = requests.get(url, params=params, headers=headers)
|
|
936
|
+
data_json = r.json()
|
|
937
|
+
temp_df = pd.DataFrame(data_json["Data"]["LSJZList"])
|
|
938
|
+
df_list.append(temp_df)
|
|
939
|
+
big_df = pd.concat(df_list)
|
|
940
|
+
big_df.columns = [
|
|
932
941
|
"净值日期",
|
|
933
942
|
"单位净值",
|
|
934
943
|
"累计净值",
|
|
@@ -943,19 +952,21 @@ def fund_etf_fund_info_em(
|
|
|
943
952
|
"_",
|
|
944
953
|
"_",
|
|
945
954
|
]
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
955
|
+
big_df = big_df[
|
|
956
|
+
["净值日期", "单位净值", "累计净值", "日增长率", "申购状态", "赎回状态"]
|
|
957
|
+
]
|
|
958
|
+
big_df["净值日期"] = pd.to_datetime(big_df["净值日期"], errors="coerce").dt.date
|
|
959
|
+
big_df["单位净值"] = pd.to_numeric(big_df["单位净值"], errors="coerce")
|
|
960
|
+
big_df["累计净值"] = pd.to_numeric(big_df["累计净值"], errors="coerce")
|
|
961
|
+
big_df["日增长率"] = pd.to_numeric(big_df["日增长率"], errors="coerce")
|
|
962
|
+
big_df.sort_values(["净值日期"], inplace=True, ignore_index=True)
|
|
963
|
+
return big_df
|
|
953
964
|
|
|
954
965
|
|
|
955
966
|
def fund_value_estimation_em(symbol: str = "全部") -> pd.DataFrame:
|
|
956
967
|
"""
|
|
957
968
|
东方财富网-数据中心-净值估算
|
|
958
|
-
|
|
969
|
+
https://fund.eastmoney.com/fundguzhi.html
|
|
959
970
|
:param symbol: choice of {'全部', '股票型', '混合型', '债券型', '指数型', 'QDII', 'ETF联接', 'LOF', '场内交易基金'}
|
|
960
971
|
:type symbol: str
|
|
961
972
|
:return: 近期净值估算数据
|
|
@@ -972,10 +983,11 @@ def fund_value_estimation_em(symbol: str = "全部") -> pd.DataFrame:
|
|
|
972
983
|
"LOF": 8,
|
|
973
984
|
"场内交易基金": 9,
|
|
974
985
|
}
|
|
975
|
-
url = "
|
|
986
|
+
url = "https://api.fund.eastmoney.com/FundGuZhi/GetFundGZList"
|
|
976
987
|
headers = {
|
|
977
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
978
|
-
"
|
|
988
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
989
|
+
"Chrome/81.0.4044.138 Safari/537.36",
|
|
990
|
+
"Referer": "https://fund.eastmoney.com/",
|
|
979
991
|
}
|
|
980
992
|
params = {
|
|
981
993
|
"type": symbol_map[symbol],
|
|
@@ -1042,7 +1054,7 @@ def fund_value_estimation_em(symbol: str = "全部") -> pd.DataFrame:
|
|
|
1042
1054
|
|
|
1043
1055
|
|
|
1044
1056
|
def fund_hk_fund_hist_em(
|
|
1045
|
-
|
|
1057
|
+
code: str = "1002200683", symbol: str = "历史净值明细"
|
|
1046
1058
|
) -> pd.DataFrame:
|
|
1047
1059
|
"""
|
|
1048
1060
|
东方财富网-天天基金网-基金数据-香港基金-历史净值明细(分红送配详情)
|
|
@@ -1054,10 +1066,7 @@ def fund_hk_fund_hist_em(
|
|
|
1054
1066
|
:return: 香港基金-历史净值明细(分红送配详情)
|
|
1055
1067
|
:rtype: pandas.DataFrame
|
|
1056
1068
|
"""
|
|
1057
|
-
url = "
|
|
1058
|
-
headers = {
|
|
1059
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
|
|
1060
|
-
}
|
|
1069
|
+
url = "https://overseas.1234567.com.cn/overseasapi/OpenApiHander.ashx"
|
|
1061
1070
|
if symbol == "历史净值明细":
|
|
1062
1071
|
params = {
|
|
1063
1072
|
"api": "HKFDApi",
|
|
@@ -1146,9 +1155,7 @@ if __name__ == "__main__":
|
|
|
1146
1155
|
fund_name_em_df = fund_name_em()
|
|
1147
1156
|
print(fund_name_em_df)
|
|
1148
1157
|
|
|
1149
|
-
fund_info_index_em_df = fund_info_index_em(
|
|
1150
|
-
symbol="债券指数", indicator="全部"
|
|
1151
|
-
)
|
|
1158
|
+
fund_info_index_em_df = fund_info_index_em(symbol="债券指数", indicator="全部")
|
|
1152
1159
|
print(fund_info_index_em_df)
|
|
1153
1160
|
|
|
1154
1161
|
fund_open_fund_daily_em_df = fund_open_fund_daily_em()
|
|
@@ -1162,7 +1169,7 @@ if __name__ == "__main__":
|
|
|
1162
1169
|
time.sleep(3)
|
|
1163
1170
|
|
|
1164
1171
|
fund_open_fund_info_em_df = fund_open_fund_info_em(
|
|
1165
|
-
symbol="
|
|
1172
|
+
symbol="502010", indicator="累计净值走势", period="成立来"
|
|
1166
1173
|
)
|
|
1167
1174
|
print(fund_open_fund_info_em_df)
|
|
1168
1175
|
time.sleep(3)
|