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,232 @@
|
|
|
1
|
+
# -*- coding:utf-8 -*-
|
|
2
|
+
# !/usr/bin/env python
|
|
3
|
+
"""
|
|
4
|
+
Date: 2024/8/10 15:30
|
|
5
|
+
Desc: 搜猪-生猪大数据-各省均价实时排行榜
|
|
6
|
+
https://www.soozhu.com/price/data/center/
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import pandas as pd
|
|
10
|
+
import requests
|
|
11
|
+
from bs4 import BeautifulSoup
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def spot_hog_soozhu() -> pd.DataFrame:
|
|
15
|
+
"""
|
|
16
|
+
搜猪-生猪大数据-各省均价实时排行榜
|
|
17
|
+
https://www.soozhu.com/price/data/center/
|
|
18
|
+
:return: 各省均价实时排行榜
|
|
19
|
+
:rtype: pandas.DataFrame
|
|
20
|
+
"""
|
|
21
|
+
session = requests.session()
|
|
22
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
23
|
+
r = session.get(url)
|
|
24
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
25
|
+
token = soup.find(name="input", attrs={"name": "csrfmiddlewaretoken"})["value"]
|
|
26
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
27
|
+
payload = {"act": "mapdata", "csrfmiddlewaretoken": token}
|
|
28
|
+
r = session.post(url, data=payload)
|
|
29
|
+
data_json = r.json()
|
|
30
|
+
temp_df = pd.DataFrame(data_json["vlist"])
|
|
31
|
+
price_list = [item[0] for item in temp_df["value"]]
|
|
32
|
+
pct_list = [item[1] for item in temp_df["value"]]
|
|
33
|
+
big_df = pd.DataFrame([temp_df["name"].values, price_list, pct_list]).T
|
|
34
|
+
big_df.columns = ["省份", "价格", "涨跌幅"]
|
|
35
|
+
big_df["价格"] = pd.to_numeric(big_df["价格"], errors="coerce")
|
|
36
|
+
big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"], errors="coerce")
|
|
37
|
+
big_df["涨跌幅"] = round(big_df["涨跌幅"], 2)
|
|
38
|
+
return big_df
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def spot_hog_year_trend_soozhu() -> pd.DataFrame:
|
|
42
|
+
"""
|
|
43
|
+
搜猪-生猪大数据-今年以来全国出栏均价走势
|
|
44
|
+
https://www.soozhu.com/price/data/center/
|
|
45
|
+
:return: 今年以来全国出栏均价走势
|
|
46
|
+
:rtype: pandas.DataFrame
|
|
47
|
+
"""
|
|
48
|
+
session = requests.session()
|
|
49
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
50
|
+
r = session.get(url)
|
|
51
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
52
|
+
token = soup.find(name="input", attrs={"name": "csrfmiddlewaretoken"})["value"]
|
|
53
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
54
|
+
payload = {"act": "yeartrend", "csrfmiddlewaretoken": token}
|
|
55
|
+
r = session.post(url, data=payload)
|
|
56
|
+
data_json = r.json()
|
|
57
|
+
temp_df = pd.DataFrame(data_json["nationlist"])
|
|
58
|
+
temp_df.columns = ["日期", "价格"]
|
|
59
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
60
|
+
temp_df["价格"] = pd.to_numeric(temp_df["价格"], errors="coerce")
|
|
61
|
+
temp_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
|
|
62
|
+
return temp_df
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def spot_hog_lean_price_soozhu() -> pd.DataFrame:
|
|
66
|
+
"""
|
|
67
|
+
搜猪-生猪大数据-全国瘦肉型肉猪
|
|
68
|
+
https://www.soozhu.com/price/data/center/
|
|
69
|
+
:return: 全国瘦肉型肉猪
|
|
70
|
+
:rtype: pandas.DataFrame
|
|
71
|
+
"""
|
|
72
|
+
session = requests.session()
|
|
73
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
74
|
+
r = session.get(url)
|
|
75
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
76
|
+
token = soup.find(name="input", attrs={"name": "csrfmiddlewaretoken"})["value"]
|
|
77
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
78
|
+
payload = {"act": "pricetrend", "indid": "", "csrfmiddlewaretoken": token}
|
|
79
|
+
r = session.post(url, data=payload)
|
|
80
|
+
data_json = r.json()
|
|
81
|
+
temp_df = pd.DataFrame(data_json["datalist"])
|
|
82
|
+
temp_df.columns = ["日期", "价格"]
|
|
83
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
84
|
+
temp_df["价格"] = pd.to_numeric(temp_df["价格"], errors="coerce")
|
|
85
|
+
temp_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
|
|
86
|
+
return temp_df
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def spot_hog_three_way_soozhu() -> pd.DataFrame:
|
|
90
|
+
"""
|
|
91
|
+
搜猪-生猪大数据-全国三元仔猪
|
|
92
|
+
https://www.soozhu.com/price/data/center/
|
|
93
|
+
:return: 全国三元仔猪
|
|
94
|
+
:rtype: pandas.DataFrame
|
|
95
|
+
"""
|
|
96
|
+
session = requests.session()
|
|
97
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
98
|
+
r = session.get(url)
|
|
99
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
100
|
+
token = soup.find(name="input", attrs={"name": "csrfmiddlewaretoken"})["value"]
|
|
101
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
102
|
+
payload = {"act": "pricetrend", "indid": "4", "csrfmiddlewaretoken": token}
|
|
103
|
+
r = session.post(url, data=payload)
|
|
104
|
+
data_json = r.json()
|
|
105
|
+
temp_df = pd.DataFrame(data_json["datalist"])
|
|
106
|
+
temp_df.columns = ["日期", "价格"]
|
|
107
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
108
|
+
temp_df["价格"] = pd.to_numeric(temp_df["价格"], errors="coerce")
|
|
109
|
+
temp_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
|
|
110
|
+
return temp_df
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def spot_hog_crossbred_soozhu() -> pd.DataFrame:
|
|
114
|
+
"""
|
|
115
|
+
搜猪-生猪大数据-全国后备二元母猪
|
|
116
|
+
https://www.soozhu.com/price/data/center/
|
|
117
|
+
:return: 全国后备二元母猪
|
|
118
|
+
:rtype: pandas.DataFrame
|
|
119
|
+
"""
|
|
120
|
+
session = requests.session()
|
|
121
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
122
|
+
r = session.get(url)
|
|
123
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
124
|
+
token = soup.find(name="input", attrs={"name": "csrfmiddlewaretoken"})["value"]
|
|
125
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
126
|
+
payload = {"act": "pricetrend", "indid": "6", "csrfmiddlewaretoken": token}
|
|
127
|
+
r = session.post(url, data=payload)
|
|
128
|
+
data_json = r.json()
|
|
129
|
+
temp_df = pd.DataFrame(data_json["datalist"])
|
|
130
|
+
temp_df.columns = ["日期", "价格"]
|
|
131
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
132
|
+
temp_df["价格"] = pd.to_numeric(temp_df["价格"], errors="coerce")
|
|
133
|
+
temp_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
|
|
134
|
+
return temp_df
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def spot_corn_price_soozhu() -> pd.DataFrame:
|
|
138
|
+
"""
|
|
139
|
+
搜猪-生猪大数据-全国玉米价格走势
|
|
140
|
+
https://www.soozhu.com/price/data/center/
|
|
141
|
+
:return: 全国玉米价格走势
|
|
142
|
+
:rtype: pandas.DataFrame
|
|
143
|
+
"""
|
|
144
|
+
session = requests.session()
|
|
145
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
146
|
+
r = session.get(url)
|
|
147
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
148
|
+
token = soup.find(name="input", attrs={"name": "csrfmiddlewaretoken"})["value"]
|
|
149
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
150
|
+
payload = {"act": "pricetrend", "indid": "8", "csrfmiddlewaretoken": token}
|
|
151
|
+
r = session.post(url, data=payload)
|
|
152
|
+
data_json = r.json()
|
|
153
|
+
temp_df = pd.DataFrame(data_json["datalist"])
|
|
154
|
+
temp_df.columns = ["日期", "价格"]
|
|
155
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
156
|
+
temp_df["价格"] = pd.to_numeric(temp_df["价格"], errors="coerce")
|
|
157
|
+
temp_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
|
|
158
|
+
return temp_df
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def spot_soybean_price_soozhu() -> pd.DataFrame:
|
|
162
|
+
"""
|
|
163
|
+
搜猪-生猪大数据-全国豆粕价格走势
|
|
164
|
+
https://www.soozhu.com/price/data/center/
|
|
165
|
+
:return: 全国豆粕价格走势
|
|
166
|
+
:rtype: pandas.DataFrame
|
|
167
|
+
"""
|
|
168
|
+
session = requests.session()
|
|
169
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
170
|
+
r = session.get(url)
|
|
171
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
172
|
+
token = soup.find(name="input", attrs={"name": "csrfmiddlewaretoken"})["value"]
|
|
173
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
174
|
+
payload = {"act": "pricetrend", "indid": "9", "csrfmiddlewaretoken": token}
|
|
175
|
+
r = session.post(url, data=payload)
|
|
176
|
+
data_json = r.json()
|
|
177
|
+
temp_df = pd.DataFrame(data_json["datalist"])
|
|
178
|
+
temp_df.columns = ["日期", "价格"]
|
|
179
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
180
|
+
temp_df["价格"] = pd.to_numeric(temp_df["价格"], errors="coerce")
|
|
181
|
+
temp_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
|
|
182
|
+
return temp_df
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def spot_mixed_feed_soozhu() -> pd.DataFrame:
|
|
186
|
+
"""
|
|
187
|
+
搜猪-生猪大数据-全国育肥猪合料(含自配料)半月走势
|
|
188
|
+
https://www.soozhu.com/price/data/center/
|
|
189
|
+
:return: 全国育肥猪合料(含自配料)半月走势
|
|
190
|
+
:rtype: pandas.DataFrame
|
|
191
|
+
"""
|
|
192
|
+
session = requests.session()
|
|
193
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
194
|
+
r = session.get(url)
|
|
195
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
196
|
+
token = soup.find(name="input", attrs={"name": "csrfmiddlewaretoken"})["value"]
|
|
197
|
+
url = "https://www.soozhu.com/price/data/center/"
|
|
198
|
+
payload = {"act": "pricetrend", "indid": "11", "csrfmiddlewaretoken": token}
|
|
199
|
+
r = session.post(url, data=payload)
|
|
200
|
+
data_json = r.json()
|
|
201
|
+
temp_df = pd.DataFrame(data_json["datalist"])
|
|
202
|
+
temp_df.columns = ["日期", "价格"]
|
|
203
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
204
|
+
temp_df["价格"] = pd.to_numeric(temp_df["价格"], errors="coerce")
|
|
205
|
+
temp_df.sort_values(by=["日期"], ignore_index=True, inplace=True)
|
|
206
|
+
return temp_df
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
if __name__ == "__main__":
|
|
210
|
+
spot_hog_soozhu_df = spot_hog_soozhu()
|
|
211
|
+
print(spot_hog_soozhu_df)
|
|
212
|
+
|
|
213
|
+
spot_hog_year_trend_soozhu_df = spot_hog_year_trend_soozhu()
|
|
214
|
+
print(spot_hog_year_trend_soozhu_df)
|
|
215
|
+
|
|
216
|
+
spot_hog_lean_price_soozhu_df = spot_hog_lean_price_soozhu()
|
|
217
|
+
print(spot_hog_lean_price_soozhu_df)
|
|
218
|
+
|
|
219
|
+
spot_hog_three_way_soozhu_df = spot_hog_three_way_soozhu()
|
|
220
|
+
print(spot_hog_three_way_soozhu_df)
|
|
221
|
+
|
|
222
|
+
spot_hog_crossbred_soozhu_df = spot_hog_crossbred_soozhu()
|
|
223
|
+
print(spot_hog_crossbred_soozhu_df)
|
|
224
|
+
|
|
225
|
+
spot_corn_price_soozhu_df = spot_corn_price_soozhu()
|
|
226
|
+
print(spot_corn_price_soozhu_df)
|
|
227
|
+
|
|
228
|
+
spot_soybean_price_soozhu_df = spot_soybean_price_soozhu()
|
|
229
|
+
print(spot_soybean_price_soozhu_df)
|
|
230
|
+
|
|
231
|
+
spot_mixed_feed_soozhu_df = spot_mixed_feed_soozhu()
|
|
232
|
+
print(spot_mixed_feed_soozhu_df)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# -*- coding:utf-8 -*-
|
|
2
|
+
# !/usr/bin/env python
|
|
3
|
+
"""
|
|
4
|
+
Date: 2024/5/16 20:00
|
|
5
|
+
Desc: 99 期货-数据-期现-现货走势
|
|
6
|
+
https://www.99qh.com/data/spotTrend
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import json
|
|
10
|
+
|
|
11
|
+
import pandas as pd
|
|
12
|
+
import requests
|
|
13
|
+
from bs4 import BeautifulSoup
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def __get_item_of_spot_price_qh() -> pd.DataFrame:
|
|
17
|
+
"""
|
|
18
|
+
99 期货-数据-期现-品种和 ID 对应表
|
|
19
|
+
https://www.99qh.com/data/spotTrend
|
|
20
|
+
:return: 品种和 ID 对应表
|
|
21
|
+
:rtype: str
|
|
22
|
+
"""
|
|
23
|
+
url = "https://www.99qh.com/data/spotTrend"
|
|
24
|
+
r = requests.get(url)
|
|
25
|
+
soup = BeautifulSoup(r.text, features="lxml")
|
|
26
|
+
data_text = soup.find(name="script", attrs={"id": "__NEXT_DATA__"}).text
|
|
27
|
+
data_json = json.loads(data_text)
|
|
28
|
+
big_list = []
|
|
29
|
+
for item in data_json["props"]["pageProps"]["data"]["varietyListData"]:
|
|
30
|
+
big_list.extend(item["productList"])
|
|
31
|
+
temp_df = pd.DataFrame(big_list)
|
|
32
|
+
temp_df = temp_df[["qhExchangeName", "name", "productId"]]
|
|
33
|
+
return temp_df
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def __get_token_of_spot_price_qh() -> str:
|
|
37
|
+
"""
|
|
38
|
+
99 期货-数据-期现-token
|
|
39
|
+
https://www.99qh.com/data/spotTrend
|
|
40
|
+
:return: token
|
|
41
|
+
:rtype: str
|
|
42
|
+
"""
|
|
43
|
+
url = "https://centerapi.fx168api.com/app/common/v.js"
|
|
44
|
+
headers = {
|
|
45
|
+
"Origin": "https://www.99qh.com",
|
|
46
|
+
"Referer": "https://www.99qh.com",
|
|
47
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
48
|
+
"Chrome/124.0.0.0 Safari/537.36",
|
|
49
|
+
}
|
|
50
|
+
r = requests.get(url, headers=headers)
|
|
51
|
+
token = r.headers["_pcc"]
|
|
52
|
+
return token
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def spot_price_table_qh() -> pd.DataFrame:
|
|
56
|
+
"""
|
|
57
|
+
99 期货-数据-期现-交易所与品种对照表
|
|
58
|
+
https://www.99qh.com/data/spotTrend
|
|
59
|
+
:return: 交易所与品种对照表
|
|
60
|
+
:rtype: pandas.DataFrame
|
|
61
|
+
"""
|
|
62
|
+
temp_df = __get_item_of_spot_price_qh()
|
|
63
|
+
temp_df.rename(
|
|
64
|
+
columns={
|
|
65
|
+
"qhExchangeName": "交易所名称",
|
|
66
|
+
"name": "品种名称",
|
|
67
|
+
},
|
|
68
|
+
inplace=True,
|
|
69
|
+
)
|
|
70
|
+
temp_df = temp_df[
|
|
71
|
+
[
|
|
72
|
+
"交易所名称",
|
|
73
|
+
"品种名称",
|
|
74
|
+
]
|
|
75
|
+
]
|
|
76
|
+
return temp_df
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def spot_price_qh(symbol: str = "螺纹钢") -> pd.DataFrame:
|
|
80
|
+
"""
|
|
81
|
+
99 期货-数据-期现-现货走势
|
|
82
|
+
https://www.99qh.com/data/spotTrend
|
|
83
|
+
:param symbol: 品种名称
|
|
84
|
+
:type symbol: str
|
|
85
|
+
:return: 现货走势
|
|
86
|
+
:rtype: pandas.DataFrame
|
|
87
|
+
"""
|
|
88
|
+
inner_df = __get_item_of_spot_price_qh()
|
|
89
|
+
symbol_map = dict(zip(inner_df["name"], inner_df["productId"]))
|
|
90
|
+
url = "https://centerapi.fx168api.com/app/qh/api/spot/trend"
|
|
91
|
+
headers = {
|
|
92
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
93
|
+
"Chrome/124.0.0.0 Safari/537.36",
|
|
94
|
+
"_pcc": __get_token_of_spot_price_qh(),
|
|
95
|
+
"Origin": "https://www.99qh.com",
|
|
96
|
+
"Referer": "https://www.99qh.com",
|
|
97
|
+
}
|
|
98
|
+
params = {
|
|
99
|
+
"productId": symbol_map[symbol],
|
|
100
|
+
"pageNo": "1",
|
|
101
|
+
"pageSize": "50000",
|
|
102
|
+
"startDate": "",
|
|
103
|
+
"endDate": "2050-01-01",
|
|
104
|
+
"appCategory": "web",
|
|
105
|
+
}
|
|
106
|
+
r = requests.get(url, params=params, headers=headers)
|
|
107
|
+
data_json = r.json()
|
|
108
|
+
temp_df = pd.DataFrame(data_json["data"]["list"])
|
|
109
|
+
temp_df.rename(
|
|
110
|
+
columns={"date": "日期", "fp": "期货收盘价", "sp": "现货价格"}, inplace=True
|
|
111
|
+
)
|
|
112
|
+
temp_df.sort_values(by=["日期"], inplace=True, ignore_index=True)
|
|
113
|
+
temp_df["日期"] = pd.to_datetime(temp_df["日期"], errors="coerce").dt.date
|
|
114
|
+
temp_df["期货收盘价"] = pd.to_numeric(temp_df["期货收盘价"], errors="coerce")
|
|
115
|
+
temp_df["现货价格"] = pd.to_numeric(temp_df["现货价格"], errors="coerce")
|
|
116
|
+
return temp_df
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
if __name__ == "__main__":
|
|
120
|
+
spot_price_qh_df = spot_price_qh(symbol="螺纹钢")
|
|
121
|
+
print(spot_price_qh_df)
|
akshare/spot/spot_sge.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- coding:utf-8 -*-
|
|
2
2
|
# !/usr/bin/env python
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2025/4/11 22:00
|
|
5
5
|
Desc: 上海黄金交易所-数据资讯-行情走势
|
|
6
6
|
https://www.sge.com.cn/sjzx/mrhq
|
|
7
7
|
上海黄金交易所-数据资讯-上海金基准价-历史数据
|
|
@@ -11,6 +11,8 @@ https://www.sge.com.cn/sjzx/mrhq
|
|
|
11
11
|
import pandas as pd
|
|
12
12
|
import requests
|
|
13
13
|
|
|
14
|
+
from akshare.utils.cons import headers
|
|
15
|
+
|
|
14
16
|
|
|
15
17
|
def spot_symbol_table_sge() -> pd.DataFrame:
|
|
16
18
|
"""
|
|
@@ -45,11 +47,72 @@ def spot_symbol_table_sge() -> pd.DataFrame:
|
|
|
45
47
|
return temp_df
|
|
46
48
|
|
|
47
49
|
|
|
50
|
+
def spot_quotations_sge(symbol: str = "Au99.99") -> pd.DataFrame:
|
|
51
|
+
"""
|
|
52
|
+
上海黄金交易所-实时行情数据
|
|
53
|
+
https://www.sge.com.cn/
|
|
54
|
+
https://www.sge.com.cn/graph/quotations
|
|
55
|
+
:param symbol: choice of {'Au99.99', 'Au99.95', 'Au100g', 'Pt99.95', 'Ag(T+D)', 'Au(T+D)',
|
|
56
|
+
'mAu(T+D)', 'Au(T+N1)', 'Au(T+N2)', 'Ag99.99', 'iAu99.99', 'Au99.5', 'iAu100g',
|
|
57
|
+
'iAu99.5', 'PGC30g', 'NYAuTN06', 'NYAuTN12'}; 可以通过 ak.spot_symbol_table_sge() 获取品种表
|
|
58
|
+
:type symbol: str
|
|
59
|
+
:return: 行情数据
|
|
60
|
+
:rtype: pandas.DataFrame
|
|
61
|
+
"""
|
|
62
|
+
url = "https://www.sge.com.cn/graph/quotations"
|
|
63
|
+
payload = {"instid": symbol}
|
|
64
|
+
headers = {
|
|
65
|
+
"Accept": "application/json, text/javascript, */*; q=0.01",
|
|
66
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
|
67
|
+
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
|
68
|
+
"Cache-Control": "no-cache",
|
|
69
|
+
"Connection": "keep-alive",
|
|
70
|
+
"Content-Length": "15",
|
|
71
|
+
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
|
72
|
+
"Host": "www.sge.com.cn",
|
|
73
|
+
"Origin": "https://www.sge.com.cn",
|
|
74
|
+
"Pragma": "no-cache",
|
|
75
|
+
"Referer": "https://www.sge.com.cn/",
|
|
76
|
+
"sec-ch-ua": '"Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24"',
|
|
77
|
+
"sec-ch-ua-mobile": "?0",
|
|
78
|
+
"sec-ch-ua-platform": '"Windows"',
|
|
79
|
+
"Sec-Fetch-Dest": "empty",
|
|
80
|
+
"Sec-Fetch-Mode": "cors",
|
|
81
|
+
"Sec-Fetch-Site": "same-origin",
|
|
82
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
83
|
+
"Chrome/107.0.0.0 Safari/537.36",
|
|
84
|
+
"X-Requested-With": "XMLHttpRequest",
|
|
85
|
+
}
|
|
86
|
+
r = requests.get(url, data=payload, headers=headers)
|
|
87
|
+
data_json = r.json()
|
|
88
|
+
temp_df = pd.DataFrame(
|
|
89
|
+
{
|
|
90
|
+
"品种": data_json["heyue"],
|
|
91
|
+
"时间": data_json["times"],
|
|
92
|
+
"现价": data_json["data"],
|
|
93
|
+
"更新时间": data_json["delaystr"],
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
temp_df["现价"] = pd.to_numeric(temp_df["现价"], errors="coerce")
|
|
97
|
+
# 将更新时间中的时间部分提取出来
|
|
98
|
+
update_time = temp_df["更新时间"].iloc[0].split()[1]
|
|
99
|
+
# 将时间列转换为时间格式以便排序
|
|
100
|
+
temp_df["时间"] = pd.to_datetime(temp_df["时间"], format="%H:%M").dt.time
|
|
101
|
+
# 过滤掉大于等于更新时间的数据
|
|
102
|
+
temp_df = temp_df[temp_df["时间"].astype(str) < update_time]
|
|
103
|
+
# 按时间排序
|
|
104
|
+
temp_df = temp_df.sort_values(by=["时间"])
|
|
105
|
+
temp_df.reset_index(inplace=True, drop=True)
|
|
106
|
+
return temp_df
|
|
107
|
+
|
|
108
|
+
|
|
48
109
|
def spot_hist_sge(symbol: str = "Au99.99") -> pd.DataFrame:
|
|
49
110
|
"""
|
|
50
111
|
上海黄金交易所-数据资讯-行情走势-历史数据
|
|
51
112
|
https://www.sge.com.cn/sjzx/mrhq
|
|
52
|
-
:param symbol: choice of {'Au99.99', 'Au99.95', 'Au100g', 'Pt99.95', 'Ag(T+D)', 'Au(T+D)',
|
|
113
|
+
:param symbol: choice of {'Au99.99', 'Au99.95', 'Au100g', 'Pt99.95', 'Ag(T+D)', 'Au(T+D)',
|
|
114
|
+
'mAu(T+D)', 'Au(T+N1)', 'Au(T+N2)', 'Ag99.99', 'iAu99.99', 'Au99.5', 'iAu100g', 'iAu99.5',
|
|
115
|
+
'PGC30g', 'NYAuTN06', 'NYAuTN12'}; 可以通过 ak.spot_symbol_table_sge() 获取品种表
|
|
53
116
|
:type symbol: str
|
|
54
117
|
:return: 历史数据
|
|
55
118
|
:rtype: pandas.DataFrame
|
|
@@ -74,7 +137,8 @@ def spot_hist_sge(symbol: str = "Au99.99") -> pd.DataFrame:
|
|
|
74
137
|
"Sec-Fetch-Dest": "empty",
|
|
75
138
|
"Sec-Fetch-Mode": "cors",
|
|
76
139
|
"Sec-Fetch-Site": "same-origin",
|
|
77
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
140
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
141
|
+
"Chrome/107.0.0.0 Safari/537.36",
|
|
78
142
|
"X-Requested-With": "XMLHttpRequest",
|
|
79
143
|
}
|
|
80
144
|
r = requests.post(url, data=payload, headers=headers)
|
|
@@ -105,9 +169,6 @@ def spot_golden_benchmark_sge() -> pd.DataFrame:
|
|
|
105
169
|
"""
|
|
106
170
|
url = "https://www.sge.com.cn/graph/DayilyJzj"
|
|
107
171
|
payload = {}
|
|
108
|
-
headers = {
|
|
109
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36",
|
|
110
|
-
}
|
|
111
172
|
r = requests.post(url, data=payload, headers=headers)
|
|
112
173
|
data_json = r.json()
|
|
113
174
|
temp_df = pd.DataFrame(data_json["wp"])
|
|
@@ -139,9 +200,6 @@ def spot_silver_benchmark_sge() -> pd.DataFrame:
|
|
|
139
200
|
"""
|
|
140
201
|
url = "https://www.sge.com.cn/graph/DayilyShsilverJzj"
|
|
141
202
|
payload = {}
|
|
142
|
-
headers = {
|
|
143
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36",
|
|
144
|
-
}
|
|
145
203
|
r = requests.post(url, data=payload, headers=headers)
|
|
146
204
|
data_json = r.json()
|
|
147
205
|
temp_df = pd.DataFrame(data_json["wp"])
|
|
@@ -180,3 +238,6 @@ if __name__ == "__main__":
|
|
|
180
238
|
for spot in spot_symbol_table_sge_df["品种"].tolist():
|
|
181
239
|
spot_hist_sge_df = spot_hist_sge(symbol=spot)
|
|
182
240
|
print(spot_hist_sge_df)
|
|
241
|
+
|
|
242
|
+
spot_quotations_sge_df = spot_quotations_sge(symbol="Au99.99")
|
|
243
|
+
print(spot_quotations_sge_df)
|
akshare/stock/cons.py
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2025/12/12 15:00
|
|
5
5
|
Desc: 股票配置文件
|
|
6
6
|
"""
|
|
7
|
+
|
|
8
|
+
xq_a_token = "7ed879d430984f6ea5a546808b7b9fcd64f39eb9"
|
|
9
|
+
|
|
7
10
|
# zh-sina-kcb
|
|
8
|
-
zh_sina_kcb_stock_url = "http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/
|
|
11
|
+
zh_sina_kcb_stock_url = ("http://vip.stock.finance.sina.com.cn/quotes_service/api/json_v2.php/"
|
|
12
|
+
"Market_Center.getHQNodeData")
|
|
9
13
|
zh_sina_kcb_stock_payload = {
|
|
10
14
|
"page": "1",
|
|
11
15
|
"num": "80",
|
|
@@ -13,11 +17,14 @@ zh_sina_kcb_stock_payload = {
|
|
|
13
17
|
"asc": "1",
|
|
14
18
|
"node": "kcb",
|
|
15
19
|
"symbol": "",
|
|
16
|
-
"_s_r_a": "auto"
|
|
20
|
+
"_s_r_a": "auto",
|
|
17
21
|
}
|
|
18
|
-
zh_sina_kcb_stock_count_url = "http://vip.stock.finance.sina.com.cn/quotes_service/api/
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
zh_sina_kcb_stock_count_url = ("http://vip.stock.finance.sina.com.cn/quotes_service/api/"
|
|
23
|
+
"json_v2.php/Market_Center.getHQNodeStockCount?node=kcb")
|
|
24
|
+
zh_sina_kcb_stock_hist_url = ("https://quotes.sina.cn/cn/api/jsonp.php/var%20_{}{}=/"
|
|
25
|
+
"KC_MarketDataService.getKLineData?symbol={}")
|
|
26
|
+
zh_sina_kcb_stock_amount_url = ("https://stock.finance.sina.com.cn/stock/api/jsonp.php/"
|
|
27
|
+
"var%20KKE_ShareAmount_{}=/StockService.getAmountBySymbol?_=20&symbol={}")
|
|
21
28
|
zh_sina_kcb_stock_hfq_url = "https://finance.sina.com.cn/realstock/company/{}/hfq.js"
|
|
22
29
|
zh_sina_kcb_stock_qfq_url = "https://finance.sina.com.cn/realstock/company/{}/qfq.js"
|
|
23
30
|
|
|
@@ -30,25 +37,34 @@ zh_sina_a_stock_payload = {
|
|
|
30
37
|
"asc": "1",
|
|
31
38
|
"node": "hs_a",
|
|
32
39
|
"symbol": "",
|
|
33
|
-
"_s_r_a": "page"
|
|
40
|
+
"_s_r_a": "page",
|
|
34
41
|
}
|
|
35
|
-
zh_sina_a_stock_count_url = "http://vip.stock.finance.sina.com.cn/quotes_service/api/
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
zh_sina_a_stock_count_url = ("http://vip.stock.finance.sina.com.cn/quotes_service/api/"
|
|
43
|
+
"json_v2.php/Market_Center.getHQNodeStockCount?node=hs_a")
|
|
44
|
+
zh_sina_a_stock_hist_url = (
|
|
45
|
+
"https://finance.sina.com.cn/realstock/company/{}/hisdata_klc2/klc_kl.js"
|
|
46
|
+
)
|
|
47
|
+
zh_sina_a_stock_amount_url = ("https://stock.finance.sina.com.cn/stock/api/jsonp.php/"
|
|
48
|
+
"var%20KKE_ShareAmount_{}=/StockService.getAmountBySymbol?_=20&symbol={}")
|
|
38
49
|
zh_sina_a_stock_hfq_url = "https://finance.sina.com.cn/realstock/company/{}/hfq.js"
|
|
39
50
|
zh_sina_a_stock_qfq_url = "https://finance.sina.com.cn/realstock/company/{}/qfq.js"
|
|
40
51
|
|
|
41
52
|
# us-sina
|
|
42
|
-
us_sina_stock_hist_qfq_url =
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
us_sina_stock_hist_qfq_url = (
|
|
54
|
+
"https://finance.sina.com.cn/us_stock/company/reinstatement/{}_qfq.js"
|
|
55
|
+
)
|
|
56
|
+
us_sina_stock_hist_url = (
|
|
57
|
+
"https://finance.sina.com.cn/us_stock/company/hisdata/klc_kl_{}.js"
|
|
58
|
+
)
|
|
59
|
+
us_sina_stock_list_url = ("http://stock.finance.sina.com.cn/usstock/api/jsonp.php"
|
|
60
|
+
"/IO.XSRV2.CallbackList[{}]/US_CategoryService.getList")
|
|
45
61
|
us_sina_stock_dict_payload = {
|
|
46
62
|
"page": "2",
|
|
47
63
|
"num": "20",
|
|
48
64
|
"sort": "",
|
|
49
65
|
"asc": "0",
|
|
50
66
|
"market": "",
|
|
51
|
-
"id": ""
|
|
67
|
+
"id": "",
|
|
52
68
|
}
|
|
53
69
|
js_hash_text = """
|
|
54
70
|
function d(s){
|
|
@@ -111,7 +127,8 @@ js_hash_text = """
|
|
|
111
127
|
hk_sina_stock_hist_hfq_url = "https://finance.sina.com.cn/stock/hkstock/{}/hfq.js"
|
|
112
128
|
hk_sina_stock_hist_qfq_url = "https://finance.sina.com.cn/stock/hkstock/{}/qfq.js"
|
|
113
129
|
hk_sina_stock_hist_url = "https://finance.sina.com.cn/stock/hkstock/{}/klc_kl.js"
|
|
114
|
-
hk_sina_stock_list_url = "http://vip.stock.finance.sina.com.cn/quotes_service/api/
|
|
130
|
+
hk_sina_stock_list_url = ("http://vip.stock.finance.sina.com.cn/quotes_service/api/"
|
|
131
|
+
"json_v2.php/Market_Center.getHKStockData")
|
|
115
132
|
|
|
116
133
|
hk_sina_stock_dict_payload = {
|
|
117
134
|
"page": "1",
|
|
@@ -119,14 +136,15 @@ hk_sina_stock_dict_payload = {
|
|
|
119
136
|
"sort": "symbol",
|
|
120
137
|
"asc": "1",
|
|
121
138
|
"node": "qbgg_hk",
|
|
122
|
-
"_s_r_a": "page"
|
|
139
|
+
"_s_r_a": "page",
|
|
123
140
|
}
|
|
124
141
|
|
|
125
142
|
# hk-tx
|
|
126
143
|
hk_url = "http://stock.gtimg.cn/data/hk_rank.php"
|
|
127
144
|
hk_headers = {
|
|
128
145
|
"Referer": "http://stockapp.finance.qq.com/mstats/",
|
|
129
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
|
|
146
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
|
147
|
+
"(KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36",
|
|
130
148
|
}
|
|
131
149
|
hk_payload = {
|
|
132
150
|
"board": "A_H",
|
|
@@ -134,18 +152,19 @@ hk_payload = {
|
|
|
134
152
|
"pageSize": "20",
|
|
135
153
|
"reqPage": "1",
|
|
136
154
|
"order": "decs",
|
|
137
|
-
"var_name": "list_data"
|
|
155
|
+
"var_name": "list_data",
|
|
138
156
|
}
|
|
139
157
|
|
|
140
158
|
hk_stock_url = "http://web.ifzq.gtimg.cn/appstock/app/hkfqkline/get"
|
|
141
159
|
hk_stock_headers = {
|
|
142
160
|
# "Referer": "http://gu.qq.com/hk00168/gp",
|
|
143
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
|
|
161
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
|
|
162
|
+
"(KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"
|
|
144
163
|
}
|
|
145
164
|
hk_stock_payload = {
|
|
146
165
|
"_var": "kline_dayhfq{}",
|
|
147
166
|
"param": "hk{},day,{}-01-01,{}-12-31,640,hfq",
|
|
148
|
-
"r": ""
|
|
167
|
+
"r": "",
|
|
149
168
|
}
|
|
150
169
|
|
|
151
170
|
# usa
|
|
@@ -154,7 +173,7 @@ payload_usa_daily = {
|
|
|
154
173
|
"code": "NASDAQNTES",
|
|
155
174
|
"start": "20191026213000",
|
|
156
175
|
"number": "-1000",
|
|
157
|
-
"type": "5"
|
|
176
|
+
"type": "5",
|
|
158
177
|
}
|
|
159
178
|
|
|
160
179
|
# china
|
|
@@ -166,11 +185,29 @@ hx_headers = {
|
|
|
166
185
|
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
|
167
186
|
"Cache-Control": "no-cache",
|
|
168
187
|
"Connection": "keep-alive",
|
|
169
|
-
"Cookie": "ADVC=371c0a2afd9a7b; UM_distinctid=16a24d29c4f142-0f969e46eea4c7-e323069-1fa400-16a24d29c50aa5;
|
|
188
|
+
"Cookie": "ADVC=371c0a2afd9a7b; UM_distinctid=16a24d29c4f142-0f969e46eea4c7-e323069-1fa400-16a24d29c50aa5; "
|
|
189
|
+
"HexunTrack=SID=20190416142542146f54a3710276640a88fea687ad6a7bcb0&CITY=51&TOWN=510100; "
|
|
190
|
+
"vjuids=11fcc219b5.16a820267e4.0.cc0391a93be56; vjlast=1556959357.1556959357.30; "
|
|
191
|
+
"__utma=194262068.1423418741.1558975446.1558975446.1558975446.1; "
|
|
192
|
+
"__utmz=194262068.1558975446.1.1.utmcsr=baidu|utmccn=(organic)|utmcmd=organic; "
|
|
193
|
+
"ASL=18179,anzqo,7ca108c3ded485387ca108c27ca108b97ca108ef; "
|
|
194
|
+
"cn_1263247791_dplus=%7B%22distinct_id%22%3A%20%2216a24d29c4f142-0f969e46eea4c7-e323069-1fa400-"
|
|
195
|
+
"16a24d29c50aa5%22%2C%22userFirstDate%22%3A%20%2220190504%22%2C%22userID%22%3A%20%22%22%2C%22us"
|
|
196
|
+
"erName%22%3A%20%22%22%2C%22userType%22%3A%20%22nologinuser%22%2C%22userLoginDate%22%3A%20%2"
|
|
197
|
+
"220191010%22%2C%22%24_sessionid%22%3A%200%2C%22%24_sessionTime%22%3A%201570727325%2C%22%2"
|
|
198
|
+
"4dp%22%3A%200%2C%22%24_sessionPVTime%22%3A%201570727325%2C%22initial_view_time%22%3A%20%"
|
|
199
|
+
"221556958609%22%2C%22initial_referrer%22%3A%20%22https%3A%2F%2Fwww.baidu.com%2Flink%3F"
|
|
200
|
+
"url%3DJmHPP1QGABcJs0kzrvZREqHK_nobidR7d7YPCQF75loa5N33Au5q_xFu8y9VPlvl8O6I7b1LmRuhIicc"
|
|
201
|
+
"TnFW-_%26wd%3D%26eqid%3Db55837ee0001a310000000025ccd4f55%22%2C%22initial_referrer_doma"
|
|
202
|
+
"in%22%3A%20%22www.baidu.com%22%2C%22%24recent_outside_referrer%22%3A%20%22www.baidu.co"
|
|
203
|
+
"m%22%7D; hxck_webdev1_general=bondjlvcookie_list=019124_11%e5%9b%bd%e5%80%ba24_1&npF"
|
|
204
|
+
"utjlvcookie_list=czcers1409|WT1009; appToken=pc%2Cother%2Cchrome%2ChxAppSignId9625376"
|
|
205
|
+
"0252191461570688954189%2CHXGG20190415; __jsluid_h=08f65cba22ad34dc3fd095b5b986c8a4",
|
|
170
206
|
"Host": "stockdata.stock.hexun.com",
|
|
171
207
|
"Pragma": "no-cache",
|
|
172
208
|
"Referer": "http://stockdata.stock.hexun.com/zrbg/",
|
|
173
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
209
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
210
|
+
"Chrome/77.0.3865.120 Safari/537.36",
|
|
174
211
|
}
|
|
175
212
|
|
|
176
213
|
hx_params = {
|