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
|
@@ -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,15 +1,18 @@
|
|
|
1
1
|
# -*- coding:utf-8 -*-
|
|
2
2
|
# !/usr/bin/env python
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/8/22 10:00
|
|
5
5
|
Desc: 上海黄金交易所-数据资讯-行情走势
|
|
6
6
|
https://www.sge.com.cn/sjzx/mrhq
|
|
7
7
|
上海黄金交易所-数据资讯-上海金基准价-历史数据
|
|
8
8
|
上海黄金交易所-数据资讯-上海银基准价-历史数据
|
|
9
9
|
"""
|
|
10
|
+
|
|
10
11
|
import pandas as pd
|
|
11
12
|
import requests
|
|
12
13
|
|
|
14
|
+
from akshare.utils.cons import headers
|
|
15
|
+
|
|
13
16
|
|
|
14
17
|
def spot_symbol_table_sge() -> pd.DataFrame:
|
|
15
18
|
"""
|
|
@@ -44,11 +47,63 @@ def spot_symbol_table_sge() -> pd.DataFrame:
|
|
|
44
47
|
return temp_df
|
|
45
48
|
|
|
46
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
|
+
return temp_df
|
|
98
|
+
|
|
99
|
+
|
|
47
100
|
def spot_hist_sge(symbol: str = "Au99.99") -> pd.DataFrame:
|
|
48
101
|
"""
|
|
49
102
|
上海黄金交易所-数据资讯-行情走势-历史数据
|
|
50
103
|
https://www.sge.com.cn/sjzx/mrhq
|
|
51
|
-
:param symbol: choice of {'Au99.99', 'Au99.95', 'Au100g', 'Pt99.95', 'Ag(T+D)', 'Au(T+D)',
|
|
104
|
+
:param symbol: choice of {'Au99.99', 'Au99.95', 'Au100g', 'Pt99.95', 'Ag(T+D)', 'Au(T+D)',
|
|
105
|
+
'mAu(T+D)', 'Au(T+N1)', 'Au(T+N2)', 'Ag99.99', 'iAu99.99', 'Au99.5', 'iAu100g', 'iAu99.5',
|
|
106
|
+
'PGC30g', 'NYAuTN06', 'NYAuTN12'}; 可以通过 ak.spot_symbol_table_sge() 获取品种表
|
|
52
107
|
:type symbol: str
|
|
53
108
|
:return: 历史数据
|
|
54
109
|
:rtype: pandas.DataFrame
|
|
@@ -73,7 +128,8 @@ def spot_hist_sge(symbol: str = "Au99.99") -> pd.DataFrame:
|
|
|
73
128
|
"Sec-Fetch-Dest": "empty",
|
|
74
129
|
"Sec-Fetch-Mode": "cors",
|
|
75
130
|
"Sec-Fetch-Site": "same-origin",
|
|
76
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
|
|
131
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
132
|
+
"Chrome/107.0.0.0 Safari/537.36",
|
|
77
133
|
"X-Requested-With": "XMLHttpRequest",
|
|
78
134
|
}
|
|
79
135
|
r = requests.post(url, data=payload, headers=headers)
|
|
@@ -83,8 +139,8 @@ def spot_hist_sge(symbol: str = "Au99.99") -> pd.DataFrame:
|
|
|
83
139
|
"date",
|
|
84
140
|
"open",
|
|
85
141
|
"close",
|
|
86
|
-
"high",
|
|
87
142
|
"low",
|
|
143
|
+
"high",
|
|
88
144
|
]
|
|
89
145
|
|
|
90
146
|
temp_df["date"] = pd.to_datetime(temp_df["date"], errors="coerce").dt.date
|
|
@@ -104,9 +160,6 @@ def spot_golden_benchmark_sge() -> pd.DataFrame:
|
|
|
104
160
|
"""
|
|
105
161
|
url = "https://www.sge.com.cn/graph/DayilyJzj"
|
|
106
162
|
payload = {}
|
|
107
|
-
headers = {
|
|
108
|
-
"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",
|
|
109
|
-
}
|
|
110
163
|
r = requests.post(url, data=payload, headers=headers)
|
|
111
164
|
data_json = r.json()
|
|
112
165
|
temp_df = pd.DataFrame(data_json["wp"])
|
|
@@ -138,9 +191,6 @@ def spot_silver_benchmark_sge() -> pd.DataFrame:
|
|
|
138
191
|
"""
|
|
139
192
|
url = "https://www.sge.com.cn/graph/DayilyShsilverJzj"
|
|
140
193
|
payload = {}
|
|
141
|
-
headers = {
|
|
142
|
-
"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",
|
|
143
|
-
}
|
|
144
194
|
r = requests.post(url, data=payload, headers=headers)
|
|
145
195
|
data_json = r.json()
|
|
146
196
|
temp_df = pd.DataFrame(data_json["wp"])
|
|
@@ -179,3 +229,6 @@ if __name__ == "__main__":
|
|
|
179
229
|
for spot in spot_symbol_table_sge_df["品种"].tolist():
|
|
180
230
|
spot_hist_sge_df = spot_hist_sge(symbol=spot)
|
|
181
231
|
print(spot_hist_sge_df)
|
|
232
|
+
|
|
233
|
+
spot_quotations_sge_df = spot_quotations_sge(symbol="Au99.99")
|
|
234
|
+
print(spot_quotations_sge_df)
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date:
|
|
4
|
+
Date: 2024/10/22 15:00
|
|
5
5
|
Desc: 巨潮资讯-数据浏览器-筹资指标-公司配股实施方案
|
|
6
|
-
|
|
6
|
+
https://webapi.cninfo.com.cn/#/dataBrowse
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
import pandas as pd
|
|
10
|
+
import py_mini_racer
|
|
9
11
|
import requests
|
|
10
|
-
from py_mini_racer import py_mini_racer
|
|
11
12
|
|
|
12
13
|
from akshare.datasets import get_ths_js
|
|
13
14
|
|
|
@@ -21,7 +22,7 @@ def _get_file_content_cninfo(file: str = "cninfo.js") -> str:
|
|
|
21
22
|
:rtype: str
|
|
22
23
|
"""
|
|
23
24
|
setting_file_path = get_ths_js(file)
|
|
24
|
-
with open(setting_file_path) as f:
|
|
25
|
+
with open(setting_file_path, encoding="utf-8") as f:
|
|
25
26
|
file_data = f.read()
|
|
26
27
|
return file_data
|
|
27
28
|
|
|
@@ -31,7 +32,7 @@ def stock_allotment_cninfo(
|
|
|
31
32
|
) -> pd.DataFrame:
|
|
32
33
|
"""
|
|
33
34
|
巨潮资讯-个股-配股实施方案
|
|
34
|
-
|
|
35
|
+
https://webapi.cninfo.com.cn/#/dataBrowse
|
|
35
36
|
:param symbol: 股票代码
|
|
36
37
|
:type symbol: str
|
|
37
38
|
:param start_date: 开始查询的日期
|
|
@@ -41,7 +42,7 @@ def stock_allotment_cninfo(
|
|
|
41
42
|
:return: 配股实施方案
|
|
42
43
|
:rtype: pandas.DataFrame
|
|
43
44
|
"""
|
|
44
|
-
url = "
|
|
45
|
+
url = "https://webapi.cninfo.com.cn/api/stock/p_stock2232"
|
|
45
46
|
params = {
|
|
46
47
|
"scode": symbol,
|
|
47
48
|
"sdate": start_date
|
|
@@ -63,10 +64,10 @@ def stock_allotment_cninfo(
|
|
|
63
64
|
"Cache-Control": "no-cache",
|
|
64
65
|
"Content-Length": "0",
|
|
65
66
|
"Host": "webapi.cninfo.com.cn",
|
|
66
|
-
"Origin": "
|
|
67
|
+
"Origin": "https://webapi.cninfo.com.cn",
|
|
67
68
|
"Pragma": "no-cache",
|
|
68
69
|
"Proxy-Connection": "keep-alive",
|
|
69
|
-
"Referer": "
|
|
70
|
+
"Referer": "https://webapi.cninfo.com.cn/",
|
|
70
71
|
"X-Requested-With": "XMLHttpRequest",
|
|
71
72
|
}
|
|
72
73
|
r = requests.post(url, params=params, headers=headers)
|
|
@@ -191,6 +192,6 @@ def stock_allotment_cninfo(
|
|
|
191
192
|
|
|
192
193
|
if __name__ == "__main__":
|
|
193
194
|
stock_allotment_cninfo_df = stock_allotment_cninfo(
|
|
194
|
-
symbol="600030", start_date="19900101", end_date="
|
|
195
|
+
symbol="600030", start_date="19900101", end_date="20241022"
|
|
195
196
|
)
|
|
196
197
|
print(stock_allotment_cninfo_df)
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
2
|
# -*- coding:utf-8 -*-
|
|
3
3
|
"""
|
|
4
|
-
Date: 2024/
|
|
4
|
+
Date: 2024/3/20 15:00
|
|
5
5
|
Desc: 东方财富-行情报价
|
|
6
6
|
https://quote.eastmoney.com/sz000001.html
|
|
7
7
|
"""
|
|
8
|
+
|
|
8
9
|
from functools import lru_cache
|
|
9
10
|
|
|
10
11
|
import pandas as pd
|
|
@@ -19,7 +20,7 @@ def __code_id_map_em() -> dict:
|
|
|
19
20
|
:return: 股票和市场代码
|
|
20
21
|
:rtype: dict
|
|
21
22
|
"""
|
|
22
|
-
url = "
|
|
23
|
+
url = "https://80.push2.eastmoney.com/api/qt/clist/get"
|
|
23
24
|
params = {
|
|
24
25
|
"pn": "1",
|
|
25
26
|
"pz": "50000",
|
|
@@ -98,7 +99,14 @@ def stock_bid_ask_em(symbol: str = "000001") -> pd.DataFrame:
|
|
|
98
99
|
params = {
|
|
99
100
|
"fltt": "2",
|
|
100
101
|
"invt": "2",
|
|
101
|
-
"fields": "f120,f121,f122,f174,f175,f59,f163,f43,f57,f58,f169,f170,f46,f44,f51,
|
|
102
|
+
"fields": "f120,f121,f122,f174,f175,f59,f163,f43,f57,f58,f169,f170,f46,f44,f51,"
|
|
103
|
+
"f168,f47,f164,f116,f60,f45,f52,f50,f48,f167,f117,f71,f161,f49,f530,"
|
|
104
|
+
"f135,f136,f137,f138,f139,f141,f142,f144,f145,f147,f148,f140,f143,f146,"
|
|
105
|
+
"f149,f55,f62,f162,f92,f173,f104,f105,f84,f85,f183,f184,f185,f186,f187,"
|
|
106
|
+
"f188,f189,f190,f191,f192,f107,f111,f86,f177,f78,f110,f262,f263,f264,f267,"
|
|
107
|
+
"f268,f255,f256,f257,f258,f127,f199,f128,f198,f259,f260,f261,f171,f277,f278,"
|
|
108
|
+
"f279,f288,f152,f250,f251,f252,f253,f254,f269,f270,f271,f272,f273,f274,f275,"
|
|
109
|
+
"f276,f265,f266,f289,f290,f286,f285,f292,f293,f294,f295",
|
|
102
110
|
"secid": f"{code_id_map_em_dict[symbol]}.{symbol}",
|
|
103
111
|
}
|
|
104
112
|
r = requests.get(url, params=params)
|
|
@@ -124,6 +132,22 @@ def stock_bid_ask_em(symbol: str = "000001") -> pd.DataFrame:
|
|
|
124
132
|
"buy_4_vol": data_json["data"]["f14"] * 100,
|
|
125
133
|
"buy_5": data_json["data"]["f11"],
|
|
126
134
|
"buy_5_vol": data_json["data"]["f12"] * 100,
|
|
135
|
+
"最新": data_json["data"]["f43"],
|
|
136
|
+
"均价": data_json["data"]["f71"],
|
|
137
|
+
"涨幅": data_json["data"]["f170"],
|
|
138
|
+
"涨跌": data_json["data"]["f169"],
|
|
139
|
+
"总手": data_json["data"]["f47"],
|
|
140
|
+
"金额": data_json["data"]["f48"],
|
|
141
|
+
"换手": data_json["data"]["f168"],
|
|
142
|
+
"量比": data_json["data"]["f50"],
|
|
143
|
+
"最高": data_json["data"]["f44"],
|
|
144
|
+
"最低": data_json["data"]["f45"],
|
|
145
|
+
"今开": data_json["data"]["f46"],
|
|
146
|
+
"昨收": data_json["data"]["f60"],
|
|
147
|
+
"涨停": data_json["data"]["f51"],
|
|
148
|
+
"跌停": data_json["data"]["f52"],
|
|
149
|
+
"外盘": data_json["data"]["f49"],
|
|
150
|
+
"内盘": data_json["data"]["f161"],
|
|
127
151
|
}
|
|
128
152
|
temp_df = pd.DataFrame.from_dict(tick_dict, orient="index")
|
|
129
153
|
temp_df.reset_index(inplace=True)
|