akshare 1.12.95__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 +446 -139
- 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_convert.py +40 -16
- akshare/bond/bond_info_cm.py +28 -8
- akshare/bond/bond_issue_cninfo.py +73 -30
- akshare/bond/{bond_zh_cov_sina.py → bond_zh_cov.py} +41 -17
- 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 +20 -19
- 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_lof_em.py +10 -8
- 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 +73 -50
- 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_hog.py +27 -26
- 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 +17 -14
- 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_ask_bid_em.py +27 -3
- 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 +164 -111
- 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.95.dist-info → akshare-1.15.72.dist-info}/METADATA +52 -69
- akshare-1.15.72.dist-info/RECORD +385 -0
- {akshare-1.12.95.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.95.dist-info/RECORD +0 -374
- {akshare-1.12.95.dist-info → akshare-1.15.72.dist-info}/LICENSE +0 -0
- {akshare-1.12.95.dist-info → akshare-1.15.72.dist-info}/top_level.txt +0 -0
akshare/bond/bond_info_cm.py
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/5/10 14:00
|
|
5
5
|
Desc: 中国外汇交易中心暨全国银行间同业拆借中心
|
|
6
6
|
https://www.chinamoney.com.cn/chinese/scsjzqxx/
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import functools
|
|
9
10
|
|
|
10
11
|
import pandas as pd
|
|
11
12
|
import requests
|
|
12
|
-
from tqdm import
|
|
13
|
+
from akshare.utils.tqdm import get_tqdm
|
|
14
|
+
from akshare.bond.bond_china import bond_china_close_return_map
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
@functools.lru_cache()
|
|
@@ -22,10 +24,12 @@ def bond_info_cm_query(symbol: str = "评级等级") -> pd.DataFrame:
|
|
|
22
24
|
:return: 查询相关指标的参数
|
|
23
25
|
:rtype: pandas.DataFrame
|
|
24
26
|
"""
|
|
27
|
+
bond_china_close_return_map()
|
|
25
28
|
if symbol == "主承销商":
|
|
26
29
|
url = "https://www.chinamoney.com.cn/ags/ms/cm-u-bond-md/EntyFullNameSearchCondition"
|
|
27
30
|
headers = {
|
|
28
|
-
|
|
31
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
32
|
+
"Chrome/109.0.0.0 Safari/537.36"
|
|
29
33
|
}
|
|
30
34
|
r = requests.post(url, headers=headers)
|
|
31
35
|
data_json = r.json()
|
|
@@ -42,7 +46,8 @@ def bond_info_cm_query(symbol: str = "评级等级") -> pd.DataFrame:
|
|
|
42
46
|
}
|
|
43
47
|
url = "https://www.chinamoney.com.cn/ags/ms/cm-u-bond-md/BondBaseInfoSearchCondition"
|
|
44
48
|
headers = {
|
|
45
|
-
|
|
49
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
50
|
+
"Chrome/109.0.0.0 Safari/537.36"
|
|
46
51
|
}
|
|
47
52
|
r = requests.post(url, headers=headers)
|
|
48
53
|
data_json = r.json()
|
|
@@ -88,6 +93,7 @@ def bond_info_cm(
|
|
|
88
93
|
:return: 信息查询结果
|
|
89
94
|
:rtype: pandas.DataFrame
|
|
90
95
|
"""
|
|
96
|
+
bond_china_close_return_map()
|
|
91
97
|
if bond_type:
|
|
92
98
|
bond_type_df = bond_info_cm_query(symbol="债券类型")
|
|
93
99
|
bond_type_df_value = bond_type_df[bond_type_df["name"] == bond_type][
|
|
@@ -127,18 +133,20 @@ def bond_info_cm(
|
|
|
127
133
|
"rtngShrt": grade,
|
|
128
134
|
}
|
|
129
135
|
headers = {
|
|
130
|
-
|
|
136
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
137
|
+
"Chrome/109.0.0.0 Safari/537.36"
|
|
131
138
|
}
|
|
132
139
|
r = requests.post(url, data=payload, headers=headers)
|
|
133
140
|
data_json = r.json()
|
|
134
141
|
total_page = data_json["data"]["pageTotal"]
|
|
135
142
|
big_df = pd.DataFrame()
|
|
143
|
+
tqdm = get_tqdm()
|
|
136
144
|
for page in tqdm(range(1, total_page + 1), leave=False):
|
|
137
145
|
payload.update({"pageNo": page})
|
|
138
146
|
r = requests.post(url, data=payload, headers=headers)
|
|
139
147
|
data_json = r.json()
|
|
140
148
|
temp_df = pd.DataFrame(data_json["data"]["resultList"])
|
|
141
|
-
big_df = pd.concat([big_df, temp_df], ignore_index=True)
|
|
149
|
+
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
142
150
|
big_df.rename(
|
|
143
151
|
columns={
|
|
144
152
|
"bondDefinedCode": "查询代码",
|
|
@@ -156,7 +164,17 @@ def bond_info_cm(
|
|
|
156
164
|
},
|
|
157
165
|
inplace=True,
|
|
158
166
|
)
|
|
159
|
-
big_df = big_df[
|
|
167
|
+
big_df = big_df[
|
|
168
|
+
[
|
|
169
|
+
"债券简称",
|
|
170
|
+
"债券代码",
|
|
171
|
+
"发行人/受托机构",
|
|
172
|
+
"债券类型",
|
|
173
|
+
"发行日期",
|
|
174
|
+
"最新债项评级",
|
|
175
|
+
"查询代码",
|
|
176
|
+
]
|
|
177
|
+
]
|
|
160
178
|
return big_df
|
|
161
179
|
|
|
162
180
|
|
|
@@ -170,12 +188,14 @@ def bond_info_detail_cm(symbol: str = "淮安农商行CDSD2022021012") -> pd.Dat
|
|
|
170
188
|
:return: 债券详情
|
|
171
189
|
:rtype: pandas.DataFrame
|
|
172
190
|
"""
|
|
191
|
+
bond_china_close_return_map()
|
|
173
192
|
url = "https://www.chinamoney.com.cn/ags/ms/cm-u-bond-md/BondDetailInfo"
|
|
174
193
|
inner_bond_info_cm_df = bond_info_cm(bond_name=symbol)
|
|
175
194
|
bond_code = inner_bond_info_cm_df["查询代码"].values[0]
|
|
176
195
|
payload = {"bondDefinedCode": bond_code}
|
|
177
196
|
headers = {
|
|
178
|
-
|
|
197
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
198
|
+
"Chrome/109.0.0.0 Safari/537.36"
|
|
179
199
|
}
|
|
180
200
|
r = requests.post(url, data=payload, headers=headers)
|
|
181
201
|
data_json = r.json()
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
# -*- coding:utf-8 -*-
|
|
2
2
|
# !/usr/bin/env python
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/6/19 22:00
|
|
5
5
|
Desc: 巨潮资讯-数据中心-专题统计-债券报表-债券发行
|
|
6
6
|
http://webapi.cninfo.com.cn/#/thematicStatistics
|
|
7
7
|
"""
|
|
8
|
-
import time
|
|
9
8
|
|
|
10
9
|
import pandas as pd
|
|
11
10
|
import requests
|
|
12
|
-
|
|
11
|
+
import py_mini_racer
|
|
13
12
|
|
|
14
13
|
from akshare.datasets import get_ths_js
|
|
15
14
|
|
|
@@ -23,7 +22,7 @@ def _get_file_content_cninfo(file: str = "cninfo.js") -> str:
|
|
|
23
22
|
:rtype: str
|
|
24
23
|
"""
|
|
25
24
|
setting_file_path = get_ths_js(file)
|
|
26
|
-
with open(setting_file_path) as f:
|
|
25
|
+
with open(setting_file_path, encoding="utf-8") as f:
|
|
27
26
|
file_data = f.read()
|
|
28
27
|
return file_data
|
|
29
28
|
|
|
@@ -58,7 +57,8 @@ def bond_treasure_issue_cninfo(
|
|
|
58
57
|
"Pragma": "no-cache",
|
|
59
58
|
"Proxy-Connection": "keep-alive",
|
|
60
59
|
"Referer": "http://webapi.cninfo.com.cn/",
|
|
61
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
60
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
61
|
+
"Chrome/93.0.4577.63 Safari/537.36",
|
|
62
62
|
"X-Requested-With": "XMLHttpRequest",
|
|
63
63
|
}
|
|
64
64
|
params = {
|
|
@@ -107,8 +107,12 @@ def bond_treasure_issue_cninfo(
|
|
|
107
107
|
"债券名称",
|
|
108
108
|
]
|
|
109
109
|
]
|
|
110
|
-
temp_df["发行起始日"] = pd.to_datetime(
|
|
111
|
-
|
|
110
|
+
temp_df["发行起始日"] = pd.to_datetime(
|
|
111
|
+
temp_df["发行起始日"], errors="coerce"
|
|
112
|
+
).dt.date
|
|
113
|
+
temp_df["发行终止日"] = pd.to_datetime(
|
|
114
|
+
temp_df["发行终止日"], errors="coerce"
|
|
115
|
+
).dt.date
|
|
112
116
|
temp_df["缴款日"] = pd.to_datetime(temp_df["缴款日"], errors="coerce").dt.date
|
|
113
117
|
temp_df["公告日期"] = pd.to_datetime(temp_df["公告日期"], errors="coerce").dt.date
|
|
114
118
|
temp_df["计划发行总量"] = pd.to_numeric(temp_df["计划发行总量"], errors="coerce")
|
|
@@ -133,7 +137,6 @@ def bond_local_government_issue_cninfo(
|
|
|
133
137
|
:rtype: pandas.DataFrame
|
|
134
138
|
"""
|
|
135
139
|
url = "http://webapi.cninfo.com.cn/api/sysapi/p_sysapi1121"
|
|
136
|
-
random_time_str = str(int(time.time()))
|
|
137
140
|
js_code = py_mini_racer.MiniRacer()
|
|
138
141
|
js_content = _get_file_content_cninfo("cninfo.js")
|
|
139
142
|
js_code.eval(js_content)
|
|
@@ -150,7 +153,8 @@ def bond_local_government_issue_cninfo(
|
|
|
150
153
|
"Pragma": "no-cache",
|
|
151
154
|
"Proxy-Connection": "keep-alive",
|
|
152
155
|
"Referer": "http://webapi.cninfo.com.cn/",
|
|
153
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
156
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
157
|
+
"Chrome/93.0.4577.63 Safari/537.36",
|
|
154
158
|
"X-Requested-With": "XMLHttpRequest",
|
|
155
159
|
}
|
|
156
160
|
params = {
|
|
@@ -199,8 +203,12 @@ def bond_local_government_issue_cninfo(
|
|
|
199
203
|
"债券名称",
|
|
200
204
|
]
|
|
201
205
|
]
|
|
202
|
-
temp_df["发行起始日"] = pd.to_datetime(
|
|
203
|
-
|
|
206
|
+
temp_df["发行起始日"] = pd.to_datetime(
|
|
207
|
+
temp_df["发行起始日"], errors="coerce"
|
|
208
|
+
).dt.date
|
|
209
|
+
temp_df["发行终止日"] = pd.to_datetime(
|
|
210
|
+
temp_df["发行终止日"], errors="coerce"
|
|
211
|
+
).dt.date
|
|
204
212
|
temp_df["缴款日"] = pd.to_datetime(temp_df["缴款日"], errors="coerce").dt.date
|
|
205
213
|
temp_df["公告日期"] = pd.to_datetime(temp_df["公告日期"], errors="coerce").dt.date
|
|
206
214
|
temp_df["计划发行总量"] = pd.to_numeric(temp_df["计划发行总量"], errors="coerce")
|
|
@@ -241,7 +249,8 @@ def bond_corporate_issue_cninfo(
|
|
|
241
249
|
"Pragma": "no-cache",
|
|
242
250
|
"Proxy-Connection": "keep-alive",
|
|
243
251
|
"Referer": "http://webapi.cninfo.com.cn/",
|
|
244
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
252
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
253
|
+
"Chrome/93.0.4577.63 Safari/537.36",
|
|
245
254
|
"X-Requested-With": "XMLHttpRequest",
|
|
246
255
|
}
|
|
247
256
|
params = {
|
|
@@ -295,8 +304,12 @@ def bond_corporate_issue_cninfo(
|
|
|
295
304
|
]
|
|
296
305
|
]
|
|
297
306
|
temp_df["公告日期"] = pd.to_datetime(temp_df["公告日期"], errors="coerce").dt.date
|
|
298
|
-
temp_df["交易所网上发行起始日"] = pd.to_datetime(
|
|
299
|
-
|
|
307
|
+
temp_df["交易所网上发行起始日"] = pd.to_datetime(
|
|
308
|
+
temp_df["交易所网上发行起始日"], errors="coerce"
|
|
309
|
+
).dt.date
|
|
310
|
+
temp_df["交易所网上发行终止日"] = pd.to_datetime(
|
|
311
|
+
temp_df["交易所网上发行终止日"], errors="coerce"
|
|
312
|
+
).dt.date
|
|
300
313
|
temp_df["计划发行总量"] = pd.to_numeric(temp_df["计划发行总量"], errors="coerce")
|
|
301
314
|
temp_df["实际发行总量"] = pd.to_numeric(temp_df["实际发行总量"], errors="coerce")
|
|
302
315
|
temp_df["发行面值"] = pd.to_numeric(temp_df["发行面值"], errors="coerce")
|
|
@@ -336,7 +349,8 @@ def bond_cov_issue_cninfo(
|
|
|
336
349
|
"Pragma": "no-cache",
|
|
337
350
|
"Proxy-Connection": "keep-alive",
|
|
338
351
|
"Referer": "http://webapi.cninfo.com.cn/",
|
|
339
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
352
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
353
|
+
"Chrome/93.0.4577.63 Safari/537.36",
|
|
340
354
|
"X-Requested-With": "XMLHttpRequest",
|
|
341
355
|
}
|
|
342
356
|
params = {
|
|
@@ -418,23 +432,47 @@ def bond_cov_issue_cninfo(
|
|
|
418
432
|
]
|
|
419
433
|
]
|
|
420
434
|
temp_df["公告日期"] = pd.to_datetime(temp_df["公告日期"], errors="coerce").dt.date
|
|
421
|
-
temp_df["发行起始日"] = pd.to_datetime(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
temp_df["
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
temp_df["
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
temp_df["
|
|
435
|
+
temp_df["发行起始日"] = pd.to_datetime(
|
|
436
|
+
temp_df["发行起始日"], errors="coerce"
|
|
437
|
+
).dt.date
|
|
438
|
+
temp_df["发行终止日"] = pd.to_datetime(
|
|
439
|
+
temp_df["发行终止日"], errors="coerce"
|
|
440
|
+
).dt.date
|
|
441
|
+
temp_df["转股开始日期"] = pd.to_datetime(
|
|
442
|
+
temp_df["转股开始日期"], errors="coerce"
|
|
443
|
+
).dt.date
|
|
444
|
+
temp_df["转股终止日期"] = pd.to_datetime(
|
|
445
|
+
temp_df["转股终止日期"], errors="coerce"
|
|
446
|
+
).dt.date
|
|
447
|
+
temp_df["转股终止日期"] = pd.to_datetime(
|
|
448
|
+
temp_df["转股终止日期"], errors="coerce"
|
|
449
|
+
).dt.date
|
|
450
|
+
temp_df["网上申购日期"] = pd.to_datetime(
|
|
451
|
+
temp_df["网上申购日期"], errors="coerce"
|
|
452
|
+
).dt.date
|
|
453
|
+
temp_df["网上申购中签结果公告日及退款日"] = pd.to_datetime(
|
|
454
|
+
temp_df["网上申购中签结果公告日及退款日"], errors="coerce"
|
|
455
|
+
).dt.date
|
|
456
|
+
temp_df["债权登记日"] = pd.to_datetime(
|
|
457
|
+
temp_df["债权登记日"], errors="coerce"
|
|
458
|
+
).dt.date
|
|
459
|
+
temp_df["优先申购日"] = pd.to_datetime(
|
|
460
|
+
temp_df["优先申购日"], errors="coerce"
|
|
461
|
+
).dt.date
|
|
462
|
+
temp_df["优先申购缴款日"] = pd.to_datetime(
|
|
463
|
+
temp_df["优先申购缴款日"], errors="coerce"
|
|
464
|
+
).dt.date
|
|
431
465
|
temp_df["计划发行总量"] = pd.to_numeric(temp_df["计划发行总量"], errors="coerce")
|
|
432
466
|
temp_df["实际发行总量"] = pd.to_numeric(temp_df["实际发行总量"], errors="coerce")
|
|
433
467
|
temp_df["发行面值"] = pd.to_numeric(temp_df["发行面值"], errors="coerce")
|
|
434
468
|
temp_df["发行价格"] = pd.to_numeric(temp_df["发行价格"], errors="coerce")
|
|
435
469
|
temp_df["初始转股价格"] = pd.to_numeric(temp_df["初始转股价格"], errors="coerce")
|
|
436
|
-
temp_df["网上申购数量上限"] = pd.to_numeric(
|
|
437
|
-
|
|
470
|
+
temp_df["网上申购数量上限"] = pd.to_numeric(
|
|
471
|
+
temp_df["网上申购数量上限"], errors="coerce"
|
|
472
|
+
)
|
|
473
|
+
temp_df["网上申购数量下限"] = pd.to_numeric(
|
|
474
|
+
temp_df["网上申购数量下限"], errors="coerce"
|
|
475
|
+
)
|
|
438
476
|
temp_df["网上申购单位"] = pd.to_numeric(temp_df["网上申购单位"], errors="coerce")
|
|
439
477
|
temp_df["配售价格"] = pd.to_numeric(temp_df["配售价格"], errors="coerce")
|
|
440
478
|
return temp_df
|
|
@@ -464,7 +502,8 @@ def bond_cov_stock_issue_cninfo() -> pd.DataFrame:
|
|
|
464
502
|
"Pragma": "no-cache",
|
|
465
503
|
"Proxy-Connection": "keep-alive",
|
|
466
504
|
"Referer": "http://webapi.cninfo.com.cn/",
|
|
467
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
505
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
506
|
+
"Chrome/93.0.4577.63 Safari/537.36",
|
|
468
507
|
"X-Requested-With": "XMLHttpRequest",
|
|
469
508
|
}
|
|
470
509
|
r = requests.post(url, headers=headers)
|
|
@@ -500,8 +539,12 @@ def bond_cov_stock_issue_cninfo() -> pd.DataFrame:
|
|
|
500
539
|
]
|
|
501
540
|
]
|
|
502
541
|
temp_df["公告日期"] = pd.to_datetime(temp_df["公告日期"], errors="coerce").dt.date
|
|
503
|
-
temp_df["自愿转换期起始日"] = pd.to_datetime(
|
|
504
|
-
|
|
542
|
+
temp_df["自愿转换期起始日"] = pd.to_datetime(
|
|
543
|
+
temp_df["自愿转换期起始日"], errors="coerce"
|
|
544
|
+
).dt.date
|
|
545
|
+
temp_df["自愿转换期终止日"] = pd.to_datetime(
|
|
546
|
+
temp_df["自愿转换期终止日"], errors="coerce"
|
|
547
|
+
).dt.date
|
|
505
548
|
temp_df["转股价格"] = pd.to_numeric(temp_df["转股价格"], errors="coerce")
|
|
506
549
|
return temp_df
|
|
507
550
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/
|
|
4
|
+
Date: 2024/3/20 17:50
|
|
5
5
|
Desc: 新浪财经-债券-沪深可转债-实时行情数据和历史行情数据
|
|
6
6
|
https://vip.stock.finance.sina.com.cn/mkt/#hskzz_z
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import datetime
|
|
9
10
|
import re
|
|
10
11
|
|
|
11
12
|
import pandas as pd
|
|
12
13
|
import requests
|
|
13
|
-
|
|
14
|
-
from tqdm import tqdm
|
|
14
|
+
import py_mini_racer
|
|
15
15
|
|
|
16
16
|
from akshare.bond.cons import (
|
|
17
17
|
zh_sina_bond_hs_cov_count_url,
|
|
@@ -21,6 +21,7 @@ from akshare.bond.cons import (
|
|
|
21
21
|
)
|
|
22
22
|
from akshare.stock.cons import hk_js_decode
|
|
23
23
|
from akshare.utils import demjson
|
|
24
|
+
from akshare.utils.tqdm import get_tqdm
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
def _get_zh_bond_hs_cov_page_count() -> int:
|
|
@@ -51,6 +52,7 @@ def bond_zh_hs_cov_spot() -> pd.DataFrame:
|
|
|
51
52
|
big_df = pd.DataFrame()
|
|
52
53
|
page_count = _get_zh_bond_hs_cov_page_count()
|
|
53
54
|
zh_sina_bond_hs_payload_copy = zh_sina_bond_hs_cov_payload.copy()
|
|
55
|
+
tqdm = get_tqdm()
|
|
54
56
|
for page in tqdm(range(1, page_count + 1), leave=False):
|
|
55
57
|
zh_sina_bond_hs_payload_copy.update({"page": page})
|
|
56
58
|
res = requests.get(zh_sina_bond_hs_cov_url, params=zh_sina_bond_hs_payload_copy)
|
|
@@ -132,11 +134,11 @@ def _code_id_map() -> dict:
|
|
|
132
134
|
|
|
133
135
|
|
|
134
136
|
def bond_zh_hs_cov_min(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
symbol: str = "sz128039",
|
|
138
|
+
period: str = "15",
|
|
139
|
+
adjust: str = "",
|
|
140
|
+
start_date: str = "1979-09-01 09:32:00",
|
|
141
|
+
end_date: str = "2222-01-01 09:32:00",
|
|
140
142
|
) -> pd.DataFrame:
|
|
141
143
|
"""
|
|
142
144
|
东方财富网-可转债-分时行情
|
|
@@ -191,7 +193,9 @@ def bond_zh_hs_cov_min(
|
|
|
191
193
|
temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
|
|
192
194
|
temp_df["成交额"] = pd.to_numeric(temp_df["成交额"], errors="coerce")
|
|
193
195
|
temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce")
|
|
194
|
-
temp_df["时间"] = pd.to_datetime(temp_df["时间"]).astype(
|
|
196
|
+
temp_df["时间"] = pd.to_datetime(temp_df["时间"]).astype(
|
|
197
|
+
str
|
|
198
|
+
) # show datatime here
|
|
195
199
|
return temp_df
|
|
196
200
|
else:
|
|
197
201
|
adjust_map = {
|
|
@@ -324,7 +328,11 @@ def bond_zh_cov() -> pd.DataFrame:
|
|
|
324
328
|
"pageNumber": "1",
|
|
325
329
|
"reportName": "RPT_BOND_CB_LIST",
|
|
326
330
|
"columns": "ALL",
|
|
327
|
-
"quoteColumns": "f2~01~CONVERT_STOCK_CODE~CONVERT_STOCK_PRICE,
|
|
331
|
+
"quoteColumns": "f2~01~CONVERT_STOCK_CODE~CONVERT_STOCK_PRICE,"
|
|
332
|
+
"f235~10~SECURITY_CODE~TRANSFER_PRICE,f236~10~SECURITY_CODE~TRANSFER_VALUE,"
|
|
333
|
+
"f2~10~SECURITY_CODE~CURRENT_BOND_PRICE,f237~10~SECURITY_CODE~TRANSFER_PREMIUM_RATIO,"
|
|
334
|
+
"f239~10~SECURITY_CODE~RESALE_TRIG_PRICE,f240~10~SECURITY_CODE~REDEEM_TRIG_PRICE,"
|
|
335
|
+
"f23~01~CONVERT_STOCK_CODE~PBV_RATIO",
|
|
328
336
|
"source": "WEB",
|
|
329
337
|
"client": "WEB",
|
|
330
338
|
}
|
|
@@ -332,6 +340,7 @@ def bond_zh_cov() -> pd.DataFrame:
|
|
|
332
340
|
data_json = r.json()
|
|
333
341
|
total_page = data_json["result"]["pages"]
|
|
334
342
|
big_df = pd.DataFrame()
|
|
343
|
+
tqdm = get_tqdm()
|
|
335
344
|
for page in tqdm(range(1, total_page + 1), leave=False):
|
|
336
345
|
params.update({"pageNumber": page})
|
|
337
346
|
r = requests.get(url, params=params)
|
|
@@ -348,7 +357,7 @@ def bond_zh_cov() -> pd.DataFrame:
|
|
|
348
357
|
"上市时间",
|
|
349
358
|
"正股代码",
|
|
350
359
|
"_",
|
|
351
|
-
"
|
|
360
|
+
"信用评级",
|
|
352
361
|
"_",
|
|
353
362
|
"_",
|
|
354
363
|
"_",
|
|
@@ -410,6 +419,7 @@ def bond_zh_cov() -> pd.DataFrame:
|
|
|
410
419
|
"_",
|
|
411
420
|
"_",
|
|
412
421
|
"_",
|
|
422
|
+
"_",
|
|
413
423
|
]
|
|
414
424
|
big_df = big_df[
|
|
415
425
|
[
|
|
@@ -431,6 +441,7 @@ def bond_zh_cov() -> pd.DataFrame:
|
|
|
431
441
|
"中签号发布日",
|
|
432
442
|
"中签率",
|
|
433
443
|
"上市时间",
|
|
444
|
+
"信用评级",
|
|
434
445
|
]
|
|
435
446
|
]
|
|
436
447
|
|
|
@@ -440,10 +451,14 @@ def bond_zh_cov() -> pd.DataFrame:
|
|
|
440
451
|
big_df["转股价值"] = pd.to_numeric(big_df["转股价值"], errors="coerce")
|
|
441
452
|
big_df["债现价"] = pd.to_numeric(big_df["债现价"], errors="coerce")
|
|
442
453
|
big_df["转股溢价率"] = pd.to_numeric(big_df["转股溢价率"], errors="coerce")
|
|
443
|
-
big_df["原股东配售-每股配售额"] = pd.to_numeric(
|
|
454
|
+
big_df["原股东配售-每股配售额"] = pd.to_numeric(
|
|
455
|
+
big_df["原股东配售-每股配售额"], errors="coerce"
|
|
456
|
+
)
|
|
444
457
|
big_df["发行规模"] = pd.to_numeric(big_df["发行规模"], errors="coerce")
|
|
445
458
|
big_df["中签率"] = pd.to_numeric(big_df["中签率"], errors="coerce")
|
|
446
|
-
big_df["中签号发布日"] = pd.to_datetime(
|
|
459
|
+
big_df["中签号发布日"] = pd.to_datetime(
|
|
460
|
+
big_df["中签号发布日"], errors="coerce"
|
|
461
|
+
).dt.date
|
|
447
462
|
big_df["上市时间"] = pd.to_datetime(big_df["上市时间"], errors="coerce").dt.date
|
|
448
463
|
big_df["申购日期"] = pd.to_datetime(big_df["申购日期"], errors="coerce").dt.date
|
|
449
464
|
big_df["原股东配售-股权登记日"] = pd.to_datetime(
|
|
@@ -471,7 +486,8 @@ def bond_cov_comparison() -> pd.DataFrame:
|
|
|
471
486
|
"invt": "2",
|
|
472
487
|
"fid": "f243",
|
|
473
488
|
"fs": "b:MK0354",
|
|
474
|
-
"fields": "f1,f152,f2,f3,f12,f13,f14,f227,f228,f229,f230,f231,f232,f233,f234,
|
|
489
|
+
"fields": "f1,f152,f2,f3,f12,f13,f14,f227,f228,f229,f230,f231,f232,f233,f234,"
|
|
490
|
+
"f235,f236,f237,f238,f239,f240,f241,f242,f26,f243",
|
|
475
491
|
"_": "1590386857527",
|
|
476
492
|
}
|
|
477
493
|
r = requests.get(url, params=params)
|
|
@@ -535,7 +551,9 @@ def bond_cov_comparison() -> pd.DataFrame:
|
|
|
535
551
|
return temp_df
|
|
536
552
|
|
|
537
553
|
|
|
538
|
-
def bond_zh_cov_info(
|
|
554
|
+
def bond_zh_cov_info(
|
|
555
|
+
symbol: str = "123121", indicator: str = "基本信息"
|
|
556
|
+
) -> pd.DataFrame:
|
|
539
557
|
"""
|
|
540
558
|
https://data.eastmoney.com/kzz/detail/123121.html
|
|
541
559
|
东方财富网-数据中心-新股数据-可转债详情
|
|
@@ -556,7 +574,10 @@ def bond_zh_cov_info(symbol: str = "123121", indicator: str = "基本信息") ->
|
|
|
556
574
|
params = {
|
|
557
575
|
"reportName": "RPT_BOND_CB_LIST",
|
|
558
576
|
"columns": "ALL",
|
|
559
|
-
"quoteColumns": "f2~01~CONVERT_STOCK_CODE~CONVERT_STOCK_PRICE,f235~10~SECURITY_CODE~TRANSFER_PRICE,
|
|
577
|
+
"quoteColumns": "f2~01~CONVERT_STOCK_CODE~CONVERT_STOCK_PRICE,f235~10~SECURITY_CODE~TRANSFER_PRICE,"
|
|
578
|
+
"f236~10~SECURITY_CODE~TRANSFER_VALUE,f2~10~SECURITY_CODE~CURRENT_BOND_PRICE,"
|
|
579
|
+
"f237~10~SECURITY_CODE~TRANSFER_PREMIUM_RATIO,f239~10~SECURITY_CODE~RESALE_TRIG_PRICE,"
|
|
580
|
+
"f240~10~SECURITY_CODE~REDEEM_TRIG_PRICE,f23~01~CONVERT_STOCK_CODE~PBV_RATIO",
|
|
560
581
|
"quoteType": "0",
|
|
561
582
|
"source": "WEB",
|
|
562
583
|
"client": "WEB",
|
|
@@ -567,7 +588,10 @@ def bond_zh_cov_info(symbol: str = "123121", indicator: str = "基本信息") ->
|
|
|
567
588
|
params.update(
|
|
568
589
|
{
|
|
569
590
|
"reportName": indicator_map[indicator],
|
|
570
|
-
"quoteColumns": "f2~01~CONVERT_STOCK_CODE~CONVERT_STOCK_PRICE,f235~10~SECURITY_CODE~TRANSFER_PRICE,
|
|
591
|
+
"quoteColumns": "f2~01~CONVERT_STOCK_CODE~CONVERT_STOCK_PRICE,f235~10~SECURITY_CODE~TRANSFER_PRICE,"
|
|
592
|
+
"f236~10~SECURITY_CODE~TRANSFER_VALUE,f2~10~SECURITY_CODE~CURRENT_BOND_PRICE,"
|
|
593
|
+
"f237~10~SECURITY_CODE~TRANSFER_PREMIUM_RATIO,f239~10~SECURITY_CODE~RESALE_TRIG_PRICE,"
|
|
594
|
+
"f240~10~SECURITY_CODE~REDEEM_TRIG_PRICE,f23~01~CONVERT_STOCK_CODE~PBV_RATIO",
|
|
571
595
|
}
|
|
572
596
|
)
|
|
573
597
|
r = requests.get(url, params=params)
|
akshare/bond/bond_zh_sina.py
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/
|
|
4
|
+
Date: 2024/6/18 18:30
|
|
5
5
|
Desc: 新浪财经-债券-沪深债券-实时行情数据和历史行情数据
|
|
6
6
|
https://vip.stock.finance.sina.com.cn/mkt/#hs_z
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import datetime
|
|
9
10
|
import re
|
|
10
11
|
|
|
11
12
|
import pandas as pd
|
|
12
13
|
import requests
|
|
13
|
-
|
|
14
|
+
import py_mini_racer
|
|
14
15
|
|
|
15
16
|
from akshare.bond.cons import (
|
|
16
17
|
zh_sina_bond_hs_count_url,
|
|
@@ -41,7 +42,7 @@ def get_zh_bond_hs_page_count() -> int:
|
|
|
41
42
|
return int(page_count) + 1
|
|
42
43
|
|
|
43
44
|
|
|
44
|
-
def bond_zh_hs_spot() -> pd.DataFrame:
|
|
45
|
+
def bond_zh_hs_spot(start_page: str = "1", end_page: str = "10") -> pd.DataFrame:
|
|
45
46
|
"""
|
|
46
47
|
新浪财经-债券-沪深债券-实时行情数据, 大量抓取容易封IP
|
|
47
48
|
https://vip.stock.finance.sina.com.cn/mkt/#hs_z
|
|
@@ -49,59 +50,64 @@ def bond_zh_hs_spot() -> pd.DataFrame:
|
|
|
49
50
|
:rtype: pandas.DataFrame
|
|
50
51
|
"""
|
|
51
52
|
page_count = get_zh_bond_hs_page_count()
|
|
53
|
+
page_count = int(page_count)
|
|
52
54
|
zh_sina_bond_hs_payload_copy = zh_sina_bond_hs_payload.copy()
|
|
53
55
|
tqdm = get_tqdm()
|
|
54
56
|
big_df = pd.DataFrame()
|
|
55
|
-
|
|
57
|
+
start_page = int(start_page)
|
|
58
|
+
end_page = int(end_page) + 1 if int(end_page) + 1 <= page_count else page_count
|
|
59
|
+
for page in tqdm(range(start_page, end_page), leave=False):
|
|
56
60
|
zh_sina_bond_hs_payload_copy.update({"page": page})
|
|
57
61
|
r = requests.get(zh_sina_bond_hs_url, params=zh_sina_bond_hs_payload_copy)
|
|
58
62
|
data_json = demjson.decode(r.text)
|
|
59
63
|
temp_df = pd.DataFrame(data_json)
|
|
60
64
|
big_df = pd.concat(objs=[big_df, temp_df], ignore_index=True)
|
|
61
65
|
big_df.columns = [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
66
|
+
"代码",
|
|
67
|
+
"-",
|
|
68
|
+
"名称",
|
|
69
|
+
"最新价",
|
|
70
|
+
"涨跌额",
|
|
71
|
+
"涨跌幅",
|
|
72
|
+
"买入",
|
|
73
|
+
"卖出",
|
|
74
|
+
"昨收",
|
|
75
|
+
"今开",
|
|
76
|
+
"最高",
|
|
77
|
+
"最低",
|
|
78
|
+
"成交量",
|
|
79
|
+
"成交额",
|
|
80
|
+
"-",
|
|
81
|
+
"-",
|
|
82
|
+
"-",
|
|
83
|
+
"-",
|
|
84
|
+
"-",
|
|
85
|
+
"-",
|
|
86
|
+
]
|
|
87
|
+
big_df = big_df[
|
|
88
|
+
[
|
|
89
|
+
"代码",
|
|
90
|
+
"名称",
|
|
91
|
+
"最新价",
|
|
92
|
+
"涨跌额",
|
|
93
|
+
"涨跌幅",
|
|
94
|
+
"买入",
|
|
95
|
+
"卖出",
|
|
96
|
+
"昨收",
|
|
97
|
+
"今开",
|
|
98
|
+
"最高",
|
|
99
|
+
"最低",
|
|
100
|
+
"成交量",
|
|
101
|
+
"成交额",
|
|
102
|
+
]
|
|
82
103
|
]
|
|
83
|
-
big_df = big_df[
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
'卖出',
|
|
91
|
-
'昨收',
|
|
92
|
-
'今开',
|
|
93
|
-
'最高',
|
|
94
|
-
'最低',
|
|
95
|
-
'成交量',
|
|
96
|
-
'成交额',
|
|
97
|
-
]]
|
|
98
|
-
big_df['买入'] = pd.to_numeric(big_df['买入'], errors="coerce")
|
|
99
|
-
big_df['卖出'] = pd.to_numeric(big_df['卖出'], errors="coerce")
|
|
100
|
-
big_df['昨收'] = pd.to_numeric(big_df['昨收'], errors="coerce")
|
|
101
|
-
big_df['今开'] = pd.to_numeric(big_df['今开'], errors="coerce")
|
|
102
|
-
big_df['最高'] = pd.to_numeric(big_df['最高'], errors="coerce")
|
|
103
|
-
big_df['最低'] = pd.to_numeric(big_df['最低'], errors="coerce")
|
|
104
|
-
big_df['最新价'] = pd.to_numeric(big_df['最新价'], errors="coerce")
|
|
104
|
+
big_df["买入"] = pd.to_numeric(big_df["买入"], errors="coerce")
|
|
105
|
+
big_df["卖出"] = pd.to_numeric(big_df["卖出"], errors="coerce")
|
|
106
|
+
big_df["昨收"] = pd.to_numeric(big_df["昨收"], errors="coerce")
|
|
107
|
+
big_df["今开"] = pd.to_numeric(big_df["今开"], errors="coerce")
|
|
108
|
+
big_df["最高"] = pd.to_numeric(big_df["最高"], errors="coerce")
|
|
109
|
+
big_df["最低"] = pd.to_numeric(big_df["最低"], errors="coerce")
|
|
110
|
+
big_df["最新价"] = pd.to_numeric(big_df["最新价"], errors="coerce")
|
|
105
111
|
return big_df
|
|
106
112
|
|
|
107
113
|
|
|
@@ -126,15 +132,15 @@ def bond_zh_hs_daily(symbol: str = "sh010107") -> pd.DataFrame:
|
|
|
126
132
|
) # 执行 js 解密代码
|
|
127
133
|
data_df = pd.DataFrame(dict_list)
|
|
128
134
|
data_df["date"] = pd.to_datetime(data_df["date"], errors="coerce").dt.date
|
|
129
|
-
data_df[
|
|
130
|
-
data_df[
|
|
131
|
-
data_df[
|
|
132
|
-
data_df[
|
|
135
|
+
data_df["open"] = pd.to_numeric(data_df["open"], errors="coerce")
|
|
136
|
+
data_df["high"] = pd.to_numeric(data_df["high"], errors="coerce")
|
|
137
|
+
data_df["low"] = pd.to_numeric(data_df["low"], errors="coerce")
|
|
138
|
+
data_df["close"] = pd.to_numeric(data_df["close"], errors="coerce")
|
|
133
139
|
return data_df
|
|
134
140
|
|
|
135
141
|
|
|
136
142
|
if __name__ == "__main__":
|
|
137
|
-
bond_zh_hs_spot_df = bond_zh_hs_spot()
|
|
143
|
+
bond_zh_hs_spot_df = bond_zh_hs_spot(start_page="1", end_page="5")
|
|
138
144
|
print(bond_zh_hs_spot_df)
|
|
139
145
|
|
|
140
146
|
bond_zh_hs_daily_df = bond_zh_hs_daily(symbol="sh010107")
|
akshare/cal/__init__.py
ADDED
|
File without changes
|