akshare 1.13.46__py3-none-any.whl → 1.17.99__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.
- akshare/__init__.py +757 -161
- akshare/air/air_hebei.py +79 -53
- akshare/air/air_zhenqi.py +3 -7
- akshare/air/cons.py +1 -0
- akshare/air/crypto.js +1 -1
- akshare/air/outcrypto.js +1 -1
- akshare/air/sunrise_tad.py +32 -17
- akshare/article/cons.py +1 -0
- akshare/article/epu_index.py +4 -3
- akshare/article/ff_factor.py +19 -8
- akshare/article/fred_md.py +4 -1
- akshare/article/risk_rv.py +3 -8
- akshare/bank/bank_cbirc_2020.py +11 -11
- akshare/bank/cons.py +7 -6
- akshare/bond/bond_buy_back_em.py +228 -0
- akshare/bond/bond_cb_sina.py +1 -0
- akshare/bond/bond_cb_ths.py +17 -9
- akshare/bond/bond_cbond.py +19 -14
- akshare/bond/bond_china.py +38 -39
- akshare/bond/bond_china_money.py +75 -48
- akshare/bond/bond_convert.py +10 -9
- akshare/bond/bond_em.py +37 -17
- akshare/bond/bond_info_cm.py +28 -8
- akshare/bond/bond_issue_cninfo.py +73 -30
- akshare/bond/bond_summary.py +38 -37
- akshare/bond/bond_zh_cov.py +31 -40
- akshare/bond/bond_zh_sina.py +61 -51
- akshare/bond/cons.py +14 -11
- akshare/cal/__init__.py +0 -0
- akshare/cal/rv.py +170 -0
- akshare/cost/cost_living.py +7 -5
- akshare/crypto/__init__.py +1 -1
- akshare/crypto/crypto_bitcoin_cme.py +9 -7
- akshare/crypto/crypto_hold.py +4 -2
- akshare/currency/currency.py +1 -0
- akshare/currency/currency_china_bank_sina.py +11 -6
- akshare/currency/currency_safe.py +7 -6
- akshare/data/__init__.py +1 -1
- akshare/data/cninfo.js +1 -1
- akshare/datasets.py +10 -21
- akshare/economic/cons.py +10 -3
- akshare/economic/macro_australia.py +74 -69
- akshare/economic/macro_bank.py +95 -653
- akshare/economic/macro_canada.py +92 -81
- akshare/economic/macro_china.py +163 -117
- akshare/economic/macro_china_hk.py +0 -1
- akshare/economic/macro_china_nbs.py +24 -7
- akshare/economic/macro_euro.py +103 -56
- akshare/economic/macro_finance_ths.py +135 -0
- akshare/economic/macro_germany.py +1 -1
- akshare/economic/macro_info_ws.py +100 -0
- akshare/economic/macro_japan.py +0 -1
- akshare/economic/macro_other.py +1 -6
- akshare/economic/macro_swiss.py +2 -3
- akshare/economic/macro_uk.py +1 -1
- akshare/economic/macro_usa.py +7 -9
- akshare/economic/marco_cnbs.py +11 -6
- akshare/energy/energy_carbon.py +94 -126
- akshare/energy/energy_oil_em.py +1 -2
- akshare/event/cons.py +1 -0
- akshare/event/migration.py +3 -2
- akshare/exceptions.py +43 -0
- akshare/file_fold/calendar.json +245 -2
- akshare/forex/__init__.py +0 -0
- akshare/forex/cons.py +192 -0
- akshare/forex/forex_em.py +149 -0
- akshare/fortune/fortune_500.py +15 -48
- akshare/fortune/fortune_bloomberg.py +6 -3
- akshare/fortune/fortune_forbes_500.py +3 -6
- akshare/fortune/fortune_hurun.py +2 -1
- akshare/fortune/fortune_xincaifu_500.py +17 -14
- akshare/fund/fund_amac.py +38 -15
- akshare/fund/fund_announcement_em.py +145 -0
- akshare/fund/fund_aum_em.py +49 -35
- akshare/fund/fund_em.py +251 -220
- akshare/fund/fund_etf_em.py +44 -35
- akshare/fund/fund_etf_sina.py +76 -27
- akshare/fund/fund_etf_ths.py +95 -0
- akshare/fund/fund_fee_em.py +172 -0
- akshare/fund/fund_fhsp_em.py +42 -32
- akshare/fund/fund_init_em.py +8 -5
- akshare/fund/fund_lof_em.py +12 -19
- akshare/fund/fund_manager.py +25 -11
- akshare/fund/fund_overview_em.py +42 -0
- akshare/fund/fund_portfolio_em.py +78 -66
- akshare/fund/fund_position_lg.py +19 -8
- akshare/fund/fund_rank_em.py +90 -84
- akshare/fund/fund_rating.py +33 -12
- akshare/fund/fund_report_cninfo.py +63 -48
- akshare/fund/fund_scale_em.py +24 -13
- akshare/fund/fund_scale_sina.py +20 -10
- akshare/fund/fund_xq.py +3 -2
- akshare/futures/cons.py +141 -46
- akshare/futures/cot.py +89 -88
- akshare/futures/futures_basis.py +99 -33
- akshare/futures/futures_comex_em.py +1 -0
- akshare/futures/futures_comm_ctp.py +13 -2
- akshare/futures/futures_contract_detail.py +59 -9
- akshare/futures/futures_daily_bar.py +75 -62
- akshare/futures/futures_foreign.py +14 -8
- akshare/futures/futures_hf_em.py +215 -61
- akshare/futures/futures_hist_em.py +191 -0
- akshare/futures/futures_hq_sina.py +79 -61
- akshare/futures/futures_index_ccidx.py +24 -82
- akshare/futures/futures_inventory_99.py +70 -272
- akshare/futures/futures_inventory_em.py +14 -11
- akshare/futures/futures_news_shmet.py +2 -2
- akshare/futures/futures_roll_yield.py +11 -24
- akshare/futures/futures_rule.py +7 -3
- akshare/futures/futures_rule_em.py +38 -0
- akshare/futures/futures_settlement_price_sgx.py +21 -6
- akshare/futures/futures_stock_js.py +1 -2
- akshare/futures/futures_to_spot.py +43 -39
- akshare/futures/futures_warehouse_receipt.py +53 -48
- akshare/futures/futures_zh_sina.py +4 -4
- akshare/futures/receipt.py +298 -165
- akshare/futures/requests_fun.py +16 -3
- akshare/futures/symbol_var.py +32 -13
- akshare/futures_derivative/cons.py +100 -103
- akshare/futures_derivative/futures_contract_info_cffex.py +55 -39
- akshare/futures_derivative/futures_contract_info_czce.py +2 -0
- akshare/futures_derivative/futures_contract_info_dce.py +43 -17
- akshare/futures_derivative/futures_contract_info_gfex.py +43 -31
- akshare/futures_derivative/futures_contract_info_ine.py +43 -34
- akshare/futures_derivative/futures_contract_info_shfe.py +7 -8
- akshare/futures_derivative/futures_cot_sina.py +28 -19
- akshare/futures_derivative/futures_index_sina.py +25 -13
- akshare/fx/cons.py +12 -7
- akshare/fx/currency_investing.py +19 -285
- akshare/fx/fx_c_swap_cm.py +62 -0
- akshare/fx/fx_quote.py +3 -2
- akshare/fx/fx_quote_baidu.py +2 -1
- akshare/hf/__init__.py +1 -1
- akshare/hf/hf_sp500.py +8 -7
- akshare/index/cons.py +132 -28
- akshare/index/index_cflp.py +29 -26
- akshare/index/index_cni.py +89 -91
- akshare/index/index_cons.py +26 -10
- akshare/index/index_csindex.py +68 -0
- akshare/index/index_cx.py +263 -62
- akshare/index/index_drewry.py +17 -16
- akshare/index/index_eri.py +1 -0
- akshare/index/index_global_em.py +167 -0
- akshare/index/index_global_sina.py +82 -0
- akshare/index/index_kq_fz.py +17 -14
- akshare/index/index_kq_ss.py +1 -0
- akshare/index/index_option_qvix.py +351 -16
- akshare/index/index_research_sw.py +38 -38
- akshare/index/index_spot.py +9 -5
- akshare/index/index_stock_hk.py +6 -10
- akshare/index/index_stock_us_sina.py +1 -1
- akshare/index/index_stock_zh.py +193 -101
- akshare/index/index_stock_zh_csindex.py +15 -369
- akshare/index/index_sugar.py +18 -4
- akshare/index/index_sw.py +62 -34
- akshare/index/index_yw.py +53 -75
- akshare/index/index_zh_em.py +15 -82
- akshare/interest_rate/interbank_rate_em.py +14 -10
- akshare/movie/artist_yien.py +32 -5
- akshare/movie/jm.js +0 -1
- akshare/movie/movie_yien.py +92 -18
- akshare/movie/video_yien.py +28 -5
- akshare/news/__init__.py +1 -1
- akshare/news/news_baidu.py +395 -220
- akshare/news/news_cctv.py +38 -38
- akshare/news/news_stock.py +49 -13
- akshare/nlp/nlp_interface.py +7 -8
- akshare/option/cons.py +12 -12
- akshare/option/option_comm_qihuo.py +86 -0
- akshare/option/option_commodity.py +355 -211
- akshare/option/option_commodity_sina.py +22 -26
- akshare/option/option_contract_info_ctp.py +63 -0
- akshare/option/option_current_sse.py +61 -0
- akshare/option/option_current_szse.py +84 -0
- akshare/option/option_czce.py +37 -9
- akshare/option/option_daily_stats_sse_szse.py +145 -0
- akshare/option/option_em.py +4 -8
- akshare/option/option_finance.py +60 -12
- akshare/option/option_finance_sina.py +28 -26
- akshare/option/option_lhb_em.py +62 -57
- akshare/option/option_margin.py +62 -0
- akshare/option/option_premium_analysis_em.py +58 -53
- akshare/option/option_risk_analysis_em.py +11 -8
- akshare/option/option_risk_indicator_sse.py +18 -16
- akshare/option/option_value_analysis_em.py +62 -55
- akshare/other/__init__.py +1 -1
- akshare/other/other_car_cpca.py +20 -20
- akshare/pro/__init__.py +0 -1
- akshare/pro/client.py +6 -4
- akshare/pro/cons.py +3 -2
- akshare/pro/data_pro.py +6 -5
- akshare/qdii/__init__.py +0 -0
- akshare/qdii/qdii_jsl.py +233 -0
- akshare/qhkc/__init__.py +1 -6
- akshare/qhkc/qhkc_api.py +64 -22
- akshare/qhkc_web/__init__.py +1 -6
- akshare/qhkc_web/qhkc_fund.py +10 -6
- akshare/qhkc_web/qhkc_index.py +28 -14
- akshare/qhkc_web/qhkc_tool.py +62 -59
- akshare/rate/__init__.py +1 -1
- akshare/rate/repo_rate.py +36 -32
- akshare/reits/__init__.py +1 -1
- akshare/reits/reits_basic.py +149 -13
- akshare/request.py +117 -0
- akshare/spot/__init__.py +1 -1
- akshare/spot/spot_hog_soozhu.py +232 -0
- akshare/spot/spot_price_qh.py +121 -0
- akshare/spot/spot_sge.py +70 -9
- akshare/stock/cons.py +60 -23
- akshare/stock/stock_allotment_cninfo.py +10 -9
- akshare/stock/stock_ask_bid_em.py +3 -78
- akshare/stock/stock_board_concept_em.py +160 -35
- akshare/stock/stock_board_industry_em.py +163 -70
- 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 +36 -16
- akshare/stock/stock_dzjy_em.py +347 -260
- akshare/stock/stock_fund_em.py +73 -64
- akshare/stock/stock_fund_hold.py +1 -2
- akshare/stock/stock_gsrl_em.py +1 -0
- akshare/stock/stock_hk_comparison_em.py +175 -0
- akshare/stock/stock_hk_famous.py +107 -0
- akshare/stock/stock_hk_fhpx_ths.py +2 -1
- akshare/stock/stock_hk_hot_rank_em.py +1 -0
- akshare/stock/stock_hk_sina.py +91 -42
- akshare/stock/stock_hold_control_cninfo.py +100 -15
- akshare/stock/stock_hold_control_em.py +4 -5
- akshare/stock/stock_hold_num_cninfo.py +18 -12
- akshare/stock/stock_hot_rank_em.py +4 -1
- akshare/stock/stock_hot_search_baidu.py +32 -19
- akshare/stock/stock_hot_up_em.py +4 -1
- akshare/stock/stock_hsgt_em.py +155 -0
- akshare/stock/stock_industry.py +1 -0
- akshare/stock/stock_industry_cninfo.py +25 -20
- akshare/stock/stock_industry_pe_cninfo.py +45 -31
- akshare/stock/stock_industry_sw.py +5 -9
- akshare/stock/stock_info.py +31 -19
- akshare/stock/stock_info_em.py +17 -11
- akshare/stock/stock_intraday_em.py +9 -80
- akshare/stock/stock_intraday_sina.py +2 -2
- 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_profile_em.py +302 -0
- akshare/stock/stock_rank_forecast.py +8 -6
- akshare/stock/stock_repurchase_em.py +7 -2
- akshare/stock/stock_share_changes_cninfo.py +18 -14
- akshare/stock/stock_share_hold.py +24 -20
- akshare/stock/stock_stop.py +6 -6
- akshare/stock/stock_summary.py +153 -417
- akshare/stock/stock_us_famous.py +19 -11
- akshare/stock/stock_us_js.py +3 -2
- akshare/stock/stock_us_pink.py +38 -27
- akshare/stock/stock_us_sina.py +15 -12
- akshare/stock/stock_weibo_nlp.py +18 -20
- akshare/stock/stock_xq.py +36 -9
- akshare/stock/stock_zh_a_sina.py +58 -80
- akshare/stock/stock_zh_a_special.py +240 -243
- akshare/stock/stock_zh_a_tick_tx.py +11 -3
- akshare/stock/stock_zh_ah_tx.py +23 -26
- akshare/stock/stock_zh_b_sina.py +32 -55
- akshare/stock/stock_zh_comparison_em.py +250 -0
- akshare/stock/stock_zh_kcb_report.py +11 -9
- akshare/stock/stock_zh_kcb_sina.py +67 -64
- akshare/stock_a/__init__.py +0 -0
- akshare/stock_a/stock_board_concept_name_em.py +170 -0
- akshare/stock_a/stock_individual_fund_flow_rank.py +258 -0
- akshare/stock_a/stock_zh_a_spot.py +212 -0
- akshare/stock_feature/cons.py +1 -0
- 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 +15 -57
- akshare/stock_feature/stock_a_pe_and_pb.py +39 -9
- akshare/stock_feature/stock_account_em.py +0 -1
- akshare/stock_feature/stock_all_pb.py +2 -1
- akshare/stock_feature/stock_analyst_em.py +36 -30
- akshare/stock_feature/stock_board_concept_ths.py +144 -252
- akshare/stock_feature/stock_board_industry_ths.py +137 -401
- akshare/stock_feature/stock_buffett_index_lg.py +10 -8
- akshare/stock_feature/stock_classify_sina.py +3 -6
- akshare/stock_feature/stock_comment_em.py +81 -144
- akshare/stock_feature/stock_concept_futu.py +183 -0
- akshare/stock_feature/stock_congestion_lg.py +2 -1
- akshare/stock_feature/stock_cyq_em.py +5 -11
- akshare/stock_feature/stock_disclosure_cninfo.py +20 -10
- akshare/stock_feature/stock_dxsyl_em.py +121 -74
- akshare/stock_feature/stock_ebs_lg.py +5 -4
- akshare/stock_feature/stock_esg_sina.py +33 -15
- akshare/stock_feature/stock_fhps_em.py +62 -26
- akshare/stock_feature/stock_fhps_ths.py +34 -7
- akshare/stock_feature/stock_fund_flow.py +38 -25
- akshare/stock_feature/stock_gddh_em.py +19 -11
- akshare/stock_feature/stock_gdfx_em.py +226 -113
- akshare/stock_feature/stock_gdhs.py +75 -50
- akshare/stock_feature/stock_gdzjc_em.py +21 -10
- akshare/stock_feature/stock_gpzy_em.py +78 -46
- akshare/stock_feature/stock_gxl_lg.py +3 -2
- akshare/stock_feature/stock_hist_em.py +158 -237
- akshare/stock_feature/stock_hist_tx.py +13 -10
- akshare/stock_feature/stock_hk_valuation_baidu.py +20 -8
- akshare/stock_feature/stock_hot_xq.py +4 -6
- akshare/stock_feature/stock_hsgt_em.py +269 -97
- akshare/stock_feature/stock_hsgt_exchange_rate.py +115 -87
- akshare/stock_feature/stock_hsgt_min_em.py +13 -16
- akshare/stock_feature/stock_info.py +8 -81
- akshare/stock_feature/stock_inner_trade_xq.py +38 -31
- akshare/stock_feature/stock_irm_cninfo.py +32 -9
- akshare/stock_feature/stock_jgdy_em.py +43 -40
- akshare/stock_feature/stock_lh_yybpm.py +36 -37
- akshare/stock_feature/stock_lhb_em.py +165 -35
- akshare/stock_feature/stock_lhb_sina.py +93 -46
- akshare/stock_feature/stock_margin_em.py +101 -0
- akshare/stock_feature/{stock_sse_margin.py → stock_margin_sse.py} +21 -17
- akshare/stock_feature/{stock_szse_margin.py → stock_margin_szse.py} +7 -7
- akshare/stock_feature/stock_market_legu.py +4 -2
- akshare/stock_feature/stock_pankou_em.py +71 -35
- akshare/stock_feature/stock_qsjy_em.py +13 -4
- akshare/stock_feature/stock_report_em.py +152 -8
- akshare/stock_feature/stock_research_report_em.py +55 -20
- akshare/stock_feature/stock_sns_sseinfo.py +15 -12
- akshare/stock_feature/stock_sy_em.py +20 -15
- akshare/stock_feature/stock_technology_ths.py +152 -120
- akshare/stock_feature/stock_tfp_em.py +37 -14
- akshare/stock_feature/stock_three_report_em.py +120 -78
- akshare/stock_feature/stock_ttm_lyr.py +18 -9
- akshare/stock_feature/stock_value_em.py +83 -0
- akshare/stock_feature/stock_yjbb_em.py +58 -32
- akshare/stock_feature/stock_yjyg_cninfo.py +6 -2
- akshare/stock_feature/stock_yjyg_em.py +1 -1
- akshare/stock_feature/stock_yzxdr_em.py +24 -22
- akshare/stock_feature/stock_zdhtmx_em.py +20 -6
- akshare/stock_feature/stock_zh_valuation_baidu.py +3 -2
- akshare/stock_feature/stock_zh_vote_baidu.py +4 -1
- akshare/stock_feature/stock_ztb_em.py +39 -24
- akshare/stock_fundamental/__init__.py +1 -1
- akshare/stock_fundamental/stock_basic_info_xq.py +119 -0
- akshare/stock_fundamental/{stock_finance_hk.py → stock_finance_hk_em.py} +23 -16
- akshare/stock_fundamental/{stock_finance.py → stock_finance_sina.py} +203 -59
- akshare/stock_fundamental/stock_finance_ths.py +524 -57
- akshare/stock_fundamental/stock_finance_us_em.py +268 -0
- akshare/stock_fundamental/stock_gbjg_em.py +80 -0
- akshare/stock_fundamental/stock_hold.py +26 -17
- akshare/stock_fundamental/stock_ipo_declare.py +1 -0
- akshare/stock_fundamental/stock_kcb_detail_sse.py +10 -10
- akshare/stock_fundamental/stock_kcb_sse.py +26 -25
- akshare/stock_fundamental/stock_notice.py +41 -18
- akshare/stock_fundamental/stock_profit_forecast_em.py +31 -13
- akshare/stock_fundamental/stock_profit_forecast_hk_etnet.py +64 -41
- akshare/stock_fundamental/stock_profit_forecast_ths.py +86 -35
- akshare/stock_fundamental/stock_recommend.py +20 -4
- akshare/stock_fundamental/stock_register_em.py +448 -0
- akshare/stock_fundamental/stock_zygc.py +5 -62
- akshare/tool/trade_date_hist.py +1 -1
- akshare/utils/context.py +43 -0
- akshare/utils/demjson.py +2009 -1338
- akshare/utils/func.py +49 -2
- akshare/utils/multi_decrypt.py +53 -0
- akshare/utils/token_process.py +6 -5
- akshare/utils/tqdm.py +13 -3
- {akshare-1.13.46.dist-info → akshare-1.17.99.dist-info}/METADATA +56 -86
- akshare-1.17.99.dist-info/RECORD +409 -0
- {akshare-1.13.46.dist-info → akshare-1.17.99.dist-info}/WHEEL +1 -1
- {akshare-1.13.46.dist-info → akshare-1.17.99.dist-info/licenses}/LICENSE +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/fund/fund_announcement.py +0 -56
- 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 -78
- akshare/index/index_investing.py +0 -232
- akshare/sport/__init__.py +0 -6
- akshare/sport/sport_olympic.py +0 -27
- akshare/sport/sport_olympic_winter.py +0 -39
- akshare/stock_feature/stock_wencai.py +0 -104
- akshare/stock_fundamental/stock_mda_ym.py +0 -40
- akshare/stock_fundamental/stock_register.py +0 -292
- akshare-1.13.46.dist-info/RECORD +0 -380
- {akshare-1.13.46.dist-info → akshare-1.17.99.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding:utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
Date: 2025/4/5 17:30
|
|
5
|
+
Desc: 东方财富网-行情中心-债券市场-质押式回购
|
|
6
|
+
https://quote.eastmoney.com/center/gridlist.html#bond_sz_buyback
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import pandas as pd
|
|
10
|
+
|
|
11
|
+
import requests
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def bond_sh_buy_back_em() -> pd.DataFrame:
|
|
15
|
+
"""
|
|
16
|
+
东方财富网-行情中心-债券市场-上证质押式回购
|
|
17
|
+
https://quote.eastmoney.com/center/gridlist.html#bond_sh_buyback
|
|
18
|
+
:return: 上证质押式回购
|
|
19
|
+
:rtype: pandas.DataFrame
|
|
20
|
+
"""
|
|
21
|
+
url = "https://push2.eastmoney.com/api/qt/clist/get"
|
|
22
|
+
params = {
|
|
23
|
+
"np": "1",
|
|
24
|
+
"fltt": "1",
|
|
25
|
+
"invt": "2",
|
|
26
|
+
"fs": "m:1+b:MK0356",
|
|
27
|
+
"fields": "f12,f13,f14,f1,f2,f4,f3,f152,f17,f18,f15,f16,f5,f6",
|
|
28
|
+
"fid": "f6",
|
|
29
|
+
"pn": "1",
|
|
30
|
+
"pz": "20",
|
|
31
|
+
"po": "1",
|
|
32
|
+
"dect": "1",
|
|
33
|
+
"wbp2u": "|0|0|0|web",
|
|
34
|
+
}
|
|
35
|
+
r = requests.get(url, params=params)
|
|
36
|
+
data_json = r.json()
|
|
37
|
+
temp_df = pd.DataFrame(data_json['data']['diff'])
|
|
38
|
+
temp_df.reset_index(inplace=True)
|
|
39
|
+
temp_df['index'] = temp_df['index'] + 1
|
|
40
|
+
temp_df.rename(
|
|
41
|
+
columns={
|
|
42
|
+
"index": "序号",
|
|
43
|
+
"f2": "最新价",
|
|
44
|
+
"f3": "涨跌幅",
|
|
45
|
+
"f4": "涨跌额",
|
|
46
|
+
"f5": "成交量",
|
|
47
|
+
"f6": "成交额",
|
|
48
|
+
"f12": "代码",
|
|
49
|
+
"f14": "名称",
|
|
50
|
+
"f15": "最高",
|
|
51
|
+
"f16": "最低",
|
|
52
|
+
"f17": "今开",
|
|
53
|
+
"f18": "昨收",
|
|
54
|
+
},
|
|
55
|
+
inplace=True,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
temp_df = temp_df[[
|
|
59
|
+
"序号",
|
|
60
|
+
"代码",
|
|
61
|
+
"名称",
|
|
62
|
+
"最新价",
|
|
63
|
+
"涨跌额",
|
|
64
|
+
"涨跌幅",
|
|
65
|
+
"今开",
|
|
66
|
+
"最高",
|
|
67
|
+
"最低",
|
|
68
|
+
"昨收",
|
|
69
|
+
"成交量",
|
|
70
|
+
"成交额",
|
|
71
|
+
]]
|
|
72
|
+
temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce") / 1000
|
|
73
|
+
temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"], errors="coerce") / 100
|
|
74
|
+
temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"], errors="coerce") / 1000
|
|
75
|
+
temp_df["今开"] = pd.to_numeric(temp_df["今开"], errors="coerce") / 1000
|
|
76
|
+
temp_df["最高"] = pd.to_numeric(temp_df["最高"], errors="coerce") / 1000
|
|
77
|
+
temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce") / 1000
|
|
78
|
+
temp_df["昨收"] = pd.to_numeric(temp_df["昨收"], errors="coerce") / 1000
|
|
79
|
+
temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
|
|
80
|
+
temp_df["成交额"] = pd.to_numeric(temp_df["成交额"], errors="coerce")
|
|
81
|
+
return temp_df
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def bond_sz_buy_back_em() -> pd.DataFrame:
|
|
85
|
+
"""
|
|
86
|
+
东方财富网-行情中心-债券市场-深证质押式回购
|
|
87
|
+
https://quote.eastmoney.com/center/gridlist.html#bond_sz_buyback
|
|
88
|
+
:return: 深证质押式回购
|
|
89
|
+
:rtype: pandas.DataFrame
|
|
90
|
+
"""
|
|
91
|
+
url = "https://push2.eastmoney.com/api/qt/clist/get"
|
|
92
|
+
params = {
|
|
93
|
+
"np": "1",
|
|
94
|
+
"fltt": "1",
|
|
95
|
+
"invt": "2",
|
|
96
|
+
"fs": "m:0+b:MK0356",
|
|
97
|
+
"fields": "f12,f13,f14,f1,f2,f4,f3,f152,f17,f18,f15,f16,f5,f6",
|
|
98
|
+
"fid": "f6",
|
|
99
|
+
"pn": "1",
|
|
100
|
+
"pz": "20",
|
|
101
|
+
"po": "1",
|
|
102
|
+
"dect": "1",
|
|
103
|
+
"wbp2u": "|0|0|0|web",
|
|
104
|
+
}
|
|
105
|
+
r = requests.get(url, params=params)
|
|
106
|
+
data_json = r.json()
|
|
107
|
+
temp_df = pd.DataFrame(data_json['data']['diff'])
|
|
108
|
+
temp_df.reset_index(inplace=True)
|
|
109
|
+
temp_df['index'] = temp_df['index'] + 1
|
|
110
|
+
temp_df.rename(
|
|
111
|
+
columns={
|
|
112
|
+
"index": "序号",
|
|
113
|
+
"f2": "最新价",
|
|
114
|
+
"f3": "涨跌幅",
|
|
115
|
+
"f4": "涨跌额",
|
|
116
|
+
"f5": "成交量",
|
|
117
|
+
"f6": "成交额",
|
|
118
|
+
"f12": "代码",
|
|
119
|
+
"f14": "名称",
|
|
120
|
+
"f15": "最高",
|
|
121
|
+
"f16": "最低",
|
|
122
|
+
"f17": "今开",
|
|
123
|
+
"f18": "昨收",
|
|
124
|
+
},
|
|
125
|
+
inplace=True,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
temp_df = temp_df[[
|
|
129
|
+
"序号",
|
|
130
|
+
"代码",
|
|
131
|
+
"名称",
|
|
132
|
+
"最新价",
|
|
133
|
+
"涨跌额",
|
|
134
|
+
"涨跌幅",
|
|
135
|
+
"今开",
|
|
136
|
+
"最高",
|
|
137
|
+
"最低",
|
|
138
|
+
"昨收",
|
|
139
|
+
"成交量",
|
|
140
|
+
"成交额",
|
|
141
|
+
]]
|
|
142
|
+
temp_df["最新价"] = pd.to_numeric(temp_df["最新价"], errors="coerce") / 1000
|
|
143
|
+
temp_df["涨跌幅"] = pd.to_numeric(temp_df["涨跌幅"], errors="coerce") / 100
|
|
144
|
+
temp_df["涨跌额"] = pd.to_numeric(temp_df["涨跌额"], errors="coerce") / 1000
|
|
145
|
+
temp_df["今开"] = pd.to_numeric(temp_df["今开"], errors="coerce") / 1000
|
|
146
|
+
temp_df["最高"] = pd.to_numeric(temp_df["最高"], errors="coerce") / 1000
|
|
147
|
+
temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce") / 1000
|
|
148
|
+
temp_df["昨收"] = pd.to_numeric(temp_df["昨收"], errors="coerce") / 1000
|
|
149
|
+
temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
|
|
150
|
+
temp_df["成交额"] = pd.to_numeric(temp_df["成交额"], errors="coerce")
|
|
151
|
+
return temp_df
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def bond_buy_back_hist_em(symbol: str = "204001"):
|
|
155
|
+
"""
|
|
156
|
+
东方财富网-行情中心-债券市场-质押式回购-历史数据
|
|
157
|
+
https://quote.eastmoney.com/center/gridlist.html#bond_sh_buyback
|
|
158
|
+
:param symbol: 质押式回购代码
|
|
159
|
+
:type symbol: str
|
|
160
|
+
:return: 历史数据
|
|
161
|
+
:rtype: pandas.DataFrame
|
|
162
|
+
"""
|
|
163
|
+
if symbol.startswith("1"):
|
|
164
|
+
market_id = "0"
|
|
165
|
+
else:
|
|
166
|
+
market_id = "1"
|
|
167
|
+
url = "https://push2his.eastmoney.com/api/qt/stock/kline/get"
|
|
168
|
+
params = {
|
|
169
|
+
"secid": f"{market_id}.{symbol}",
|
|
170
|
+
"klt": "101",
|
|
171
|
+
"fqt": "1",
|
|
172
|
+
"lmt": "10000",
|
|
173
|
+
"end": "20500000",
|
|
174
|
+
"iscca": "1",
|
|
175
|
+
"fields1": "f1,f2,f3,f4,f5,f6,f7,f8",
|
|
176
|
+
"fields2": "f51,f52,f53,f54,f55,f56,f57,f58,f59,f60,f61,f62,f63,f64",
|
|
177
|
+
"forcect": "1"
|
|
178
|
+
}
|
|
179
|
+
r = requests.get(url, params=params)
|
|
180
|
+
data_json = r.json()
|
|
181
|
+
temp_df = pd.DataFrame([item.split(',') for item in data_json['data']['klines']])
|
|
182
|
+
temp_df.columns = [
|
|
183
|
+
"日期",
|
|
184
|
+
"开盘",
|
|
185
|
+
"收盘",
|
|
186
|
+
"最高",
|
|
187
|
+
"最低",
|
|
188
|
+
"成交量",
|
|
189
|
+
"成交额",
|
|
190
|
+
"-",
|
|
191
|
+
"-",
|
|
192
|
+
"-",
|
|
193
|
+
"-",
|
|
194
|
+
"-",
|
|
195
|
+
"-",
|
|
196
|
+
"-",
|
|
197
|
+
]
|
|
198
|
+
temp_df = temp_df[[
|
|
199
|
+
"日期",
|
|
200
|
+
"开盘",
|
|
201
|
+
"收盘",
|
|
202
|
+
"最高",
|
|
203
|
+
"最低",
|
|
204
|
+
"成交量",
|
|
205
|
+
"成交额",
|
|
206
|
+
]]
|
|
207
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
208
|
+
temp_df["开盘"] = pd.to_numeric(temp_df["开盘"], errors="coerce")
|
|
209
|
+
temp_df["收盘"] = pd.to_numeric(temp_df["收盘"], errors="coerce")
|
|
210
|
+
temp_df["最高"] = pd.to_numeric(temp_df["最高"], errors="coerce")
|
|
211
|
+
temp_df["最低"] = pd.to_numeric(temp_df["最低"], errors="coerce")
|
|
212
|
+
temp_df["成交量"] = pd.to_numeric(temp_df["成交量"], errors="coerce")
|
|
213
|
+
temp_df["成交额"] = pd.to_numeric(temp_df["成交额"], errors="coerce")
|
|
214
|
+
return temp_df
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
if __name__ == "__main__":
|
|
218
|
+
bond_sh_buy_back_em_df = bond_sh_buy_back_em()
|
|
219
|
+
print(bond_sh_buy_back_em_df)
|
|
220
|
+
|
|
221
|
+
bond_sz_buy_back_em_df = bond_sz_buy_back_em()
|
|
222
|
+
print(bond_sz_buy_back_em_df)
|
|
223
|
+
|
|
224
|
+
bond_buy_back_hist_em_df = bond_buy_back_hist_em(symbol="204001")
|
|
225
|
+
print(bond_buy_back_hist_em_df)
|
|
226
|
+
|
|
227
|
+
bond_buy_back_hist_em_df = bond_buy_back_hist_em(symbol="131810")
|
|
228
|
+
print(bond_buy_back_hist_em_df)
|
akshare/bond/bond_cb_sina.py
CHANGED
akshare/bond/bond_cb_ths.py
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
# -*- coding:utf-8 -*-
|
|
2
2
|
# !/usr/bin/env python
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/8/14 11:30
|
|
5
5
|
Desc: 同花顺-数据中心-可转债
|
|
6
|
-
|
|
6
|
+
https://data.10jqka.com.cn/ipo/bond/
|
|
7
7
|
"""
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
import pandas as pd
|
|
10
|
+
import requests
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
def bond_zh_cov_info_ths() -> pd.DataFrame:
|
|
13
14
|
"""
|
|
14
15
|
同花顺-数据中心-可转债
|
|
15
|
-
|
|
16
|
+
https://data.10jqka.com.cn/ipo/bond/
|
|
16
17
|
:return: 可转债行情
|
|
17
18
|
:rtype: pandas.DataFrame
|
|
18
19
|
"""
|
|
19
|
-
url = "
|
|
20
|
+
url = "https://data.10jqka.com.cn/ipo/kzz/"
|
|
20
21
|
headers = {
|
|
21
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
22
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
23
|
+
"Chrome/89.0.4389.90 Safari/537.36",
|
|
22
24
|
}
|
|
23
25
|
r = requests.get(url, headers=headers)
|
|
24
26
|
data_json = r.json()
|
|
@@ -67,12 +69,18 @@ def bond_zh_cov_info_ths() -> pd.DataFrame:
|
|
|
67
69
|
"中签率",
|
|
68
70
|
]
|
|
69
71
|
]
|
|
70
|
-
temp_df["申购日期"] = pd.to_datetime(
|
|
71
|
-
|
|
72
|
+
temp_df["申购日期"] = pd.to_datetime(
|
|
73
|
+
temp_df["申购日期"], format="%Y-%m-%d", errors="coerce"
|
|
74
|
+
).dt.date
|
|
75
|
+
temp_df["中签公布日"] = pd.to_datetime(
|
|
76
|
+
temp_df["中签公布日"], format="%Y-%m-%d", errors="coerce"
|
|
77
|
+
).dt.date
|
|
72
78
|
temp_df["上市日期"] = pd.to_datetime(
|
|
73
79
|
temp_df["上市日期"], format="%Y-%m-%d", errors="coerce"
|
|
74
80
|
).dt.date
|
|
75
|
-
temp_df["到期时间"] = pd.to_datetime(
|
|
81
|
+
temp_df["到期时间"] = pd.to_datetime(
|
|
82
|
+
temp_df["到期时间"], format="%Y-%m-%d", errors="coerce"
|
|
83
|
+
).dt.date
|
|
76
84
|
temp_df["每股获配额"] = pd.to_numeric(temp_df["每股获配额"], errors="coerce")
|
|
77
85
|
temp_df["计划发行量"] = pd.to_numeric(temp_df["计划发行量"], errors="coerce")
|
|
78
86
|
temp_df["实际发行量"] = pd.to_numeric(temp_df["实际发行量"], errors="coerce")
|
akshare/bond/bond_cbond.py
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Date: 2022/9/20 17:46
|
|
5
5
|
Desc: 中国债券信息网-中债指数-中债指数族系-总指数-综合类指数
|
|
6
6
|
"""
|
|
7
|
+
|
|
7
8
|
import pandas as pd
|
|
8
9
|
import requests
|
|
9
10
|
|
|
@@ -58,17 +59,17 @@ def bond_new_composite_index_cbond(
|
|
|
58
59
|
url = "https://yield.chinabond.com.cn/cbweb-mn/indices/singleIndexQuery"
|
|
59
60
|
params = {
|
|
60
61
|
"indexid": "8a8b2ca0332abed20134ea76d8885831",
|
|
61
|
-
"": "",
|
|
62
|
+
"": "", # noqa: F601
|
|
62
63
|
"qxlxt": period_map[period],
|
|
63
|
-
"": "",
|
|
64
|
+
"": "", # noqa: F601
|
|
64
65
|
"ltcslx": "",
|
|
65
|
-
"": "",
|
|
66
|
-
"zslxt": indicator_map[indicator],
|
|
67
|
-
"": "",
|
|
68
|
-
"zslxt": indicator_map[indicator],
|
|
69
|
-
"": "",
|
|
66
|
+
"": "", # noqa: F601
|
|
67
|
+
"zslxt": indicator_map[indicator], # noqa: F601
|
|
68
|
+
"": "", # noqa: F601
|
|
69
|
+
"zslxt": indicator_map[indicator], # noqa: F601
|
|
70
|
+
"": "", # noqa: F601
|
|
70
71
|
"lx": "1",
|
|
71
|
-
"": "",
|
|
72
|
+
"": "", # noqa: F601
|
|
72
73
|
"locale": "",
|
|
73
74
|
}
|
|
74
75
|
r = requests.post(url, params=params)
|
|
@@ -79,8 +80,12 @@ def bond_new_composite_index_cbond(
|
|
|
79
80
|
)
|
|
80
81
|
temp_df.reset_index(inplace=True)
|
|
81
82
|
temp_df.columns = ["date", "value"]
|
|
82
|
-
temp_df[
|
|
83
|
-
temp_df["date"] =
|
|
83
|
+
temp_df["date"] = temp_df["date"].astype(float)
|
|
84
|
+
temp_df["date"] = (
|
|
85
|
+
pd.to_datetime(temp_df["date"], unit="ms", errors="coerce", utc=True)
|
|
86
|
+
.dt.tz_convert("Asia/Shanghai")
|
|
87
|
+
.dt.date
|
|
88
|
+
)
|
|
84
89
|
temp_df["value"] = pd.to_numeric(temp_df["value"], errors="coerce")
|
|
85
90
|
return temp_df
|
|
86
91
|
|
|
@@ -135,13 +140,13 @@ def bond_composite_index_cbond(
|
|
|
135
140
|
url = "https://yield.chinabond.com.cn/cbweb-mn/indices/singleIndexQuery"
|
|
136
141
|
params = {
|
|
137
142
|
"indexid": "2c90818811afed8d0111c0c672b31578",
|
|
138
|
-
"": "",
|
|
143
|
+
"": "", # noqa: F601
|
|
139
144
|
"qxlxt": period_map[period],
|
|
140
|
-
"": "",
|
|
145
|
+
"": "", # noqa: F601
|
|
141
146
|
"zslxt": indicator_map[indicator],
|
|
142
|
-
"": "",
|
|
147
|
+
"": "", # noqa: F601
|
|
143
148
|
"lx": "1",
|
|
144
|
-
"": "",
|
|
149
|
+
"": "", # noqa: F601
|
|
145
150
|
"locale": "",
|
|
146
151
|
}
|
|
147
152
|
r = requests.post(url, params=params)
|
akshare/bond/bond_china.py
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/
|
|
4
|
+
Date: 2024/10/1 17:00
|
|
5
5
|
Desc: 中国外汇交易中心暨全国银行间同业拆借中心
|
|
6
6
|
中国外汇交易中心暨全国银行间同业拆借中心-市场数据-债券市场行情-现券市场做市报价
|
|
7
7
|
中国外汇交易中心暨全国银行间同业拆借中心-市场数据-债券市场行情-现券市场成交行情
|
|
8
8
|
https://www.chinamoney.com.cn/chinese/mkdatabond/
|
|
9
9
|
"""
|
|
10
|
+
|
|
10
11
|
from io import StringIO
|
|
11
12
|
|
|
12
13
|
import pandas as pd
|
|
13
14
|
import requests
|
|
14
15
|
|
|
15
16
|
from akshare.bond.bond_china_money import bond_china_close_return_map
|
|
17
|
+
from akshare.utils.cons import headers
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
def bond_spot_quote() -> pd.DataFrame:
|
|
@@ -24,9 +26,6 @@ def bond_spot_quote() -> pd.DataFrame:
|
|
|
24
26
|
"""
|
|
25
27
|
bond_china_close_return_map()
|
|
26
28
|
url = "https://www.chinamoney.com.cn/ags/ms/cm-u-md-bond/CbMktMakQuot"
|
|
27
|
-
headers = {
|
|
28
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
|
|
29
|
-
}
|
|
30
29
|
payload = {
|
|
31
30
|
"flag": "1",
|
|
32
31
|
"lang": "cn",
|
|
@@ -61,16 +60,24 @@ def bond_spot_quote() -> pd.DataFrame:
|
|
|
61
60
|
"买入/卖出收益率",
|
|
62
61
|
]
|
|
63
62
|
]
|
|
64
|
-
temp_df["买入净价"] =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
temp_df["
|
|
63
|
+
temp_df["买入净价"] = (
|
|
64
|
+
temp_df["买入/卖出净价"].str.split("/", expand=True).iloc[:, 0]
|
|
65
|
+
)
|
|
66
|
+
temp_df["卖出净价"] = (
|
|
67
|
+
temp_df["买入/卖出净价"].str.split("/", expand=True).iloc[:, 1]
|
|
68
|
+
)
|
|
69
|
+
temp_df["买入收益率"] = (
|
|
70
|
+
temp_df["买入/卖出收益率"].str.split("/", expand=True).iloc[:, 0]
|
|
71
|
+
)
|
|
72
|
+
temp_df["卖出收益率"] = (
|
|
73
|
+
temp_df["买入/卖出收益率"].str.split("/", expand=True).iloc[:, 1]
|
|
74
|
+
)
|
|
68
75
|
del temp_df["买入/卖出净价"]
|
|
69
76
|
del temp_df["买入/卖出收益率"]
|
|
70
|
-
temp_df[
|
|
71
|
-
temp_df[
|
|
72
|
-
temp_df[
|
|
73
|
-
temp_df[
|
|
77
|
+
temp_df["买入净价"] = pd.to_numeric(temp_df["买入净价"], errors="coerce")
|
|
78
|
+
temp_df["卖出净价"] = pd.to_numeric(temp_df["卖出净价"], errors="coerce")
|
|
79
|
+
temp_df["买入收益率"] = pd.to_numeric(temp_df["买入收益率"], errors="coerce")
|
|
80
|
+
temp_df["卖出收益率"] = pd.to_numeric(temp_df["卖出收益率"], errors="coerce")
|
|
74
81
|
return temp_df
|
|
75
82
|
|
|
76
83
|
|
|
@@ -82,9 +89,6 @@ def bond_spot_deal() -> pd.DataFrame:
|
|
|
82
89
|
:rtype: pandas.DataFrame
|
|
83
90
|
"""
|
|
84
91
|
url = "https://www.chinamoney.com.cn/ags/ms/cm-u-md-bond/CbtPri"
|
|
85
|
-
headers = {
|
|
86
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
|
|
87
|
-
}
|
|
88
92
|
payload = {
|
|
89
93
|
"flag": "1",
|
|
90
94
|
"lang": "cn",
|
|
@@ -127,16 +131,16 @@ def bond_spot_deal() -> pd.DataFrame:
|
|
|
127
131
|
"交易量",
|
|
128
132
|
]
|
|
129
133
|
]
|
|
130
|
-
temp_df[
|
|
131
|
-
temp_df[
|
|
132
|
-
temp_df[
|
|
133
|
-
temp_df[
|
|
134
|
-
temp_df[
|
|
134
|
+
temp_df["成交净价"] = pd.to_numeric(temp_df["成交净价"], errors="coerce")
|
|
135
|
+
temp_df["最新收益率"] = pd.to_numeric(temp_df["最新收益率"], errors="coerce")
|
|
136
|
+
temp_df["涨跌"] = pd.to_numeric(temp_df["涨跌"], errors="coerce")
|
|
137
|
+
temp_df["加权收益率"] = pd.to_numeric(temp_df["加权收益率"], errors="coerce")
|
|
138
|
+
temp_df["交易量"] = pd.to_numeric(temp_df["交易量"], errors="coerce")
|
|
135
139
|
return temp_df
|
|
136
140
|
|
|
137
141
|
|
|
138
142
|
def bond_china_yield(
|
|
139
|
-
|
|
143
|
+
start_date: str = "20200204", end_date: str = "20210124"
|
|
140
144
|
) -> pd.DataFrame:
|
|
141
145
|
"""
|
|
142
146
|
中国债券信息网-国债及其他债券收益率曲线
|
|
@@ -152,28 +156,25 @@ def bond_china_yield(
|
|
|
152
156
|
"""
|
|
153
157
|
url = "https://yield.chinabond.com.cn/cbweb-pbc-web/pbc/historyQuery"
|
|
154
158
|
params = {
|
|
155
|
-
"startDate":
|
|
156
|
-
"endDate":
|
|
159
|
+
"startDate": "-".join([start_date[:4], start_date[4:6], start_date[6:]]),
|
|
160
|
+
"endDate": "-".join([end_date[:4], end_date[4:6], end_date[6:]]),
|
|
157
161
|
"gjqx": "0",
|
|
158
162
|
"qxId": "ycqx",
|
|
159
163
|
"locale": "cn_ZH",
|
|
160
164
|
}
|
|
161
|
-
headers = {
|
|
162
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36",
|
|
163
|
-
}
|
|
164
165
|
res = requests.get(url, params=params, headers=headers)
|
|
165
166
|
data_text = res.text.replace(" ", "")
|
|
166
167
|
data_df = pd.read_html(StringIO(data_text), header=0)[1]
|
|
167
|
-
data_df[
|
|
168
|
-
data_df[
|
|
169
|
-
data_df[
|
|
170
|
-
data_df[
|
|
171
|
-
data_df[
|
|
172
|
-
data_df[
|
|
173
|
-
data_df[
|
|
174
|
-
data_df[
|
|
175
|
-
data_df[
|
|
176
|
-
data_df.sort_values(by=
|
|
168
|
+
data_df["日期"] = pd.to_datetime(data_df["日期"], errors="coerce").dt.date
|
|
169
|
+
data_df["3月"] = pd.to_numeric(data_df["3月"], errors="coerce")
|
|
170
|
+
data_df["6月"] = pd.to_numeric(data_df["6月"], errors="coerce")
|
|
171
|
+
data_df["1年"] = pd.to_numeric(data_df["1年"], errors="coerce")
|
|
172
|
+
data_df["3年"] = pd.to_numeric(data_df["3年"], errors="coerce")
|
|
173
|
+
data_df["5年"] = pd.to_numeric(data_df["5年"], errors="coerce")
|
|
174
|
+
data_df["7年"] = pd.to_numeric(data_df["7年"], errors="coerce")
|
|
175
|
+
data_df["10年"] = pd.to_numeric(data_df["10年"], errors="coerce")
|
|
176
|
+
data_df["30年"] = pd.to_numeric(data_df["30年"], errors="coerce")
|
|
177
|
+
data_df.sort_values(by="日期", inplace=True)
|
|
177
178
|
data_df.reset_index(inplace=True, drop=True)
|
|
178
179
|
return data_df
|
|
179
180
|
|
|
@@ -185,7 +186,5 @@ if __name__ == "__main__":
|
|
|
185
186
|
bond_spot_deal_df = bond_spot_deal()
|
|
186
187
|
print(bond_spot_deal_df)
|
|
187
188
|
|
|
188
|
-
bond_china_yield_df = bond_china_yield(
|
|
189
|
-
start_date="20210201", end_date="20220201"
|
|
190
|
-
)
|
|
189
|
+
bond_china_yield_df = bond_china_yield(start_date="20210201", end_date="20220201")
|
|
191
190
|
print(bond_china_yield_df)
|