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
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/7/15 16:30
|
|
5
5
|
Desc: 新浪财经-ESG评级中心
|
|
6
6
|
https://finance.sina.com.cn/esg/
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import math
|
|
9
10
|
|
|
10
11
|
import pandas as pd
|
|
@@ -12,6 +13,156 @@ import requests
|
|
|
12
13
|
from tqdm import tqdm
|
|
13
14
|
|
|
14
15
|
|
|
16
|
+
def stock_esg_msci_sina() -> pd.DataFrame:
|
|
17
|
+
"""
|
|
18
|
+
新浪财经-ESG评级中心-ESG评级-MSCI
|
|
19
|
+
https://finance.sina.com.cn/esg/grade.shtml
|
|
20
|
+
:return: MSCI
|
|
21
|
+
:rtype: pandas.DataFrame
|
|
22
|
+
"""
|
|
23
|
+
url = "https://global.finance.sina.com.cn/api/openapi.php/EsgService.getMsciEsgStocks?p=1&num=100"
|
|
24
|
+
r = requests.get(url)
|
|
25
|
+
data_json = r.json()
|
|
26
|
+
page_num = math.ceil(int(data_json["result"]["data"]["total"]) / 100)
|
|
27
|
+
big_df = pd.DataFrame()
|
|
28
|
+
for page in tqdm(range(1, page_num + 1), leave=False):
|
|
29
|
+
headers = {
|
|
30
|
+
"Referer": "https://finance.sina.com.cn/",
|
|
31
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
32
|
+
"Chrome/123.0.0.0 Safari/537.36",
|
|
33
|
+
}
|
|
34
|
+
url = f"https://global.finance.sina.com.cn/api/openapi.php/EsgService.getMsciEsgStocks?p={page}&num=100"
|
|
35
|
+
r = requests.get(url, headers=headers)
|
|
36
|
+
data_json = r.json()
|
|
37
|
+
temp_df = pd.DataFrame(data_json["result"]["data"]["data"])
|
|
38
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
39
|
+
|
|
40
|
+
big_df.rename(
|
|
41
|
+
columns={
|
|
42
|
+
"agency_id": "-",
|
|
43
|
+
"agency_name": "评级机构",
|
|
44
|
+
"symbol": "股票代码",
|
|
45
|
+
"delist": "-",
|
|
46
|
+
"comp_code": "-",
|
|
47
|
+
"name": "股票名称",
|
|
48
|
+
"market": "交易市场",
|
|
49
|
+
"industry_code": "行业代码",
|
|
50
|
+
"industry_name": "行业名称",
|
|
51
|
+
"sw1_code": "-",
|
|
52
|
+
"sw1_name": "-",
|
|
53
|
+
"sw2_code": "-",
|
|
54
|
+
"sw2_name": "-",
|
|
55
|
+
"sw3_code": "-",
|
|
56
|
+
"sw3_name": "-",
|
|
57
|
+
"hs1_code": "-",
|
|
58
|
+
"hs1_name": "-",
|
|
59
|
+
"hs2_code": "-",
|
|
60
|
+
"hs2_name": "-",
|
|
61
|
+
"hs3_code": "-",
|
|
62
|
+
"hs3_name": "-",
|
|
63
|
+
"factset_sector_code": "-",
|
|
64
|
+
"factset_sector_name": "-",
|
|
65
|
+
"factset_industry_code": "-",
|
|
66
|
+
"factset_industry_name": "-",
|
|
67
|
+
"date": "-",
|
|
68
|
+
"quarter_date": "评级日期",
|
|
69
|
+
"grade": "ESG等级",
|
|
70
|
+
"score": "-",
|
|
71
|
+
"env_score": "环境总评",
|
|
72
|
+
"env_grade": "-",
|
|
73
|
+
"social_score": "社会责任总评",
|
|
74
|
+
"social_grade": "-",
|
|
75
|
+
"governance_score": "治理总评",
|
|
76
|
+
"governance_grade": "-",
|
|
77
|
+
"change_status": "-",
|
|
78
|
+
"updated_time": "更新时间",
|
|
79
|
+
"created_time": "创建时间",
|
|
80
|
+
"esg_rating": "ESG评分",
|
|
81
|
+
},
|
|
82
|
+
inplace=True,
|
|
83
|
+
)
|
|
84
|
+
big_df = big_df[
|
|
85
|
+
[
|
|
86
|
+
"股票代码",
|
|
87
|
+
"ESG评分",
|
|
88
|
+
"环境总评",
|
|
89
|
+
"社会责任总评",
|
|
90
|
+
"治理总评",
|
|
91
|
+
"评级日期",
|
|
92
|
+
"交易市场",
|
|
93
|
+
]
|
|
94
|
+
]
|
|
95
|
+
big_df["评级日期"] = pd.to_datetime(big_df["评级日期"], errors="coerce").dt.date
|
|
96
|
+
big_df["环境总评"] = pd.to_numeric(big_df["环境总评"], errors="coerce")
|
|
97
|
+
big_df["社会责任总评"] = pd.to_numeric(big_df["社会责任总评"], errors="coerce")
|
|
98
|
+
big_df["治理总评"] = pd.to_numeric(big_df["治理总评"], errors="coerce")
|
|
99
|
+
return big_df
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def stock_esg_rft_sina() -> pd.DataFrame:
|
|
103
|
+
"""
|
|
104
|
+
新浪财经-ESG评级中心-ESG评级-路孚特
|
|
105
|
+
https://finance.sina.com.cn/esg/grade.shtml
|
|
106
|
+
:return: 路孚特
|
|
107
|
+
:rtype: pandas.DataFrame
|
|
108
|
+
"""
|
|
109
|
+
url = "https://global.finance.sina.com.cn/api/openapi.php/EsgService.getRftEsgStocks?p=1&num=20000"
|
|
110
|
+
r = requests.get(url)
|
|
111
|
+
data_json = r.json()
|
|
112
|
+
big_df = pd.DataFrame(data_json["result"]["data"]["data"])
|
|
113
|
+
big_df.rename(
|
|
114
|
+
columns={
|
|
115
|
+
"symbol": "股票代码",
|
|
116
|
+
"esg_score": "ESG评分",
|
|
117
|
+
"esg_score_date": "ESG评分日期",
|
|
118
|
+
"env_score": "环境总评",
|
|
119
|
+
"env_score_date": "环境总评日期",
|
|
120
|
+
"social_score": "社会责任总评",
|
|
121
|
+
"social_score_date": "社会责任总评日期",
|
|
122
|
+
"governance_score": "治理总评",
|
|
123
|
+
"governance_score_date": "治理总评日期",
|
|
124
|
+
"zy_score": "争议总评",
|
|
125
|
+
"zy_score_date": "争议总评日期",
|
|
126
|
+
"industry": "行业",
|
|
127
|
+
"exchange": "交易所",
|
|
128
|
+
},
|
|
129
|
+
inplace=True,
|
|
130
|
+
)
|
|
131
|
+
big_df = big_df[
|
|
132
|
+
[
|
|
133
|
+
"股票代码",
|
|
134
|
+
"ESG评分",
|
|
135
|
+
"ESG评分日期",
|
|
136
|
+
"环境总评",
|
|
137
|
+
"环境总评日期",
|
|
138
|
+
"社会责任总评",
|
|
139
|
+
"社会责任总评日期",
|
|
140
|
+
"治理总评",
|
|
141
|
+
"治理总评日期",
|
|
142
|
+
"争议总评",
|
|
143
|
+
"争议总评日期",
|
|
144
|
+
"行业",
|
|
145
|
+
"交易所",
|
|
146
|
+
]
|
|
147
|
+
]
|
|
148
|
+
big_df["ESG评分日期"] = pd.to_datetime(
|
|
149
|
+
big_df["ESG评分日期"], errors="coerce"
|
|
150
|
+
).dt.date
|
|
151
|
+
big_df["环境总评日期"] = pd.to_datetime(
|
|
152
|
+
big_df["环境总评日期"], errors="coerce"
|
|
153
|
+
).dt.date
|
|
154
|
+
big_df["社会责任总评日期"] = pd.to_datetime(
|
|
155
|
+
big_df["社会责任总评日期"], errors="coerce"
|
|
156
|
+
).dt.date
|
|
157
|
+
big_df["治理总评日期"] = pd.to_datetime(
|
|
158
|
+
big_df["治理总评日期"], errors="coerce"
|
|
159
|
+
).dt.date
|
|
160
|
+
big_df["争议总评日期"] = pd.to_datetime(
|
|
161
|
+
big_df["争议总评日期"], errors="coerce"
|
|
162
|
+
).dt.date
|
|
163
|
+
return big_df
|
|
164
|
+
|
|
165
|
+
|
|
15
166
|
def stock_esg_rate_sina() -> pd.DataFrame:
|
|
16
167
|
"""
|
|
17
168
|
新浪财经-ESG评级中心-ESG评级-ESG评级数据
|
|
@@ -22,7 +173,7 @@ def stock_esg_rate_sina() -> pd.DataFrame:
|
|
|
22
173
|
url = "https://global.finance.sina.com.cn/api/openapi.php/EsgService.getEsgStocks?page=1&num=200"
|
|
23
174
|
r = requests.get(url)
|
|
24
175
|
data_json = r.json()
|
|
25
|
-
page_num = math.ceil(data_json["result"]["data"]["info"]["total"] / 200)
|
|
176
|
+
page_num = math.ceil(int(data_json["result"]["data"]["info"]["total"]) / 200)
|
|
26
177
|
big_df = pd.DataFrame()
|
|
27
178
|
for page in tqdm(range(1, page_num + 1), leave=False):
|
|
28
179
|
url = f"https://global.finance.sina.com.cn/api/openapi.php/EsgService.getEsgStocks?page={page}&num=200"
|
|
@@ -39,7 +190,7 @@ def stock_esg_rate_sina() -> pd.DataFrame:
|
|
|
39
190
|
temp_df["market"] = data_json["result"]["data"]["info"]["stocks"][num][
|
|
40
191
|
"market"
|
|
41
192
|
]
|
|
42
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
193
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
43
194
|
|
|
44
195
|
big_df.rename(
|
|
45
196
|
columns={
|
|
@@ -65,6 +216,42 @@ def stock_esg_rate_sina() -> pd.DataFrame:
|
|
|
65
216
|
return big_df
|
|
66
217
|
|
|
67
218
|
|
|
219
|
+
def stock_esg_zd_sina() -> pd.DataFrame:
|
|
220
|
+
"""
|
|
221
|
+
新浪财经-ESG评级中心-ESG评级-秩鼎
|
|
222
|
+
https://finance.sina.com.cn/esg/grade.shtml
|
|
223
|
+
:return: 秩鼎
|
|
224
|
+
:rtype: pandas.DataFrame
|
|
225
|
+
"""
|
|
226
|
+
url = "https://global.finance.sina.com.cn/api/openapi.php/EsgService.getZdEsgStocks?p=1&num=20000"
|
|
227
|
+
r = requests.get(url)
|
|
228
|
+
data_json = r.json()
|
|
229
|
+
big_df = pd.DataFrame(data_json["result"]["data"]["data"])
|
|
230
|
+
big_df.rename(
|
|
231
|
+
columns={
|
|
232
|
+
"ticker": "股票代码",
|
|
233
|
+
"esg_score": "ESG评分",
|
|
234
|
+
"report_date": "评分日期",
|
|
235
|
+
"environmental_score": "环境总评",
|
|
236
|
+
"social_score": "社会责任总评",
|
|
237
|
+
"governance_score": "治理总评",
|
|
238
|
+
},
|
|
239
|
+
inplace=True,
|
|
240
|
+
)
|
|
241
|
+
big_df = big_df[
|
|
242
|
+
[
|
|
243
|
+
"股票代码",
|
|
244
|
+
"ESG评分",
|
|
245
|
+
"环境总评",
|
|
246
|
+
"社会责任总评",
|
|
247
|
+
"治理总评",
|
|
248
|
+
"评分日期",
|
|
249
|
+
]
|
|
250
|
+
]
|
|
251
|
+
big_df["评分日期"] = pd.to_datetime(big_df["评分日期"], errors="coerce").dt.date
|
|
252
|
+
return big_df
|
|
253
|
+
|
|
254
|
+
|
|
68
255
|
def stock_esg_hz_sina() -> pd.DataFrame:
|
|
69
256
|
"""
|
|
70
257
|
新浪财经-ESG评级中心-ESG评级-华证指数
|
|
@@ -72,10 +259,19 @@ def stock_esg_hz_sina() -> pd.DataFrame:
|
|
|
72
259
|
:return: 华证指数
|
|
73
260
|
:rtype: pandas.DataFrame
|
|
74
261
|
"""
|
|
75
|
-
url = "https://global.finance.sina.com.cn/api/openapi.php/EsgService.getHzEsgStocks
|
|
76
|
-
|
|
262
|
+
url = "https://global.finance.sina.com.cn/api/openapi.php/EsgService.getHzEsgStocks"
|
|
263
|
+
params = {"p": 1, "num": "100"}
|
|
264
|
+
r = requests.get(url, params=params)
|
|
77
265
|
data_json = r.json()
|
|
78
|
-
|
|
266
|
+
total_page = math.ceil(int(data_json["result"]["data"]["total"]) / 100)
|
|
267
|
+
big_df = pd.DataFrame()
|
|
268
|
+
for page in tqdm(range(1, total_page + 1), leave=False):
|
|
269
|
+
params = {"p": str(page), "num": "100"}
|
|
270
|
+
r = requests.get(url, params=params)
|
|
271
|
+
data_json = r.json()
|
|
272
|
+
temp_df = pd.DataFrame(data_json["result"]["data"]["data"])
|
|
273
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
274
|
+
|
|
79
275
|
big_df.rename(
|
|
80
276
|
columns={
|
|
81
277
|
"date": "日期",
|
|
@@ -109,17 +305,26 @@ def stock_esg_hz_sina() -> pd.DataFrame:
|
|
|
109
305
|
"公司治理等级",
|
|
110
306
|
]
|
|
111
307
|
]
|
|
112
|
-
big_df[
|
|
113
|
-
big_df[
|
|
114
|
-
big_df[
|
|
115
|
-
big_df[
|
|
116
|
-
big_df[
|
|
308
|
+
big_df["日期"] = pd.to_datetime(big_df["日期"], errors="coerce").dt.date
|
|
309
|
+
big_df["ESG评分"] = pd.to_numeric(big_df["ESG评分"], errors="coerce")
|
|
310
|
+
big_df["环境"] = pd.to_numeric(big_df["环境"], errors="coerce")
|
|
311
|
+
big_df["社会"] = pd.to_numeric(big_df["社会"], errors="coerce")
|
|
312
|
+
big_df["公司治理"] = pd.to_numeric(big_df["公司治理"], errors="coerce")
|
|
117
313
|
return big_df
|
|
118
314
|
|
|
119
315
|
|
|
120
316
|
if __name__ == "__main__":
|
|
317
|
+
stock_esg_msci_sina_df = stock_esg_msci_sina()
|
|
318
|
+
print(stock_esg_msci_sina_df)
|
|
319
|
+
|
|
320
|
+
stock_esg_rft_sina_df = stock_esg_rft_sina()
|
|
321
|
+
print(stock_esg_rft_sina_df)
|
|
322
|
+
|
|
121
323
|
stock_esg_rate_sina_df = stock_esg_rate_sina()
|
|
122
324
|
print(stock_esg_rate_sina_df)
|
|
123
325
|
|
|
326
|
+
stock_esg_zd_sina_df = stock_esg_zd_sina()
|
|
327
|
+
print(stock_esg_zd_sina_df)
|
|
328
|
+
|
|
124
329
|
stock_esg_hz_sina_df = stock_esg_hz_sina()
|
|
125
330
|
print(stock_esg_hz_sina_df)
|
|
@@ -5,12 +5,13 @@ Date: 2023/4/7 15:22
|
|
|
5
5
|
Desc: 东方财富网-数据中心-年报季报-分红送配
|
|
6
6
|
https://data.eastmoney.com/yjfp/
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import pandas as pd
|
|
9
10
|
import requests
|
|
10
|
-
from tqdm import
|
|
11
|
+
from akshare.utils.tqdm import get_tqdm
|
|
11
12
|
|
|
12
13
|
|
|
13
|
-
def stock_fhps_em(date: str = "
|
|
14
|
+
def stock_fhps_em(date: str = "20231231") -> pd.DataFrame:
|
|
14
15
|
"""
|
|
15
16
|
东方财富网-数据中心-年报季报-分红送配
|
|
16
17
|
https://data.eastmoney.com/yjfp/
|
|
@@ -19,6 +20,10 @@ def stock_fhps_em(date: str = "20210630") -> pd.DataFrame:
|
|
|
19
20
|
:return: 分红送配
|
|
20
21
|
:rtype: pandas.DataFrame
|
|
21
22
|
"""
|
|
23
|
+
import warnings
|
|
24
|
+
|
|
25
|
+
warnings.simplefilter(action="ignore", category=FutureWarning)
|
|
26
|
+
|
|
22
27
|
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
|
|
23
28
|
params = {
|
|
24
29
|
"sortColumns": "PLAN_NOTICE_DATE",
|
|
@@ -38,12 +43,13 @@ def stock_fhps_em(date: str = "20210630") -> pd.DataFrame:
|
|
|
38
43
|
data_json = r.json()
|
|
39
44
|
total_pages = int(data_json["result"]["pages"])
|
|
40
45
|
big_df = pd.DataFrame()
|
|
46
|
+
tqdm = get_tqdm()
|
|
41
47
|
for page in tqdm(range(1, total_pages + 1), leave=False):
|
|
42
48
|
params.update({"pageNumber": page})
|
|
43
49
|
r = requests.get(url, params=params)
|
|
44
50
|
data_json = r.json()
|
|
45
51
|
temp_df = pd.DataFrame(data_json["result"]["data"])
|
|
46
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
52
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
47
53
|
|
|
48
54
|
big_df.columns = [
|
|
49
55
|
"_",
|
|
@@ -99,22 +105,35 @@ def stock_fhps_em(date: str = "20210630") -> pd.DataFrame:
|
|
|
99
105
|
"最新公告日期",
|
|
100
106
|
]
|
|
101
107
|
]
|
|
102
|
-
big_df["送转股份-送转总比例"] = pd.to_numeric(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
big_df["
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
big_df["
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
big_df["
|
|
112
|
-
|
|
108
|
+
big_df["送转股份-送转总比例"] = pd.to_numeric(
|
|
109
|
+
big_df["送转股份-送转总比例"], errors="coerce"
|
|
110
|
+
)
|
|
111
|
+
big_df["送转股份-送转比例"] = pd.to_numeric(
|
|
112
|
+
big_df["送转股份-送转比例"], errors="coerce"
|
|
113
|
+
)
|
|
114
|
+
big_df["送转股份-转股比例"] = pd.to_numeric(
|
|
115
|
+
big_df["送转股份-转股比例"], errors="coerce"
|
|
116
|
+
)
|
|
117
|
+
big_df["现金分红-现金分红比例"] = pd.to_numeric(
|
|
118
|
+
big_df["现金分红-现金分红比例"], errors="coerce"
|
|
119
|
+
)
|
|
120
|
+
big_df["现金分红-股息率"] = pd.to_numeric(
|
|
121
|
+
big_df["现金分红-股息率"], errors="coerce"
|
|
122
|
+
)
|
|
123
|
+
big_df["每股收益"] = pd.to_numeric(big_df["每股收益"], errors="coerce")
|
|
124
|
+
big_df["每股净资产"] = pd.to_numeric(big_df["每股净资产"], errors="coerce")
|
|
125
|
+
big_df["每股公积金"] = pd.to_numeric(big_df["每股公积金"], errors="coerce")
|
|
126
|
+
big_df["每股未分配利润"] = pd.to_numeric(big_df["每股未分配利润"], errors="coerce")
|
|
127
|
+
big_df["净利润同比增长"] = pd.to_numeric(big_df["净利润同比增长"], errors="coerce")
|
|
128
|
+
big_df["总股本"] = pd.to_numeric(big_df["总股本"], errors="coerce")
|
|
113
129
|
|
|
114
130
|
big_df["预案公告日"] = pd.to_datetime(big_df["预案公告日"], errors="coerce").dt.date
|
|
115
131
|
big_df["股权登记日"] = pd.to_datetime(big_df["股权登记日"], errors="coerce").dt.date
|
|
116
132
|
big_df["除权除息日"] = pd.to_datetime(big_df["除权除息日"], errors="coerce").dt.date
|
|
117
|
-
big_df["最新公告日期"] = pd.to_datetime(
|
|
133
|
+
big_df["最新公告日期"] = pd.to_datetime(
|
|
134
|
+
big_df["最新公告日期"], errors="coerce"
|
|
135
|
+
).dt.date
|
|
136
|
+
big_df.sort_values(["最新公告日期"], inplace=True, ignore_index=True)
|
|
118
137
|
return big_df
|
|
119
138
|
|
|
120
139
|
|
|
@@ -146,12 +165,13 @@ def stock_fhps_detail_em(symbol: str = "300073") -> pd.DataFrame:
|
|
|
146
165
|
data_json = r.json()
|
|
147
166
|
total_pages = int(data_json["result"]["pages"])
|
|
148
167
|
big_df = pd.DataFrame()
|
|
168
|
+
tqdm = get_tqdm()
|
|
149
169
|
for page in tqdm(range(1, total_pages + 1), leave=False):
|
|
150
170
|
params.update({"pageNumber": page})
|
|
151
171
|
r = requests.get(url, params=params)
|
|
152
172
|
data_json = r.json()
|
|
153
173
|
temp_df = pd.DataFrame(data_json["result"]["data"])
|
|
154
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
174
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
155
175
|
|
|
156
176
|
big_df.columns = [
|
|
157
177
|
"_",
|
|
@@ -209,29 +229,44 @@ def stock_fhps_detail_em(symbol: str = "300073") -> pd.DataFrame:
|
|
|
209
229
|
]
|
|
210
230
|
]
|
|
211
231
|
big_df["报告期"] = pd.to_datetime(big_df["报告期"], errors="coerce").dt.date
|
|
212
|
-
big_df["业绩披露日期"] = pd.to_datetime(
|
|
232
|
+
big_df["业绩披露日期"] = pd.to_datetime(
|
|
233
|
+
big_df["业绩披露日期"], errors="coerce"
|
|
234
|
+
).dt.date
|
|
213
235
|
big_df["预案公告日"] = pd.to_datetime(big_df["预案公告日"], errors="coerce").dt.date
|
|
214
236
|
big_df["股权登记日"] = pd.to_datetime(big_df["股权登记日"], errors="coerce").dt.date
|
|
215
237
|
big_df["除权除息日"] = pd.to_datetime(big_df["除权除息日"], errors="coerce").dt.date
|
|
216
|
-
big_df["最新公告日期"] = pd.to_datetime(
|
|
238
|
+
big_df["最新公告日期"] = pd.to_datetime(
|
|
239
|
+
big_df["最新公告日期"], errors="coerce"
|
|
240
|
+
).dt.date
|
|
217
241
|
|
|
218
|
-
big_df["送转股份-送转总比例"] = pd.to_numeric(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
big_df["
|
|
222
|
-
|
|
242
|
+
big_df["送转股份-送转总比例"] = pd.to_numeric(
|
|
243
|
+
big_df["送转股份-送转总比例"], errors="coerce"
|
|
244
|
+
)
|
|
245
|
+
big_df["送转股份-送股比例"] = pd.to_numeric(
|
|
246
|
+
big_df["送转股份-送股比例"], errors="coerce"
|
|
247
|
+
)
|
|
248
|
+
big_df["送转股份-转股比例"] = pd.to_numeric(
|
|
249
|
+
big_df["送转股份-转股比例"], errors="coerce"
|
|
250
|
+
)
|
|
251
|
+
big_df["现金分红-现金分红比例"] = pd.to_numeric(
|
|
252
|
+
big_df["现金分红-现金分红比例"], errors="coerce"
|
|
253
|
+
)
|
|
254
|
+
big_df["现金分红-股息率"] = pd.to_numeric(
|
|
255
|
+
big_df["现金分红-股息率"], errors="coerce"
|
|
256
|
+
)
|
|
223
257
|
big_df["每股收益"] = pd.to_numeric(big_df["每股收益"], errors="coerce")
|
|
224
258
|
big_df["每股净资产"] = pd.to_numeric(big_df["每股净资产"], errors="coerce")
|
|
225
259
|
big_df["每股公积金"] = pd.to_numeric(big_df["每股公积金"], errors="coerce")
|
|
226
260
|
big_df["每股未分配利润"] = pd.to_numeric(big_df["每股未分配利润"], errors="coerce")
|
|
227
261
|
big_df["净利润同比增长"] = pd.to_numeric(big_df["净利润同比增长"], errors="coerce")
|
|
228
262
|
big_df["总股本"] = pd.to_numeric(big_df["总股本"], errors="coerce")
|
|
263
|
+
big_df.sort_values(["报告期"], inplace=True, ignore_index=True)
|
|
229
264
|
return big_df
|
|
230
265
|
|
|
231
266
|
|
|
232
267
|
if __name__ == "__main__":
|
|
233
|
-
stock_fhps_em_df = stock_fhps_em(date="
|
|
268
|
+
stock_fhps_em_df = stock_fhps_em(date="20231231")
|
|
234
269
|
print(stock_fhps_em_df)
|
|
235
270
|
|
|
236
|
-
stock_fhps_detail_em_df = stock_fhps_detail_em(symbol="
|
|
271
|
+
stock_fhps_detail_em_df = stock_fhps_detail_em(symbol="000005")
|
|
237
272
|
print(stock_fhps_detail_em_df)
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
5
|
-
Desc:
|
|
4
|
+
Date: 2024/5/13 10:30
|
|
5
|
+
Desc: 同花顺-分红情况
|
|
6
6
|
https://basic.10jqka.com.cn/new/603444/bonus.html
|
|
7
7
|
"""
|
|
8
|
+
|
|
9
|
+
from io import StringIO
|
|
10
|
+
|
|
8
11
|
import pandas as pd
|
|
9
12
|
import requests
|
|
10
13
|
|
|
11
14
|
|
|
12
15
|
def stock_fhps_detail_ths(symbol: str = "603444") -> pd.DataFrame:
|
|
13
16
|
"""
|
|
14
|
-
|
|
17
|
+
同花顺-分红情况
|
|
15
18
|
https://basic.10jqka.com.cn/new/603444/bonus.html
|
|
16
19
|
:param symbol: 股票代码
|
|
17
20
|
:type symbol: str
|
|
@@ -21,12 +24,28 @@ def stock_fhps_detail_ths(symbol: str = "603444") -> pd.DataFrame:
|
|
|
21
24
|
url = f"https://basic.10jqka.com.cn/new/{symbol}/bonus.html"
|
|
22
25
|
headers = {
|
|
23
26
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
28
|
+
"Chrome/89.0.4389.90 Safari/537.36",
|
|
26
29
|
}
|
|
27
30
|
r = requests.get(url, headers=headers)
|
|
28
31
|
r.encoding = "gbk"
|
|
29
|
-
temp_df = pd.read_html(r.text)[0]
|
|
32
|
+
temp_df = pd.read_html(StringIO(r.text))[0]
|
|
33
|
+
temp_df["董事会日期"] = pd.to_datetime(
|
|
34
|
+
temp_df["董事会日期"], format="%Y-%m-%d", errors="coerce"
|
|
35
|
+
).dt.date
|
|
36
|
+
temp_df["股东大会预案公告日期"] = pd.to_datetime(
|
|
37
|
+
temp_df["股东大会预案公告日期"], format="%Y-%m-%d", errors="coerce"
|
|
38
|
+
).dt.date
|
|
39
|
+
temp_df["实施公告日"] = pd.to_datetime(
|
|
40
|
+
temp_df["实施公告日"], format="%Y-%m-%d", errors="coerce"
|
|
41
|
+
).dt.date
|
|
42
|
+
temp_df["A股股权登记日"] = pd.to_datetime(
|
|
43
|
+
temp_df["A股股权登记日"], format="%Y-%m-%d", errors="coerce"
|
|
44
|
+
).dt.date
|
|
45
|
+
temp_df["A股除权除息日"] = pd.to_datetime(
|
|
46
|
+
temp_df["A股除权除息日"], format="%Y-%m-%d", errors="coerce"
|
|
47
|
+
).dt.date
|
|
48
|
+
temp_df.sort_values(by=["董事会日期"], ignore_index=True, inplace=True)
|
|
30
49
|
return temp_df
|
|
31
50
|
|
|
32
51
|
|